@automattic/vip-design-system 2.1.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +3 -0
- package/build/system/Accordion/Accordion.test.d.ts +0 -1
- package/build/system/Accordion/Accordion.test.js +23 -12
- package/build/system/Avatar/Avatar.d.ts +0 -1
- package/build/system/Avatar/Avatar.js +9 -17
- package/build/system/Avatar/Avatar.stories.d.ts +2 -1
- package/build/system/Avatar/Avatar.stories.js +19 -2
- package/build/system/Button/Button.d.ts +2 -0
- package/build/system/Button/Button.js +6 -15
- package/build/system/Button/Button.stories.js +86 -67
- package/build/system/Card/Card.js +1 -2
- package/build/system/Drawer/Drawer.d.ts +12 -3
- package/build/system/Drawer/Drawer.js +8 -9
- package/build/system/Drawer/Drawer.stories.d.ts +0 -1
- package/build/system/Drawer/Drawer.stories.js +19 -225
- package/build/system/Drawer/styles.d.ts +2 -2
- package/build/system/Drawer/styles.js +13 -9
- package/build/system/Form/Checkbox/Checkbox.js +0 -3
- package/build/system/Form/Checkbox/Checkbox.stories.js +2 -2
- package/build/system/Form/Checkbox/styles.js +16 -11
- package/build/system/Form/Radio/Radio.stories.js +1 -1
- package/build/system/Form/Toggle.d.ts +14 -2
- package/build/system/Form/Toggle.js +68 -69
- package/build/system/Form/Toggle.stories.d.ts +29 -18
- package/build/system/Form/Toggle.stories.js +99 -0
- package/build/system/Form/Toggle.test.js +36 -19
- package/build/system/Link/Link.d.ts +1 -1
- package/build/system/Link/Link.js +5 -20
- package/build/system/Link/Link.stories.d.ts +3 -1
- package/build/system/Link/Link.stories.js +18 -1
- package/build/system/MobileMenu/MobileMenu.d.ts +16 -0
- package/build/system/MobileMenu/MobileMenu.js +112 -0
- package/build/system/MobileMenu/MobileMenu.stories.d.ts +19 -0
- package/build/system/MobileMenu/MobileMenu.stories.js +173 -0
- package/build/system/MobileMenu/MobileMenu.test.d.ts +1 -0
- package/build/system/MobileMenu/MobileMenu.test.js +81 -0
- package/build/system/Nav/NavItem.js +4 -5
- package/build/system/Nav/NavItemGroup.d.ts +3 -0
- package/build/system/Nav/NavItemGroup.js +18 -6
- package/build/system/Nav/styles/variants/menu.js +15 -9
- package/build/system/Nav/styles/variants/menugroup.js +9 -5
- package/build/system/Nav/styles/variants/toolbar.js +1 -2
- package/build/system/Nav/styles.js +1 -0
- package/build/system/NewDialog/DialogClose.d.ts +7 -2
- package/build/system/NewDialog/DialogClose.js +25 -15
- package/build/system/NewDialog/index.d.ts +2 -1
- package/build/system/NewDialog/index.js +2 -1
- package/build/system/NewForm/FormAutocomplete.css +1 -3
- package/build/system/Table/Table.js +1 -0
- package/build/system/Toolbar/Toolbar.js +1 -1
- package/build/system/Toolbar/Toolbar.stories.d.ts +3 -0
- package/build/system/Toolbar/Toolbar.stories.js +62 -6
- package/build/system/Toolbar/ToolbarUtilNav.d.ts +3 -0
- package/build/system/Toolbar/ToolbarUtilNav.js +21 -3
- package/build/system/Toolbar/index.d.ts +3 -0
- package/build/system/Toolbar/index.js +2 -1
- package/build/system/index.d.ts +4 -1
- package/build/system/index.js +4 -0
- package/build/system/theme/index.d.ts +70 -35
- package/build/system/theme/index.js +47 -18
- package/package.json +2 -1
- package/src/system/Accordion/Accordion.test.tsx +15 -8
- package/src/system/Avatar/Avatar.stories.tsx +15 -1
- package/src/system/Avatar/Avatar.tsx +8 -12
- package/src/system/Button/Button.stories.tsx +40 -31
- package/src/system/Button/Button.tsx +6 -15
- package/src/system/Card/Card.tsx +0 -1
- package/src/system/Drawer/Drawer.stories.tsx +28 -197
- package/src/system/Drawer/Drawer.tsx +31 -18
- package/src/system/Drawer/styles.ts +15 -5
- package/src/system/Form/Checkbox/Checkbox.stories.tsx +2 -2
- package/src/system/Form/Checkbox/Checkbox.tsx +0 -3
- package/src/system/Form/Checkbox/styles.ts +57 -46
- package/src/system/Form/Radio/Radio.stories.tsx +1 -1
- package/src/system/Form/Toggle.stories.tsx +122 -0
- package/src/system/Form/{Toggle.test.js → Toggle.test.tsx} +1 -1
- package/src/system/Form/Toggle.tsx +77 -0
- package/src/system/Link/Link.stories.tsx +21 -0
- package/src/system/Link/Link.tsx +10 -17
- package/src/system/MobileMenu/MobileMenu.stories.tsx +171 -0
- package/src/system/MobileMenu/MobileMenu.test.tsx +50 -0
- package/src/system/MobileMenu/MobileMenu.tsx +116 -0
- package/src/system/Nav/NavItem.tsx +3 -3
- package/src/system/Nav/NavItemGroup.tsx +18 -2
- package/src/system/Nav/styles/variants/menu.ts +15 -9
- package/src/system/Nav/styles/variants/menugroup.ts +7 -3
- package/src/system/Nav/styles/variants/toolbar.ts +1 -2
- package/src/system/Nav/styles.ts +1 -0
- package/src/system/NewDialog/DialogClose.tsx +36 -23
- package/src/system/NewDialog/index.ts +3 -2
- package/src/system/NewForm/FormAutocomplete.css +1 -3
- package/src/system/Table/Table.tsx +1 -1
- package/src/system/Toolbar/Toolbar.stories.tsx +50 -3
- package/src/system/Toolbar/Toolbar.tsx +1 -1
- package/src/system/Toolbar/ToolbarUtilNav.tsx +19 -2
- package/src/system/Toolbar/index.tsx +6 -1
- package/src/system/index.js +4 -0
- package/src/system/theme/index.js +47 -18
- package/build/system/Form/Toggle.stories.jsx +0 -96
- package/src/system/Form/Toggle.js +0 -74
- package/src/system/Form/Toggle.stories.jsx +0 -96
package/build/system/index.d.ts
CHANGED
|
@@ -21,6 +21,9 @@ import { DialogDivider } from './Dialog';
|
|
|
21
21
|
import { DialogContent } from './Dialog';
|
|
22
22
|
import { DialogTrigger } from './Dialog';
|
|
23
23
|
import { ConfirmationDialog } from './ConfirmationDialog';
|
|
24
|
+
import { MobileMenu } from './MobileMenu/MobileMenu';
|
|
25
|
+
import { MobileMenuTrigger } from './MobileMenu/MobileMenu';
|
|
26
|
+
import { MobileMenuWrapper } from './MobileMenu/MobileMenu';
|
|
24
27
|
import { NewConfirmationDialog } from './NewConfirmationDialog';
|
|
25
28
|
import { Grid } from './Grid';
|
|
26
29
|
import { Flex } from './Flex';
|
|
@@ -53,4 +56,4 @@ import { Validation } from './Form';
|
|
|
53
56
|
import { Wizard } from './Wizard';
|
|
54
57
|
import { WizardStep } from './Wizard';
|
|
55
58
|
import theme from './theme';
|
|
56
|
-
export { Accordion, Avatar, Badge, Box, Breadcrumbs, Button, ButtonSubmit, ButtonVariant, Card, Checkbox, Code, Dialog, NewDialog, Form, Drawer, Dropdown, DialogButton, DialogMenu, DialogMenuItem, DialogDivider, DialogContent, DialogTrigger, ConfirmationDialog, NewConfirmationDialog, Grid, Flex, Notice, OptionRow, Heading, Input, Label, Spinner, Table, TableRow, TableCell, Tooltip, Link, Radio, RadioBoxGroup, Textarea, Progress, Text, Tabs, Nav, NavItem, TabsTrigger, TabsContent, TabsList, Toggle, ToggleRow, Toolbar, Validation, Wizard, WizardStep, theme };
|
|
59
|
+
export { Accordion, Avatar, Badge, Box, Breadcrumbs, Button, ButtonSubmit, ButtonVariant, Card, Checkbox, Code, Dialog, NewDialog, Form, Drawer, Dropdown, DialogButton, DialogMenu, DialogMenuItem, DialogDivider, DialogContent, DialogTrigger, ConfirmationDialog, MobileMenu, MobileMenuTrigger, MobileMenuWrapper, NewConfirmationDialog, Grid, Flex, Notice, OptionRow, Heading, Input, Label, Spinner, Table, TableRow, TableCell, Tooltip, Link, Radio, RadioBoxGroup, Textarea, Progress, Text, Tabs, Nav, NavItem, TabsTrigger, TabsContent, TabsList, Toggle, ToggleRow, Toolbar, Validation, Wizard, WizardStep, theme };
|
package/build/system/index.js
CHANGED
|
@@ -36,6 +36,7 @@ import {
|
|
|
36
36
|
import { Grid } from './Grid';
|
|
37
37
|
import { Heading } from './Heading';
|
|
38
38
|
import { Link } from './Link';
|
|
39
|
+
import { MobileMenuWrapper, MobileMenuTrigger, MobileMenu } from './MobileMenu/MobileMenu';
|
|
39
40
|
import { Nav } from './Nav/Nav';
|
|
40
41
|
import { NavItem } from './Nav/NavItem';
|
|
41
42
|
import { NewConfirmationDialog } from './NewConfirmationDialog';
|
|
@@ -77,6 +78,9 @@ export {
|
|
|
77
78
|
DialogContent,
|
|
78
79
|
DialogTrigger,
|
|
79
80
|
ConfirmationDialog,
|
|
81
|
+
MobileMenu,
|
|
82
|
+
MobileMenuTrigger,
|
|
83
|
+
MobileMenuWrapper,
|
|
80
84
|
NewConfirmationDialog,
|
|
81
85
|
Grid,
|
|
82
86
|
Flex,
|
|
@@ -64,6 +64,10 @@ declare namespace _default {
|
|
|
64
64
|
color: string;
|
|
65
65
|
bg: string;
|
|
66
66
|
border: string;
|
|
67
|
+
py: number;
|
|
68
|
+
px: number;
|
|
69
|
+
minHeight: string;
|
|
70
|
+
height: string;
|
|
67
71
|
cursor: string;
|
|
68
72
|
fontWeight: string;
|
|
69
73
|
boxShadow: string;
|
|
@@ -72,6 +76,14 @@ declare namespace _default {
|
|
|
72
76
|
backgroundColor: string;
|
|
73
77
|
color: string;
|
|
74
78
|
};
|
|
79
|
+
verticalAlign: string;
|
|
80
|
+
display: string;
|
|
81
|
+
alignItems: string;
|
|
82
|
+
justifyContent: string;
|
|
83
|
+
textDecoration: string;
|
|
84
|
+
'&:hover': {
|
|
85
|
+
textDecoration: string;
|
|
86
|
+
};
|
|
75
87
|
};
|
|
76
88
|
export { primary_1 as primary };
|
|
77
89
|
let secondary_1: {
|
|
@@ -162,26 +174,45 @@ declare namespace _default {
|
|
|
162
174
|
};
|
|
163
175
|
};
|
|
164
176
|
}
|
|
165
|
-
export
|
|
166
|
-
|
|
177
|
+
export let links: {
|
|
178
|
+
primary: {
|
|
167
179
|
color: string;
|
|
168
|
-
'&:
|
|
180
|
+
'&:visited': {
|
|
169
181
|
color: string;
|
|
170
182
|
};
|
|
171
|
-
};
|
|
172
|
-
let hover: {
|
|
173
|
-
display: string;
|
|
174
|
-
color: string;
|
|
175
|
-
py: number;
|
|
176
|
-
px: number;
|
|
177
|
-
my: number;
|
|
178
|
-
mx: number;
|
|
179
|
-
borderRadius: number;
|
|
180
183
|
'&:hover': {
|
|
181
|
-
|
|
184
|
+
color: string;
|
|
185
|
+
};
|
|
186
|
+
'&:active': {
|
|
187
|
+
color: string;
|
|
188
|
+
};
|
|
189
|
+
textDecorationThickness: string;
|
|
190
|
+
textUnderlineOffset: string;
|
|
191
|
+
'&:hover, &:focus': {
|
|
192
|
+
color: string;
|
|
193
|
+
textDecorationLine: string;
|
|
194
|
+
textDecorationThickness: string;
|
|
182
195
|
};
|
|
183
196
|
};
|
|
184
|
-
|
|
197
|
+
'button-primary': {
|
|
198
|
+
variant: string;
|
|
199
|
+
};
|
|
200
|
+
'button-danger': {
|
|
201
|
+
variant: string;
|
|
202
|
+
};
|
|
203
|
+
'button-display': {
|
|
204
|
+
variant: string;
|
|
205
|
+
};
|
|
206
|
+
'button-ghost': {
|
|
207
|
+
variant: string;
|
|
208
|
+
};
|
|
209
|
+
'button-secondary': {
|
|
210
|
+
variant: string;
|
|
211
|
+
};
|
|
212
|
+
'button-tertiary': {
|
|
213
|
+
variant: string;
|
|
214
|
+
};
|
|
215
|
+
};
|
|
185
216
|
let text_1: {};
|
|
186
217
|
export { text_1 as text };
|
|
187
218
|
export namespace dialog {
|
|
@@ -277,32 +308,36 @@ declare namespace _default {
|
|
|
277
308
|
};
|
|
278
309
|
};
|
|
279
310
|
export namespace styles {
|
|
280
|
-
|
|
281
|
-
fontFamily: string;
|
|
282
|
-
lineHeight: string;
|
|
283
|
-
fontWeight: string;
|
|
284
|
-
|
|
285
|
-
color
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
a: {
|
|
311
|
+
namespace root {
|
|
312
|
+
export let fontFamily: string;
|
|
313
|
+
export let lineHeight: string;
|
|
314
|
+
export let fontWeight: string;
|
|
315
|
+
let color_1: string;
|
|
316
|
+
export { color_1 as color };
|
|
317
|
+
let backgroundColor_5: string;
|
|
318
|
+
export { backgroundColor_5 as backgroundColor };
|
|
319
|
+
export let fontSmoothing: string;
|
|
320
|
+
export let a: {
|
|
290
321
|
'&:hover': {
|
|
291
322
|
textDecorationLine: string;
|
|
292
323
|
textDecorationThickness: string;
|
|
293
324
|
};
|
|
294
325
|
};
|
|
295
|
-
svg
|
|
296
|
-
fill: string;
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
326
|
+
export namespace svg {
|
|
327
|
+
export let fill: string;
|
|
328
|
+
let display_1: string;
|
|
329
|
+
export { display_1 as display };
|
|
330
|
+
}
|
|
331
|
+
export namespace pre {
|
|
332
|
+
let fontFamily_1: string;
|
|
333
|
+
export { fontFamily_1 as fontFamily };
|
|
334
|
+
}
|
|
335
|
+
export namespace p_2 {
|
|
336
|
+
let color_2: string;
|
|
337
|
+
export { color_2 as color };
|
|
338
|
+
}
|
|
339
|
+
export { p_2 as p };
|
|
340
|
+
}
|
|
306
341
|
}
|
|
307
342
|
}
|
|
308
343
|
export default _default;
|
|
@@ -271,11 +271,14 @@ export default {
|
|
|
271
271
|
|
|
272
272
|
buttons: {
|
|
273
273
|
primary: {
|
|
274
|
-
// you can reference other values defined in the theme
|
|
275
274
|
fontFamily: 'body',
|
|
276
275
|
color: 'button.primary.label.default',
|
|
277
276
|
bg: 'button.primary.background.default',
|
|
278
277
|
border: '1px solid transparent',
|
|
278
|
+
py: 0,
|
|
279
|
+
px: 5,
|
|
280
|
+
minHeight: '38px',
|
|
281
|
+
height: '100%',
|
|
279
282
|
cursor: 'pointer',
|
|
280
283
|
fontWeight: 'medium',
|
|
281
284
|
boxShadow: 'none',
|
|
@@ -284,6 +287,14 @@ export default {
|
|
|
284
287
|
backgroundColor: 'button.primary.background.hover',
|
|
285
288
|
color: 'button.primary.label.hover',
|
|
286
289
|
},
|
|
290
|
+
verticalAlign: 'middle',
|
|
291
|
+
display: 'inline-flex',
|
|
292
|
+
alignItems: 'center',
|
|
293
|
+
justifyContent: 'center',
|
|
294
|
+
textDecoration: 'none',
|
|
295
|
+
'&:hover': {
|
|
296
|
+
textDecoration: 'none',
|
|
297
|
+
},
|
|
287
298
|
},
|
|
288
299
|
|
|
289
300
|
secondary: {
|
|
@@ -387,23 +398,43 @@ export default {
|
|
|
387
398
|
},
|
|
388
399
|
|
|
389
400
|
links: {
|
|
390
|
-
|
|
391
|
-
color: '
|
|
392
|
-
'&:
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
hover: {
|
|
396
|
-
display: 'block',
|
|
397
|
-
color: 'inherit',
|
|
398
|
-
py: 1,
|
|
399
|
-
px: 2,
|
|
400
|
-
my: -1,
|
|
401
|
-
mx: -2,
|
|
402
|
-
borderRadius: 2,
|
|
401
|
+
primary: {
|
|
402
|
+
color: 'link',
|
|
403
|
+
'&:visited': {
|
|
404
|
+
color: 'links.visited',
|
|
405
|
+
},
|
|
403
406
|
'&:hover': {
|
|
404
|
-
|
|
407
|
+
color: 'hover',
|
|
408
|
+
},
|
|
409
|
+
'&:active': {
|
|
410
|
+
color: 'links.active',
|
|
411
|
+
},
|
|
412
|
+
textDecorationThickness: '0.125rem',
|
|
413
|
+
textUnderlineOffset: '0.125rem',
|
|
414
|
+
'&:hover, &:focus': {
|
|
415
|
+
color: 'links.hover',
|
|
416
|
+
textDecorationLine: 'underline',
|
|
417
|
+
textDecorationThickness: '0.125rem',
|
|
405
418
|
},
|
|
406
419
|
},
|
|
420
|
+
'button-primary': {
|
|
421
|
+
variant: 'buttons.primary',
|
|
422
|
+
},
|
|
423
|
+
'button-danger': {
|
|
424
|
+
variant: 'buttons.danger',
|
|
425
|
+
},
|
|
426
|
+
'button-display': {
|
|
427
|
+
variant: 'buttons.display',
|
|
428
|
+
},
|
|
429
|
+
'button-ghost': {
|
|
430
|
+
variant: 'buttons.ghost',
|
|
431
|
+
},
|
|
432
|
+
'button-secondary': {
|
|
433
|
+
variant: 'buttons.secondary',
|
|
434
|
+
},
|
|
435
|
+
'button-tertiary': {
|
|
436
|
+
variant: 'buttons.tertiary',
|
|
437
|
+
},
|
|
407
438
|
},
|
|
408
439
|
|
|
409
440
|
text: getHeadingStyles(),
|
|
@@ -492,11 +523,9 @@ export default {
|
|
|
492
523
|
fontFamily: 'body',
|
|
493
524
|
lineHeight: 'body',
|
|
494
525
|
fontWeight: 'body',
|
|
495
|
-
fontSize: 2,
|
|
496
526
|
color: 'text',
|
|
497
527
|
backgroundColor: 'backgrounds.primary',
|
|
498
|
-
|
|
499
|
-
'-moz-osx-font-smoothing': 'grayscale',
|
|
528
|
+
fontSmoothing: 'antialiased',
|
|
500
529
|
a: {
|
|
501
530
|
'&:hover': {
|
|
502
531
|
textDecorationLine: 'underline',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@automattic/vip-design-system",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"main": "build/system/index.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build-storybook": "storybook build",
|
|
@@ -93,6 +93,7 @@
|
|
|
93
93
|
"@testing-library/dom": "9.3.3",
|
|
94
94
|
"@testing-library/jest-dom": "6.1.3",
|
|
95
95
|
"@testing-library/react": "14.0.0",
|
|
96
|
+
"@testing-library/user-event": "^14.4.3",
|
|
96
97
|
"@tsconfig/node18": "18.2.2",
|
|
97
98
|
"@types/jest": "29.5.5",
|
|
98
99
|
"@types/jest-axe": "3.5.6",
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
// TODO: Fix this
|
|
2
1
|
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
3
2
|
// @ts-nocheck
|
|
4
3
|
/** @jsxImportSource theme-ui */
|
|
5
|
-
|
|
6
4
|
/**
|
|
7
5
|
* External dependencies
|
|
8
6
|
*/
|
|
9
|
-
import {
|
|
7
|
+
import { render, screen } from '@testing-library/react';
|
|
8
|
+
import userEvent from '@testing-library/user-event';
|
|
10
9
|
import { axe } from 'jest-axe';
|
|
11
10
|
import { ThemeUIProvider } from 'theme-ui';
|
|
12
11
|
|
|
@@ -48,15 +47,23 @@ describe( '<Accordion />', () => {
|
|
|
48
47
|
} );
|
|
49
48
|
|
|
50
49
|
it( 'should open the content when clicking on its trigger', async () => {
|
|
50
|
+
const user = userEvent.setup();
|
|
51
|
+
|
|
51
52
|
const { container } = renderComponent();
|
|
52
53
|
|
|
53
|
-
|
|
54
|
+
await user.click( screen.getByRole( 'button', { name: 'trigger two', expanded: false } ) );
|
|
54
55
|
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
expect(
|
|
57
|
+
screen.getByRole( 'button', { name: 'trigger one', expanded: false } )
|
|
58
|
+
).toHaveAttribute( 'data-state', 'closed' );
|
|
59
|
+
expect( screen.queryByText( 'content one' ) ).not.toBeInTheDocument();
|
|
57
60
|
|
|
58
|
-
// Should
|
|
59
|
-
expect( screen.
|
|
61
|
+
// Should find the open content
|
|
62
|
+
expect( screen.getByRole( 'button', { name: 'trigger two', expanded: true } ) ).toHaveAttribute(
|
|
63
|
+
'data-state',
|
|
64
|
+
'open'
|
|
65
|
+
);
|
|
66
|
+
expect( screen.getByText( 'content two' ) ).toBeVisible();
|
|
60
67
|
|
|
61
68
|
// Check for accessibility issues
|
|
62
69
|
expect( await axe( container ) ).toHaveNoViolations();
|
|
@@ -16,4 +16,18 @@ export default {
|
|
|
16
16
|
|
|
17
17
|
type Story = StoryObj< typeof Avatar >;
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
const COMMON_SIZES = [ 128, 64, 48, 32, 24, 16 ];
|
|
20
|
+
|
|
21
|
+
export const Default = () => (
|
|
22
|
+
<>
|
|
23
|
+
{ COMMON_SIZES.map( size => (
|
|
24
|
+
<Avatar key={ size } size={ size } src="https://i.pravatar.cc/100" />
|
|
25
|
+
) ) }
|
|
26
|
+
</>
|
|
27
|
+
);
|
|
28
|
+
export const WithName: Story = {
|
|
29
|
+
args: {
|
|
30
|
+
name: 'Kitty',
|
|
31
|
+
size: 30,
|
|
32
|
+
},
|
|
33
|
+
};
|
|
@@ -11,7 +11,6 @@ import { Image, ImageProps, ThemeUIStyleObject } from 'theme-ui';
|
|
|
11
11
|
import { Box, Text } from '..';
|
|
12
12
|
|
|
13
13
|
export interface AvatarProps {
|
|
14
|
-
isVIP?: boolean;
|
|
15
14
|
size?: number;
|
|
16
15
|
src?: string;
|
|
17
16
|
name?: string;
|
|
@@ -23,24 +22,21 @@ type AvatarImageProps = AvatarProps & ImageProps;
|
|
|
23
22
|
|
|
24
23
|
export const Avatar = forwardRef< HTMLElement, AvatarImageProps >(
|
|
25
24
|
(
|
|
26
|
-
{
|
|
25
|
+
{ name, size = 32, src, className, sx = {}, ...props }: AvatarImageProps,
|
|
27
26
|
ref: Ref< HTMLElement >
|
|
28
27
|
) => (
|
|
29
28
|
<Box
|
|
30
29
|
sx={ {
|
|
31
30
|
borderRadius: '100%',
|
|
32
|
-
height: size
|
|
33
|
-
width: size
|
|
34
|
-
borderWidth: '2px',
|
|
35
|
-
borderStyle: 'solid',
|
|
36
|
-
borderColor: isVIP || isVIP === undefined ? 'primary' : 'transparent',
|
|
31
|
+
height: size,
|
|
32
|
+
width: size,
|
|
37
33
|
overflow: 'hidden',
|
|
38
|
-
|
|
34
|
+
border: 'none',
|
|
35
|
+
backgroundColor: 'icon.primary',
|
|
39
36
|
display: 'inline-flex',
|
|
40
37
|
alignItems: 'center',
|
|
41
38
|
justifyContent: 'center',
|
|
42
|
-
color: '
|
|
43
|
-
padding: '1px', // this should probably be replaced with a token
|
|
39
|
+
color: 'inverse',
|
|
44
40
|
textAlign: 'center',
|
|
45
41
|
...sx,
|
|
46
42
|
} }
|
|
@@ -63,10 +59,10 @@ export const Avatar = forwardRef< HTMLElement, AvatarImageProps >(
|
|
|
63
59
|
<Text
|
|
64
60
|
as="span"
|
|
65
61
|
sx={ {
|
|
66
|
-
color: '
|
|
62
|
+
color: 'icon.inverse',
|
|
67
63
|
mb: 0,
|
|
68
64
|
fontWeight: 'bold',
|
|
69
|
-
fontSize:
|
|
65
|
+
fontSize: 2,
|
|
70
66
|
textTransform: 'uppercase',
|
|
71
67
|
} }
|
|
72
68
|
>
|
|
@@ -10,6 +10,7 @@ import { BiCalendarHeart } from 'react-icons/bi';
|
|
|
10
10
|
* Internal dependencies
|
|
11
11
|
*/
|
|
12
12
|
import { Button, ButtonVariant } from '..';
|
|
13
|
+
import { Flex } from '../Flex/Flex';
|
|
13
14
|
import ScreenReaderText from '../ScreenReaderText';
|
|
14
15
|
|
|
15
16
|
export default {
|
|
@@ -66,48 +67,56 @@ This documentation is heavily inspired by the [U.S Web Design System (USWDS)](ht
|
|
|
66
67
|
};
|
|
67
68
|
|
|
68
69
|
const Template = args => (
|
|
69
|
-
<
|
|
70
|
-
<
|
|
70
|
+
<div>
|
|
71
|
+
<Flex sx={ { gap: 2, flexDirection: 'row' } }>
|
|
72
|
+
<Button { ...args }>Primary</Button>
|
|
71
73
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
74
|
+
<Button variant="secondary" sx={ { ml: 2 } } { ...args }>
|
|
75
|
+
Secondary
|
|
76
|
+
</Button>
|
|
75
77
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
78
|
+
<Button variant="tertiary" sx={ { ml: 2 } } { ...args }>
|
|
79
|
+
Tertiary
|
|
80
|
+
</Button>
|
|
79
81
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
82
|
+
<Button variant="ghost" sx={ { ml: 2 } } { ...args }>
|
|
83
|
+
Ghost
|
|
84
|
+
</Button>
|
|
83
85
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
86
|
+
<Button variant="display" sx={ { ml: 2 } } { ...args }>
|
|
87
|
+
Display
|
|
88
|
+
</Button>
|
|
87
89
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
90
|
+
<Button variant="danger" sx={ { ml: 2 } } { ...args }>
|
|
91
|
+
Danger
|
|
92
|
+
</Button>
|
|
91
93
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
94
|
+
<Button variant="primary" disabled={ true } sx={ { ml: 2 } } { ...args }>
|
|
95
|
+
Disabled
|
|
96
|
+
</Button>
|
|
95
97
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
98
|
+
<Button variant="text" sx={ { ml: 2 } } as="a" href="https://google/com" { ...args }>
|
|
99
|
+
Button link
|
|
100
|
+
</Button>
|
|
101
|
+
|
|
102
|
+
<Button variant="icon" sx={ { ml: 2 } } type="button" { ...args }>
|
|
103
|
+
<BiCalendarHeart size={ 24 } />
|
|
104
|
+
<ScreenReaderText>domain.com</ScreenReaderText>
|
|
105
|
+
</Button>
|
|
106
|
+
</Flex>
|
|
99
107
|
|
|
100
|
-
<
|
|
101
|
-
<
|
|
102
|
-
|
|
103
|
-
|
|
108
|
+
<div sx={ { mt: 3 } }>
|
|
109
|
+
<Button variant="secondary" href="https://google/com" { ...args } full>
|
|
110
|
+
Button with full width
|
|
111
|
+
</Button>
|
|
112
|
+
</div>
|
|
104
113
|
|
|
105
|
-
<div sx={ {
|
|
106
|
-
<Button variant="secondary" href="https://google/com" { ...args }>
|
|
107
|
-
Button with
|
|
114
|
+
<div sx={ { mt: 3, display: 'flex' } }>
|
|
115
|
+
<Button variant="secondary" href="https://google/com" { ...args } grow>
|
|
116
|
+
Button with grow width
|
|
108
117
|
</Button>
|
|
109
118
|
</div>
|
|
110
|
-
</
|
|
119
|
+
</div>
|
|
111
120
|
);
|
|
112
121
|
|
|
113
122
|
export const Default = Template.bind( {} );
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
1
|
import classNames from 'classnames';
|
|
5
|
-
import React, { useCallback, forwardRef
|
|
2
|
+
import React, { useCallback, forwardRef } from 'react';
|
|
6
3
|
import { Theme, Button as ThemeButton, ButtonProps as ThemeButtonProps } from 'theme-ui';
|
|
7
4
|
|
|
8
5
|
type ButtonClickType = React.MouseEvent< HTMLButtonElement, MouseEvent >;
|
|
@@ -25,11 +22,13 @@ export enum ButtonVariant {
|
|
|
25
22
|
export interface ButtonProps extends ThemeButtonProps {
|
|
26
23
|
disabled?: boolean;
|
|
27
24
|
onClick?: ( event: ButtonClickType ) => void;
|
|
25
|
+
full?: boolean;
|
|
26
|
+
grow?: boolean;
|
|
28
27
|
variant?: keyof typeof ButtonVariant; // converts the enum to a string union type
|
|
29
28
|
}
|
|
30
29
|
|
|
31
30
|
const Button = forwardRef< HTMLButtonElement, ButtonProps >(
|
|
32
|
-
( { className, disabled, onClick, sx, ...rest }
|
|
31
|
+
( { className, disabled, onClick, sx, full, grow, ...rest }, ref ) => {
|
|
33
32
|
const handleOnClick = useCallback(
|
|
34
33
|
( event: ButtonClickType ) => {
|
|
35
34
|
if ( disabled ) {
|
|
@@ -46,16 +45,6 @@ const Button = forwardRef< HTMLButtonElement, ButtonProps >(
|
|
|
46
45
|
return (
|
|
47
46
|
<ThemeButton
|
|
48
47
|
sx={ {
|
|
49
|
-
verticalAlign: 'middle',
|
|
50
|
-
display: 'inline-flex',
|
|
51
|
-
alignItems: 'center',
|
|
52
|
-
justifyContent: 'center',
|
|
53
|
-
minHeight: '36px',
|
|
54
|
-
py: 0,
|
|
55
|
-
textDecoration: 'none',
|
|
56
|
-
'&:hover': {
|
|
57
|
-
textDecoration: 'none',
|
|
58
|
-
},
|
|
59
48
|
'&:focus': 'none',
|
|
60
49
|
'&:focus-visible': ( theme: ButtonTheme ) => theme.outline,
|
|
61
50
|
'&[aria-disabled="true"]': {
|
|
@@ -65,6 +54,8 @@ const Button = forwardRef< HTMLButtonElement, ButtonProps >(
|
|
|
65
54
|
cursor: 'not-allowed',
|
|
66
55
|
pointerEvents: 'none',
|
|
67
56
|
},
|
|
57
|
+
flexGrow: Boolean( grow ) === true ? '1' : 'initial',
|
|
58
|
+
width: Boolean( full ) === true ? '100%' : 'auto',
|
|
68
59
|
...sx,
|
|
69
60
|
} }
|
|
70
61
|
{ ...rest }
|
package/src/system/Card/Card.tsx
CHANGED