Skip to content

Commit 97f848a

Browse files
Merge pull request #712 from glints-dev/feature/next-popover
feat: next popover
2 parents 4dcba2b + c5c5444 commit 97f848a

29 files changed

Lines changed: 1054 additions & 52 deletions

package.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"module": "./es/index.js",
77
"sideEffects": false,
88
"engines": {
9-
"node": "^14 || ^16"
9+
"node": ">=14"
1010
},
1111
"scripts": {
1212
"build": "npm run build:icon && npm run build:next:icon && npm run build:lib && npm run build:es && npm run build:ts",
@@ -129,6 +129,7 @@
129129
"classnames": "^2.2.6",
130130
"downshift": "^6.1.3",
131131
"moment": "^2.24.0",
132+
"polaris-glints": "^11.0.0",
132133
"react-id-generator": "^3.0.1",
133134
"styled-system": "^5.1.5"
134135
},
@@ -144,7 +145,8 @@
144145
".+\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/test/__mocks__/fileMock.js"
145146
},
146147
"transformIgnorePatterns": [
147-
"node_modules/(?!lodash-es)"
148+
"node_modules/(?!lodash-es)",
149+
"node_modules/(?!polaris-glints)"
148150
],
149151
"modulePathIgnorePatterns": [
150152
"test/e2e/"
@@ -157,6 +159,9 @@
157159
"@glints/poppins": "^1.0.2"
158160
},
159161
"resolutions": {
160-
"immer": "^9.0.6"
162+
"immer": "^9.0.6",
163+
"@types/react": "^17.0.37",
164+
"@types/react-dom": "^17.0.11",
165+
"nanoid": "3.3.4"
161166
}
162167
}

src/@next/ButtonGroup/ButtonGroup.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import React from 'react';
22
import { Story, Meta } from '@storybook/react';
3-
import { ButtonGroup, ButtonGroupProps } from './ButtonGroupStyle';
43
import { BaseContainer } from '../../Layout/GlintsContainer/GlintsContainer';
54
import { PrimaryButton } from '../Button/PrimaryButtonStyle';
65
import { Button } from '../Button/Button';
76
import { OutlineButton } from '../Button/OutlineButtonStyle';
7+
import { ButtonGroup, ButtonGroupProps } from './ButtonGroup';
88

99
(ButtonGroup as React.FunctionComponent<ButtonGroupProps>).displayName =
1010
'ButtonGroup';
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import React from 'react';
2+
import { StyledButtonGroup } from './ButtonGroupStyle';
3+
4+
export interface ButtonGroupProps
5+
extends React.HtmlHTMLAttributes<HTMLDivElement> {
6+
segmented?: boolean;
7+
fullWidth?: boolean;
8+
/** Set this true when buttons are wrapped by another element (e.g as an activator for Popover) */
9+
isButtonWrapped?: boolean;
10+
}
11+
12+
export const ButtonGroup = ({
13+
segmented,
14+
fullWidth,
15+
isButtonWrapped,
16+
...props
17+
}: ButtonGroupProps) => {
18+
return (
19+
<StyledButtonGroup
20+
data-segmented={segmented}
21+
data-full-width={fullWidth}
22+
data-button-wrapped={isButtonWrapped}
23+
{...props}
24+
/>
25+
);
26+
};
Lines changed: 48 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,58 @@
1-
import React from 'react';
21
import styled from 'styled-components';
32
import { borderRadius4 } from '../utilities/borderRadius';
43
import { Neutral } from '../utilities/colors';
54
import { space8 } from '../utilities/spacing';
65

7-
export interface ButtonGroupProps
8-
extends React.HtmlHTMLAttributes<HTMLDivElement> {
9-
segmented?: boolean;
10-
fullWidth?: boolean;
11-
}
12-
13-
export const ButtonGroup = styled.div`
6+
export const StyledButtonGroup = styled.div`
147
display: flex;
158
flex-direction: row;
169
align-items: center;
1710
padding: 0px;
18-
${({ segmented }: ButtonGroupProps) =>
19-
segmented
20-
? `> button {
21-
border-radius: 0;
22-
border-right: 0;
23-
24-
:nth-child(1) {
25-
border-radius: ${borderRadius4} 0px 0px ${borderRadius4};
26-
}
27-
28-
:nth-last-child(1) {
29-
border-radius: 0px ${borderRadius4} ${borderRadius4} 0px;
30-
border-right: 1px solid ${Neutral.B68}
31-
}
32-
}
33-
> button:focus {
34-
z-index: 1;
35-
border: 1px solid ${Neutral.B68}
36-
}
37-
38-
button[data-active='true'] {
39-
border: 1px solid ${Neutral.B40}
40-
}
41-
`
42-
: `gap: ${space8};`}
43-
${({ fullWidth }: ButtonGroupProps) =>
44-
fullWidth
45-
? `> button {
46-
flex: 1;
47-
}`
48-
: ``}
11+
gap: ${space8};
12+
13+
&[data-segmented='true'] {
14+
gap: 0;
15+
}
16+
17+
&[data-segmented='true'] button[data-active='true'] {
18+
border: 1px solid ${Neutral.B40};
19+
}
20+
21+
&[data-segmented='true'] button {
22+
border-radius: 0;
23+
border-right: 0;
24+
25+
:nth-child(1) {
26+
border-radius: ${borderRadius4} 0px 0px ${borderRadius4};
27+
}
28+
29+
:nth-last-child(1) {
30+
border-radius: 0px ${borderRadius4} ${borderRadius4} 0px;
31+
border-right: 1px solid ${Neutral.B68};
32+
}
33+
}
34+
35+
&[data-segmented='true'] button:focus {
36+
z-index: 1;
37+
border: 1px solid ${Neutral.B68};
38+
}
39+
40+
&[data-full-width='true'] button {
41+
flex: 1;
42+
}
43+
44+
&[data-segmented='true']&[data-button-wrapped='true'] > * {
45+
button {
46+
border-radius: 0;
47+
border-right: 0;
48+
}
49+
:nth-child(1) button {
50+
border-radius: ${borderRadius4} 0px 0px ${borderRadius4};
51+
}
52+
53+
:nth-last-child(1) button {
54+
border-radius: 0px ${borderRadius4} ${borderRadius4} 0px;
55+
border-right: 1px solid ${Neutral.B68};
56+
}
57+
}
4958
`;

src/@next/ButtonGroup/index.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
import { ButtonGroup } from './ButtonGroupStyle';
2-
3-
export { ButtonGroup };
1+
export { ButtonGroup } from './ButtonGroup';

0 commit comments

Comments
 (0)