@automattic/vip-design-system 2.2.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/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/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 -5
- 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/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/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 +49 -2
- 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
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
/** @jsxImportSource theme-ui */
|
|
2
|
+
import { BiSolidHelpCircle, BiSolidBell } from 'react-icons/bi';
|
|
3
|
+
|
|
1
4
|
import { Toolbar } from '.';
|
|
2
|
-
import { Text, Avatar, Nav, NavItem } from '../../system';
|
|
5
|
+
import { Text, Avatar, Nav, NavItem, Flex, Toggle, Label } from '../../system';
|
|
3
6
|
import ScreenReaderText from '../ScreenReaderText';
|
|
4
7
|
import { CustomLink } from '../utils/stories/CustomLink';
|
|
5
8
|
|
|
@@ -58,6 +61,10 @@ export const Default: Story = {
|
|
|
58
61
|
|
|
59
62
|
<Toolbar.UtilNav>
|
|
60
63
|
<Text sx={ { color: 'toolbar.text.default', mb: 0 } }>Utility Item</Text>
|
|
64
|
+
|
|
65
|
+
<Toolbar.IconHolder>
|
|
66
|
+
<BiSolidBell />
|
|
67
|
+
</Toolbar.IconHolder>
|
|
61
68
|
</Toolbar.UtilNav>
|
|
62
69
|
</Toolbar.Primary>
|
|
63
70
|
</>
|
|
@@ -86,11 +93,51 @@ export const VIPDashboardLike: Story = {
|
|
|
86
93
|
<NavItem.Toolbar href="https://googles.com">My Applications</NavItem.Toolbar>
|
|
87
94
|
{ /* Example below if you have Next.js <Link /> */ }
|
|
88
95
|
<NavItem.Toolbar active href="https://google.com" as={ CustomLink }>
|
|
89
|
-
|
|
96
|
+
My Organizations
|
|
90
97
|
</NavItem.Toolbar>
|
|
91
98
|
</Nav.Toolbar>
|
|
92
99
|
|
|
93
100
|
<Toolbar.UtilNav>
|
|
101
|
+
<Flex sx={ { gap: 2, minHeight: 64, alignItems: 'center' } }>
|
|
102
|
+
<Flex
|
|
103
|
+
sx={ {
|
|
104
|
+
alignItems: 'center',
|
|
105
|
+
} }
|
|
106
|
+
>
|
|
107
|
+
<Toggle
|
|
108
|
+
checked={ true }
|
|
109
|
+
onChange={ () => {} }
|
|
110
|
+
name="viptogglefeaure"
|
|
111
|
+
id="viptogglefeaure"
|
|
112
|
+
variant="warning"
|
|
113
|
+
aria-label="Vip features toggle"
|
|
114
|
+
/>
|
|
115
|
+
|
|
116
|
+
<Label
|
|
117
|
+
htmlFor="viptogglefeaure"
|
|
118
|
+
sx={ { color: 'toolbar.text.default', mb: 0, ml: 2 } }
|
|
119
|
+
>
|
|
120
|
+
VIP
|
|
121
|
+
</Label>
|
|
122
|
+
</Flex>
|
|
123
|
+
|
|
124
|
+
<a
|
|
125
|
+
href="/"
|
|
126
|
+
sx={ { color: 'icon.inverse', width: 38, justifyContent: 'center', display: 'flex' } }
|
|
127
|
+
aria-label="Help center"
|
|
128
|
+
>
|
|
129
|
+
<BiSolidHelpCircle width={ 16 } height={ 16 } />
|
|
130
|
+
</a>
|
|
131
|
+
|
|
132
|
+
<a
|
|
133
|
+
href="/"
|
|
134
|
+
sx={ { color: 'icon.inverse', width: 38, justifyContent: 'center', display: 'flex' } }
|
|
135
|
+
aria-label="Help center"
|
|
136
|
+
>
|
|
137
|
+
<BiSolidBell width={ 16 } height={ 16 } />
|
|
138
|
+
</a>
|
|
139
|
+
</Flex>
|
|
140
|
+
|
|
94
141
|
<Toolbar.Separator />
|
|
95
142
|
|
|
96
143
|
<a href="/">
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/** @jsxImportSource theme-ui */
|
|
2
|
-
|
|
3
2
|
import React, { Ref, forwardRef } from 'react';
|
|
4
3
|
|
|
4
|
+
import { Flex } from '..';
|
|
5
|
+
|
|
5
6
|
export type ToolbarUtilNavProps = {
|
|
6
7
|
children: React.ReactNode;
|
|
7
8
|
label?: string;
|
|
@@ -17,6 +18,7 @@ export const ToolbarUtilNav = forwardRef< HTMLElement, ToolbarUtilNavProps >(
|
|
|
17
18
|
alignItems: 'center',
|
|
18
19
|
flexDirection: 'row',
|
|
19
20
|
display: 'flex',
|
|
21
|
+
gap: 4,
|
|
20
22
|
} }
|
|
21
23
|
>
|
|
22
24
|
{ children }
|
|
@@ -24,10 +26,26 @@ export const ToolbarUtilNav = forwardRef< HTMLElement, ToolbarUtilNavProps >(
|
|
|
24
26
|
)
|
|
25
27
|
);
|
|
26
28
|
|
|
29
|
+
export const ToolbarIconHolder = ( { children } ) => (
|
|
30
|
+
<Flex
|
|
31
|
+
sx={ {
|
|
32
|
+
width: 38,
|
|
33
|
+
height: 38,
|
|
34
|
+
alignItems: 'center',
|
|
35
|
+
justifyContent: 'center',
|
|
36
|
+
color: 'icon.inverse',
|
|
37
|
+
'&:hover': { color: 'icon.primary' },
|
|
38
|
+
} }
|
|
39
|
+
>
|
|
40
|
+
{ children }
|
|
41
|
+
</Flex>
|
|
42
|
+
);
|
|
43
|
+
|
|
27
44
|
export const ToolbarUtilNavSeparator = () => (
|
|
28
45
|
<span
|
|
29
46
|
aria-hidden="true"
|
|
30
47
|
sx={ {
|
|
48
|
+
display: [ 'block', 'none', 'none', 'block', 'block' ],
|
|
31
49
|
'&:after': {
|
|
32
50
|
display: 'block',
|
|
33
51
|
backgroundColor: 'borders.inverse',
|
|
@@ -36,7 +54,6 @@ export const ToolbarUtilNavSeparator = () => (
|
|
|
36
54
|
overflow: 'hidden',
|
|
37
55
|
content: '""',
|
|
38
56
|
},
|
|
39
|
-
mx: 3,
|
|
40
57
|
position: 'relative',
|
|
41
58
|
} }
|
|
42
59
|
></span>
|
|
@@ -3,7 +3,11 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { Logo } from './Logo';
|
|
5
5
|
import { ToolbarPrimary as Primary } from './Toolbar';
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
ToolbarUtilNav as UtilNav,
|
|
8
|
+
ToolbarUtilNavSeparator as Separator,
|
|
9
|
+
ToolbarIconHolder as IconHolder,
|
|
10
|
+
} from './ToolbarUtilNav';
|
|
7
11
|
|
|
8
12
|
export const VIP_TOOLBAR = 'vip-toolbar-component';
|
|
9
13
|
|
|
@@ -12,4 +16,5 @@ export const Toolbar = {
|
|
|
12
16
|
Primary,
|
|
13
17
|
Separator,
|
|
14
18
|
UtilNav,
|
|
19
|
+
IconHolder,
|
|
15
20
|
};
|
package/src/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,
|
|
@@ -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',
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
/** @jsxImportSource theme-ui */
|
|
2
|
-
/**
|
|
3
|
-
* External dependencies
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Internal dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { Toggle, Label } from '..';
|
|
10
|
-
|
|
11
|
-
export default {
|
|
12
|
-
title: 'Toggle',
|
|
13
|
-
component: Toggle,
|
|
14
|
-
argTypes: {
|
|
15
|
-
checked: {
|
|
16
|
-
options: [ true, false ],
|
|
17
|
-
default: true,
|
|
18
|
-
control: { type: 'radio' },
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const Default = args => (
|
|
24
|
-
<form>
|
|
25
|
-
<Toggle
|
|
26
|
-
checked={ args.checked }
|
|
27
|
-
defaultChecked
|
|
28
|
-
color={ args.color }
|
|
29
|
-
aria-label="Feature flag"
|
|
30
|
-
/>
|
|
31
|
-
|
|
32
|
-
<br />
|
|
33
|
-
<br />
|
|
34
|
-
|
|
35
|
-
<Toggle checked={ args.checked } defaultChecked={ false } aria-label="Feature flag 2" />
|
|
36
|
-
|
|
37
|
-
<br />
|
|
38
|
-
<br />
|
|
39
|
-
|
|
40
|
-
<Toggle aria-label="Feature Disabled" disabled defaultChecked={ false } />
|
|
41
|
-
</form>
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
const WithLabel = args => (
|
|
45
|
-
<form>
|
|
46
|
-
<Label htmlFor="custom-label-input">Custom Label here</Label>
|
|
47
|
-
|
|
48
|
-
<Toggle
|
|
49
|
-
id="custom-label-input"
|
|
50
|
-
defaultChecked
|
|
51
|
-
checked={ args.checked }
|
|
52
|
-
aria-label="Feature flag"
|
|
53
|
-
/>
|
|
54
|
-
</form>
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
const CustomStyling = args => (
|
|
58
|
-
<form>
|
|
59
|
-
<Label htmlFor="custom-label-input">Custom Styling</Label>
|
|
60
|
-
|
|
61
|
-
<div>
|
|
62
|
-
<Toggle
|
|
63
|
-
id="custom-label-input"
|
|
64
|
-
defaultChecked
|
|
65
|
-
checked={ args.checked }
|
|
66
|
-
aria-label="Feature flag"
|
|
67
|
-
variant="success"
|
|
68
|
-
/>{ ' ' }
|
|
69
|
-
<Toggle
|
|
70
|
-
id="custom-label-input-error"
|
|
71
|
-
defaultChecked
|
|
72
|
-
checked={ args.checked }
|
|
73
|
-
aria-label="Error flag"
|
|
74
|
-
variant="error"
|
|
75
|
-
/>{ ' ' }
|
|
76
|
-
<Toggle
|
|
77
|
-
id="custom-label-input-warning"
|
|
78
|
-
defaultChecked
|
|
79
|
-
checked={ args.checked }
|
|
80
|
-
aria-label="Warning flag"
|
|
81
|
-
variant="warning"
|
|
82
|
-
/>{ ' ' }
|
|
83
|
-
<Toggle
|
|
84
|
-
id="custom-label-input-info"
|
|
85
|
-
defaultChecked
|
|
86
|
-
checked={ args.checked }
|
|
87
|
-
aria-label="info flag"
|
|
88
|
-
variant="info"
|
|
89
|
-
/>
|
|
90
|
-
</div>
|
|
91
|
-
</form>
|
|
92
|
-
);
|
|
93
|
-
|
|
94
|
-
export const Primary = Default.bind( { checked: true } );
|
|
95
|
-
export const ExternalLabel = WithLabel.bind( { checked: true } );
|
|
96
|
-
export const CustomStyle = CustomStyling.bind( { checked: true } );
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
/* eslint-disable max-len */
|
|
2
|
-
/** @jsxImportSource theme-ui */
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* External dependencies
|
|
6
|
-
*/
|
|
7
|
-
import * as Switch from '@radix-ui/react-switch';
|
|
8
|
-
import classNames from 'classnames';
|
|
9
|
-
import PropTypes from 'prop-types';
|
|
10
|
-
import React from 'react';
|
|
11
|
-
|
|
12
|
-
// Documentation for Radix Switch component
|
|
13
|
-
// https://www.radix-ui.com/docs/primitives/components/switch
|
|
14
|
-
|
|
15
|
-
export const Toggle = React.forwardRef(
|
|
16
|
-
( { name = 'toggle', onChange, className = null, variant = 'primary', ...rest }, forwardRef ) => (
|
|
17
|
-
<Switch.Root
|
|
18
|
-
className={ classNames( 'vip-toggle-component', className ) }
|
|
19
|
-
sx={ {
|
|
20
|
-
all: 'unset',
|
|
21
|
-
cursor: 'pointer',
|
|
22
|
-
position: 'relative',
|
|
23
|
-
width: 40,
|
|
24
|
-
height: 20,
|
|
25
|
-
borderRadius: 5,
|
|
26
|
-
backgroundColor: 'muted',
|
|
27
|
-
backgroundRepeat: 'no-repeat',
|
|
28
|
-
backgroundPosition: 'right 2px top 2px',
|
|
29
|
-
backgroundImage: `url(
|
|
30
|
-
'data:image/svg+xml;utf8,<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M4.53846 3L3 4.53846L6.46156 8.00001L3.00003 11.4615L4.53848 13L8.00001 9.53847L11.4615 13L13 11.4615L9.53847 8.00001L13 4.53849L11.4615 3.00003L8.00001 6.46156L4.53846 3Z" fill="white"/></svg>')`,
|
|
31
|
-
WebkitTapHighlightColor: 'rgba(0, 0, 0, 0)',
|
|
32
|
-
|
|
33
|
-
'&:focus-visible': theme => theme.outline,
|
|
34
|
-
'&[disabled]': {
|
|
35
|
-
opacity: 0.7,
|
|
36
|
-
},
|
|
37
|
-
'&[data-state="checked"]': {
|
|
38
|
-
backgroundColor: variant,
|
|
39
|
-
backgroundPosition: 'left 2px top 2px',
|
|
40
|
-
backgroundImage: `url(
|
|
41
|
-
'data:image/svg+xml;utf8,<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M13.4999 4.9995L5.7254 12.4008L2.5 9.33023L3.83307 7.92994L5.7254 9.73144L12.1668 3.59921L13.4999 4.9995Z" fill="white"/></svg>')`,
|
|
42
|
-
},
|
|
43
|
-
} }
|
|
44
|
-
name={ name }
|
|
45
|
-
onCheckedChange={ onChange || undefined }
|
|
46
|
-
ref={ forwardRef }
|
|
47
|
-
{ ...rest }
|
|
48
|
-
>
|
|
49
|
-
<Switch.Thumb
|
|
50
|
-
sx={ {
|
|
51
|
-
display: 'block',
|
|
52
|
-
width: 16,
|
|
53
|
-
height: 16,
|
|
54
|
-
backgroundColor: 'white',
|
|
55
|
-
borderRadius: '100%',
|
|
56
|
-
boxShadow: 'rgb(0 0 0 / 5%) 0px 1px 5px, rgb(0 0 0 / 15%) 0px 1px 1px',
|
|
57
|
-
transition: 'transform 100ms',
|
|
58
|
-
transform: 'translateX(2px)',
|
|
59
|
-
willChange: 'transform',
|
|
60
|
-
'&[data-state="checked"]': { transform: 'translateX(22px)' },
|
|
61
|
-
} }
|
|
62
|
-
/>
|
|
63
|
-
</Switch.Root>
|
|
64
|
-
)
|
|
65
|
-
);
|
|
66
|
-
|
|
67
|
-
Toggle.displayName = 'Toggle';
|
|
68
|
-
|
|
69
|
-
Toggle.propTypes = {
|
|
70
|
-
name: PropTypes.string,
|
|
71
|
-
className: PropTypes.any,
|
|
72
|
-
onChange: PropTypes.func,
|
|
73
|
-
variant: PropTypes.string,
|
|
74
|
-
};
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
/** @jsxImportSource theme-ui */
|
|
2
|
-
/**
|
|
3
|
-
* External dependencies
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Internal dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { Toggle, Label } from '..';
|
|
10
|
-
|
|
11
|
-
export default {
|
|
12
|
-
title: 'Toggle',
|
|
13
|
-
component: Toggle,
|
|
14
|
-
argTypes: {
|
|
15
|
-
checked: {
|
|
16
|
-
options: [ true, false ],
|
|
17
|
-
default: true,
|
|
18
|
-
control: { type: 'radio' },
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const Default = args => (
|
|
24
|
-
<form>
|
|
25
|
-
<Toggle
|
|
26
|
-
checked={ args.checked }
|
|
27
|
-
defaultChecked
|
|
28
|
-
color={ args.color }
|
|
29
|
-
aria-label="Feature flag"
|
|
30
|
-
/>
|
|
31
|
-
|
|
32
|
-
<br />
|
|
33
|
-
<br />
|
|
34
|
-
|
|
35
|
-
<Toggle checked={ args.checked } defaultChecked={ false } aria-label="Feature flag 2" />
|
|
36
|
-
|
|
37
|
-
<br />
|
|
38
|
-
<br />
|
|
39
|
-
|
|
40
|
-
<Toggle aria-label="Feature Disabled" disabled defaultChecked={ false } />
|
|
41
|
-
</form>
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
const WithLabel = args => (
|
|
45
|
-
<form>
|
|
46
|
-
<Label htmlFor="custom-label-input">Custom Label here</Label>
|
|
47
|
-
|
|
48
|
-
<Toggle
|
|
49
|
-
id="custom-label-input"
|
|
50
|
-
defaultChecked
|
|
51
|
-
checked={ args.checked }
|
|
52
|
-
aria-label="Feature flag"
|
|
53
|
-
/>
|
|
54
|
-
</form>
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
const CustomStyling = args => (
|
|
58
|
-
<form>
|
|
59
|
-
<Label htmlFor="custom-label-input">Custom Styling</Label>
|
|
60
|
-
|
|
61
|
-
<div>
|
|
62
|
-
<Toggle
|
|
63
|
-
id="custom-label-input"
|
|
64
|
-
defaultChecked
|
|
65
|
-
checked={ args.checked }
|
|
66
|
-
aria-label="Feature flag"
|
|
67
|
-
variant="success"
|
|
68
|
-
/>{ ' ' }
|
|
69
|
-
<Toggle
|
|
70
|
-
id="custom-label-input-error"
|
|
71
|
-
defaultChecked
|
|
72
|
-
checked={ args.checked }
|
|
73
|
-
aria-label="Error flag"
|
|
74
|
-
variant="error"
|
|
75
|
-
/>{ ' ' }
|
|
76
|
-
<Toggle
|
|
77
|
-
id="custom-label-input-warning"
|
|
78
|
-
defaultChecked
|
|
79
|
-
checked={ args.checked }
|
|
80
|
-
aria-label="Warning flag"
|
|
81
|
-
variant="warning"
|
|
82
|
-
/>{ ' ' }
|
|
83
|
-
<Toggle
|
|
84
|
-
id="custom-label-input-info"
|
|
85
|
-
defaultChecked
|
|
86
|
-
checked={ args.checked }
|
|
87
|
-
aria-label="info flag"
|
|
88
|
-
variant="info"
|
|
89
|
-
/>
|
|
90
|
-
</div>
|
|
91
|
-
</form>
|
|
92
|
-
);
|
|
93
|
-
|
|
94
|
-
export const Primary = Default.bind( { checked: true } );
|
|
95
|
-
export const ExternalLabel = WithLabel.bind( { checked: true } );
|
|
96
|
-
export const CustomStyle = CustomStyling.bind( { checked: true } );
|