@automattic/vip-design-system 0.11.1 → 0.14.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/.storybook/decorators/withBoundingBox.jsx +11 -4
- package/.storybook/decorators/withColorMode.jsx +6 -6
- package/.storybook/decorators/withThemeProvider.jsx +4 -6
- package/.storybook/main.js +1 -0
- package/.storybook/preview.js +1 -0
- package/build/system/Button/Button.js +7 -1
- package/build/system/Form/Toggle.js +62 -72
- package/build/system/Form/Toggle.stories.js +107 -0
- package/build/system/Form/Toggle.test.js +55 -0
- package/build/system/Link/Link.js +6 -0
- package/build/system/NewDialog/DialogClose.js +76 -0
- package/build/system/NewDialog/DialogClose.test.js +67 -0
- package/build/system/NewDialog/DialogContent.js +26 -0
- package/build/system/NewDialog/DialogDescription.js +54 -0
- package/build/system/NewDialog/DialogDescription.test.js +95 -0
- package/build/system/NewDialog/DialogOverlay.js +48 -0
- package/build/system/NewDialog/DialogOverlay.test.js +63 -0
- package/build/system/NewDialog/DialogTitle.js +50 -0
- package/build/system/NewDialog/DialogTitle.test.js +95 -0
- package/build/system/NewDialog/NewDialog.js +117 -0
- package/build/system/NewDialog/NewDialog.stories.js +159 -0
- package/build/system/NewDialog/index.js +7 -0
- package/build/system/Notice/Notice.js +4 -4
- package/build/system/index.js +4 -0
- package/build/system/theme/getColor.js +43 -0
- package/build/system/theme/index.js +11 -2
- package/package.json +8 -4
- package/src/system/Button/Button.js +3 -1
- package/src/system/Form/Toggle.js +59 -62
- package/src/system/Form/Toggle.stories.jsx +89 -0
- package/src/system/Form/Toggle.test.js +23 -0
- package/src/system/Link/Link.js +2 -0
- package/src/system/NewDialog/DialogClose.js +46 -0
- package/src/system/NewDialog/DialogClose.test.js +32 -0
- package/src/system/NewDialog/DialogContent.js +17 -0
- package/src/system/NewDialog/DialogDescription.js +36 -0
- package/src/system/NewDialog/DialogDescription.test.js +47 -0
- package/src/system/NewDialog/DialogOverlay.js +31 -0
- package/src/system/NewDialog/DialogOverlay.test.js +27 -0
- package/src/system/NewDialog/DialogTitle.js +27 -0
- package/src/system/NewDialog/DialogTitle.test.js +47 -0
- package/src/system/NewDialog/NewDialog.js +87 -0
- package/src/system/NewDialog/NewDialog.stories.jsx +96 -0
- package/src/system/NewDialog/index.js +7 -0
- package/src/system/Notice/Notice.js +3 -3
- package/src/system/index.js +3 -0
- package/src/system/theme/getColor.js +29 -0
- package/src/system/theme/index.js +11 -2
- package/tokens/valet-color.json +6163 -1918
- package/build/system/Form/MultiSelect.js +0 -38
- package/build/system/UsageChart/UsageChart.js +0 -60
- package/build/system/UsageChart/index.js +0 -7
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { makeDecorator } from '@storybook/addons';
|
|
3
|
-
import { Box } from
|
|
3
|
+
import { Box, Heading } from '../../src/system';
|
|
4
4
|
|
|
5
5
|
export default makeDecorator( {
|
|
6
6
|
name: 'withBoundingBox',
|
|
7
7
|
parameterName: 'colorMode2',
|
|
8
8
|
wrapper: ( storyFn, context ) => {
|
|
9
9
|
return (
|
|
10
|
-
<Box sx={{ p:
|
|
11
|
-
{
|
|
10
|
+
<Box sx={ { p: 3, height: '100vh' } }>
|
|
11
|
+
<Box sx={ { backgroundColor: 'backgroundMuted', p: 3, borderRadius: 2 } }>
|
|
12
|
+
<Heading variant="h1" sx={ { mb: 1 } }>
|
|
13
|
+
{ context.title }
|
|
14
|
+
</Heading>
|
|
15
|
+
<Heading variant="h2">{ context.name }</Heading>
|
|
16
|
+
</Box>
|
|
17
|
+
|
|
18
|
+
<Box sx={ { py: 3 } }>{ storyFn() }</Box>
|
|
12
19
|
</Box>
|
|
13
20
|
);
|
|
14
|
-
}
|
|
21
|
+
},
|
|
15
22
|
} );
|
|
@@ -4,7 +4,7 @@ import { useColorMode } from 'theme-ui';
|
|
|
4
4
|
|
|
5
5
|
// These need to be updated to import VIP design tokens;
|
|
6
6
|
const lightBackground = '#ffffff';
|
|
7
|
-
const darkBackground = '#
|
|
7
|
+
const darkBackground = '#1C1C1B';
|
|
8
8
|
|
|
9
9
|
export const backgrounds = {
|
|
10
10
|
default: 'Light',
|
|
@@ -21,7 +21,7 @@ export const backgrounds = {
|
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
function ThemeChanger( { background } ) {
|
|
24
|
-
const [colorMode, setColorMode] = useColorMode();
|
|
24
|
+
const [ colorMode, setColorMode ] = useColorMode();
|
|
25
25
|
const newColorMode = darkBackground === background ? 'dark' : 'default';
|
|
26
26
|
|
|
27
27
|
useEffect( () => {
|
|
@@ -29,7 +29,7 @@ function ThemeChanger( { background } ) {
|
|
|
29
29
|
}, [ newColorMode ] );
|
|
30
30
|
|
|
31
31
|
return null;
|
|
32
|
-
}
|
|
32
|
+
}
|
|
33
33
|
|
|
34
34
|
export default makeDecorator( {
|
|
35
35
|
name: 'withColorMode',
|
|
@@ -37,9 +37,9 @@ export default makeDecorator( {
|
|
|
37
37
|
wrapper: ( storyFn, context ) => {
|
|
38
38
|
return (
|
|
39
39
|
<>
|
|
40
|
-
<ThemeChanger background={context.globals?.backgrounds?.value} />
|
|
41
|
-
{storyFn()}
|
|
40
|
+
<ThemeChanger background={ context.globals?.backgrounds?.value } />
|
|
41
|
+
{ storyFn() }
|
|
42
42
|
</>
|
|
43
43
|
);
|
|
44
|
-
}
|
|
44
|
+
},
|
|
45
45
|
} );
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { makeDecorator } from '@storybook/addons';
|
|
3
3
|
import { ThemeProvider } from 'theme-ui';
|
|
4
|
-
import { Box, theme } from
|
|
4
|
+
import { Box, theme } from '../../src/system';
|
|
5
5
|
|
|
6
6
|
export default makeDecorator( {
|
|
7
7
|
name: 'withThemeProvider',
|
|
8
8
|
parameterName: 'themeUi',
|
|
9
9
|
wrapper: ( storyFn, context ) => {
|
|
10
10
|
return (
|
|
11
|
-
<ThemeProvider theme={theme}>
|
|
12
|
-
<Box sx={{
|
|
13
|
-
{storyFn( context )}
|
|
14
|
-
</Box>
|
|
11
|
+
<ThemeProvider theme={ theme }>
|
|
12
|
+
<Box sx={ { height: '100vh' } }>{ storyFn( context ) }</Box>
|
|
15
13
|
</ThemeProvider>
|
|
16
14
|
);
|
|
17
|
-
}
|
|
15
|
+
},
|
|
18
16
|
} );
|
package/.storybook/main.js
CHANGED
package/.storybook/preview.js
CHANGED
|
@@ -30,8 +30,14 @@ var Button = function Button(_ref) {
|
|
|
30
30
|
justifyContent: 'center',
|
|
31
31
|
height: '36px',
|
|
32
32
|
py: 0,
|
|
33
|
+
'&:focus': function focus(theme) {
|
|
34
|
+
return theme.outline;
|
|
35
|
+
},
|
|
36
|
+
'&:focus-visible': function focusVisible(theme) {
|
|
37
|
+
return theme.outline;
|
|
38
|
+
},
|
|
33
39
|
'&:disabled': {
|
|
34
|
-
opacity: 0.
|
|
40
|
+
opacity: 0.7,
|
|
35
41
|
cursor: 'not-allowed',
|
|
36
42
|
pointerEvents: 'all'
|
|
37
43
|
}
|
|
@@ -13,91 +13,81 @@ var _classnames = _interopRequireDefault(require("classnames"));
|
|
|
13
13
|
|
|
14
14
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
15
15
|
|
|
16
|
+
var Switch = _interopRequireWildcard(require("@radix-ui/react-switch"));
|
|
17
|
+
|
|
16
18
|
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
17
19
|
|
|
18
|
-
var _excluded = ["name", "className"];
|
|
20
|
+
var _excluded = ["name", "onChange", "className", "variant"];
|
|
21
|
+
|
|
22
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
23
|
+
|
|
24
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
25
|
|
|
26
|
+
// Documentation for Radix Switch component
|
|
27
|
+
// https://www.radix-ui.com/docs/primitives/components/switch
|
|
20
28
|
var Toggle = function Toggle(_ref) {
|
|
21
29
|
var _ref$name = _ref.name,
|
|
22
30
|
name = _ref$name === void 0 ? 'toggle' : _ref$name,
|
|
31
|
+
onChange = _ref.onChange,
|
|
23
32
|
_ref$className = _ref.className,
|
|
24
33
|
className = _ref$className === void 0 ? null : _ref$className,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
id: name,
|
|
31
|
-
type: "checkbox"
|
|
32
|
-
}, props)), (0, _jsxRuntime.jsx)(CheckBoxLabel, {
|
|
33
|
-
htmlFor: name
|
|
34
|
-
})]
|
|
35
|
-
});
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
exports.Toggle = Toggle;
|
|
39
|
-
Toggle.propTypes = {
|
|
40
|
-
name: _propTypes["default"].string,
|
|
41
|
-
className: _propTypes["default"].any
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
var CheckBoxWrapper = function CheckBoxWrapper(props) {
|
|
45
|
-
return (0, _jsxRuntime.jsx)("div", (0, _extends2["default"])({
|
|
34
|
+
_ref$variant = _ref.variant,
|
|
35
|
+
variant = _ref$variant === void 0 ? 'primary' : _ref$variant,
|
|
36
|
+
rest = (0, _objectWithoutPropertiesLoose2["default"])(_ref, _excluded);
|
|
37
|
+
return (0, _jsxRuntime.jsx)(Switch.Root, (0, _extends2["default"])({
|
|
38
|
+
className: (0, _classnames["default"])('vip-toggle-component', className),
|
|
46
39
|
sx: {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
var CheckBoxLabel = function CheckBoxLabel(props) {
|
|
53
|
-
return (0, _jsxRuntime.jsx)("label", (0, _extends2["default"])({
|
|
54
|
-
sx: {
|
|
55
|
-
position: 'absolute',
|
|
56
|
-
top: '0',
|
|
57
|
-
left: '0',
|
|
58
|
-
width: '42px',
|
|
59
|
-
height: '24px',
|
|
60
|
-
borderRadius: '15px',
|
|
40
|
+
all: 'unset',
|
|
41
|
+
position: 'relative',
|
|
42
|
+
width: 40,
|
|
43
|
+
height: 20,
|
|
44
|
+
borderRadius: '32px',
|
|
61
45
|
backgroundColor: 'muted',
|
|
62
|
-
|
|
63
|
-
'
|
|
64
|
-
|
|
46
|
+
backgroundRepeat: 'no-repeat',
|
|
47
|
+
backgroundPosition: 'right 2px top 2px',
|
|
48
|
+
backgroundImage: "url(\n\t\t\t\t'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>')",
|
|
49
|
+
WebkitTapHighlightColor: 'rgba(0, 0, 0, 0)',
|
|
50
|
+
'&:focus': function focus(theme) {
|
|
51
|
+
return theme.outline;
|
|
52
|
+
},
|
|
53
|
+
'&:focus-visible': function focusVisible(theme) {
|
|
54
|
+
return theme.outline;
|
|
55
|
+
},
|
|
56
|
+
'&[disabled]': {
|
|
57
|
+
opacity: 0.7
|
|
58
|
+
},
|
|
59
|
+
'&[data-state="checked"]': {
|
|
60
|
+
backgroundColor: variant,
|
|
61
|
+
backgroundPosition: 'left 2px top 2px',
|
|
62
|
+
backgroundImage: "url(\n\t\t\t\t\t'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>')"
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
name: name,
|
|
66
|
+
onCheckedChange: onChange || undefined
|
|
67
|
+
}, rest, {
|
|
68
|
+
children: (0, _jsxRuntime.jsx)(Switch.Thumb, {
|
|
69
|
+
sx: {
|
|
65
70
|
display: 'block',
|
|
71
|
+
width: 16,
|
|
72
|
+
height: 16,
|
|
73
|
+
backgroundColor: 'white',
|
|
66
74
|
borderRadius: '50%',
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
75
|
+
boxShadow: 'rgb(0 0 0 / 5%) 0px 1px 5px, rgb(0 0 0 / 15%) 0px 1px 1px',
|
|
76
|
+
transition: 'transform 100ms',
|
|
77
|
+
transform: 'translateX(2px)',
|
|
78
|
+
willChange: 'transform',
|
|
79
|
+
'&[data-state="checked"]': {
|
|
80
|
+
transform: 'translateX(22px)'
|
|
81
|
+
}
|
|
73
82
|
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
83
|
+
})
|
|
84
|
+
}));
|
|
76
85
|
};
|
|
77
86
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
width: '42px',
|
|
85
|
-
height: '24px',
|
|
86
|
-
padding: 0,
|
|
87
|
-
margin: 0,
|
|
88
|
-
display: 'block',
|
|
89
|
-
'&:checked + label': {
|
|
90
|
-
backgroundColor: 'success',
|
|
91
|
-
'&::after': {
|
|
92
|
-
content: "''",
|
|
93
|
-
display: 'block',
|
|
94
|
-
borderRadius: '50%',
|
|
95
|
-
width: '18px',
|
|
96
|
-
height: '18px',
|
|
97
|
-
marginLeft: '21px',
|
|
98
|
-
transition: '0.2s'
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}, props));
|
|
87
|
+
exports.Toggle = Toggle;
|
|
88
|
+
Toggle.propTypes = {
|
|
89
|
+
name: _propTypes["default"].string,
|
|
90
|
+
className: _propTypes["default"].any,
|
|
91
|
+
onChange: _propTypes["default"].func,
|
|
92
|
+
variant: _propTypes["default"].string
|
|
103
93
|
};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports["default"] = exports.Primary = exports.ExternalLabel = exports.CustomStyle = void 0;
|
|
5
|
+
|
|
6
|
+
var _ = require("..");
|
|
7
|
+
|
|
8
|
+
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
9
|
+
|
|
10
|
+
/** @jsxImportSource theme-ui */
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* External dependencies
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Internal dependencies
|
|
18
|
+
*/
|
|
19
|
+
var _default = {
|
|
20
|
+
title: 'Toggle',
|
|
21
|
+
component: _.Toggle,
|
|
22
|
+
argTypes: {
|
|
23
|
+
checked: {
|
|
24
|
+
options: [true, false],
|
|
25
|
+
"default": true,
|
|
26
|
+
control: {
|
|
27
|
+
type: 'radio'
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
exports["default"] = _default;
|
|
33
|
+
|
|
34
|
+
var Default = function Default(args) {
|
|
35
|
+
return (0, _jsxRuntime.jsxs)("form", {
|
|
36
|
+
children: [(0, _jsxRuntime.jsx)(_.Toggle, {
|
|
37
|
+
checked: args.checked,
|
|
38
|
+
defaultChecked: true,
|
|
39
|
+
color: args.color,
|
|
40
|
+
"aria-label": "Feature flag"
|
|
41
|
+
}), (0, _jsxRuntime.jsx)("br", {}), (0, _jsxRuntime.jsx)("br", {}), (0, _jsxRuntime.jsx)(_.Toggle, {
|
|
42
|
+
checked: args.checked,
|
|
43
|
+
defaultChecked: false,
|
|
44
|
+
"aria-label": "Feature flag 2"
|
|
45
|
+
}), (0, _jsxRuntime.jsx)("br", {}), (0, _jsxRuntime.jsx)("br", {}), (0, _jsxRuntime.jsx)(_.Toggle, {
|
|
46
|
+
"aria-label": "Feature Disabled",
|
|
47
|
+
disabled: true,
|
|
48
|
+
defaultChecked: false
|
|
49
|
+
})]
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
var WithLabel = function WithLabel(args) {
|
|
54
|
+
return (0, _jsxRuntime.jsxs)("form", {
|
|
55
|
+
children: [(0, _jsxRuntime.jsx)(_.Label, {
|
|
56
|
+
htmlFor: "custom-label-input",
|
|
57
|
+
children: "Custom Label here"
|
|
58
|
+
}), (0, _jsxRuntime.jsx)(_.Toggle, {
|
|
59
|
+
id: "custom-label-input",
|
|
60
|
+
defaultChecked: true,
|
|
61
|
+
checked: args.checked,
|
|
62
|
+
"aria-label": "Feature flag"
|
|
63
|
+
})]
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
var CustomStyling = function CustomStyling(args) {
|
|
68
|
+
return (0, _jsxRuntime.jsxs)("form", {
|
|
69
|
+
children: [(0, _jsxRuntime.jsx)(_.Label, {
|
|
70
|
+
htmlFor: "custom-label-input",
|
|
71
|
+
children: "Custom Styling"
|
|
72
|
+
}), (0, _jsxRuntime.jsxs)("div", {
|
|
73
|
+
children: [(0, _jsxRuntime.jsx)(_.Toggle, {
|
|
74
|
+
id: "custom-label-input",
|
|
75
|
+
defaultChecked: true,
|
|
76
|
+
checked: args.checked,
|
|
77
|
+
"aria-label": "Feature flag",
|
|
78
|
+
variant: "success"
|
|
79
|
+
}), ' ', (0, _jsxRuntime.jsx)(_.Toggle, {
|
|
80
|
+
id: "custom-label-input-error",
|
|
81
|
+
defaultChecked: true,
|
|
82
|
+
checked: args.checked,
|
|
83
|
+
"aria-label": "Error flag",
|
|
84
|
+
variant: "error"
|
|
85
|
+
}), ' ', (0, _jsxRuntime.jsx)(_.Toggle, {
|
|
86
|
+
id: "custom-label-input-warning",
|
|
87
|
+
defaultChecked: true,
|
|
88
|
+
checked: args.checked,
|
|
89
|
+
"aria-label": "Warning flag",
|
|
90
|
+
variant: "warning"
|
|
91
|
+
})]
|
|
92
|
+
})]
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
var Primary = Default.bind({
|
|
97
|
+
checked: true
|
|
98
|
+
});
|
|
99
|
+
exports.Primary = Primary;
|
|
100
|
+
var ExternalLabel = WithLabel.bind({
|
|
101
|
+
checked: true
|
|
102
|
+
});
|
|
103
|
+
exports.ExternalLabel = ExternalLabel;
|
|
104
|
+
var CustomStyle = CustomStyling.bind({
|
|
105
|
+
checked: true
|
|
106
|
+
});
|
|
107
|
+
exports.CustomStyle = CustomStyle;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
6
|
+
|
|
7
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
8
|
+
|
|
9
|
+
var _react = require("@testing-library/react");
|
|
10
|
+
|
|
11
|
+
var _jestAxe = require("jest-axe");
|
|
12
|
+
|
|
13
|
+
var _Toggle = require("./Toggle");
|
|
14
|
+
|
|
15
|
+
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* External dependencies
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Internal dependencies
|
|
23
|
+
*/
|
|
24
|
+
describe('<Toggle />', function () {
|
|
25
|
+
it('renders the Toggle component', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
26
|
+
var _render, container;
|
|
27
|
+
|
|
28
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
29
|
+
while (1) {
|
|
30
|
+
switch (_context.prev = _context.next) {
|
|
31
|
+
case 0:
|
|
32
|
+
_render = (0, _react.render)((0, _jsxRuntime.jsx)(_Toggle.Toggle, {
|
|
33
|
+
"aria-label": "Dinner room Light",
|
|
34
|
+
defaultChecked: true,
|
|
35
|
+
name: "my-toggle"
|
|
36
|
+
})), container = _render.container;
|
|
37
|
+
expect(_react.screen.getByRole('switch')).toBeInTheDocument(); // Check for accessibility issues
|
|
38
|
+
|
|
39
|
+
_context.t0 = expect;
|
|
40
|
+
_context.next = 5;
|
|
41
|
+
return (0, _jestAxe.axe)(container);
|
|
42
|
+
|
|
43
|
+
case 5:
|
|
44
|
+
_context.t1 = _context.sent;
|
|
45
|
+
_context.next = 8;
|
|
46
|
+
return (0, _context.t0)(_context.t1).toHaveNoViolations();
|
|
47
|
+
|
|
48
|
+
case 8:
|
|
49
|
+
case "end":
|
|
50
|
+
return _context.stop();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}, _callee);
|
|
54
|
+
})));
|
|
55
|
+
});
|
|
@@ -33,6 +33,12 @@ var Link = function Link(_ref) {
|
|
|
33
33
|
},
|
|
34
34
|
'&:hover, &:focus': {
|
|
35
35
|
color: 'heading'
|
|
36
|
+
},
|
|
37
|
+
'&:focus': function focus(theme) {
|
|
38
|
+
return theme.outline;
|
|
39
|
+
},
|
|
40
|
+
'&:focus-visible': function focusVisible(theme) {
|
|
41
|
+
return theme.outline;
|
|
36
42
|
}
|
|
37
43
|
}, sx)
|
|
38
44
|
}));
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
exports.__esModule = true;
|
|
6
|
+
exports.DialogClose = void 0;
|
|
7
|
+
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
|
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
|
11
|
+
|
|
12
|
+
var DialogPrimitive = _interopRequireWildcard(require("@radix-ui/react-dialog"));
|
|
13
|
+
|
|
14
|
+
var _io = require("react-icons/io5");
|
|
15
|
+
|
|
16
|
+
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
17
|
+
|
|
18
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
19
|
+
|
|
20
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
21
|
+
|
|
22
|
+
/** @jsxImportSource theme-ui */
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* External dependencies
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Internal dependencies
|
|
30
|
+
*/
|
|
31
|
+
var DialogClose = /*#__PURE__*/_react["default"].forwardRef(function (props, forwardedRef) {
|
|
32
|
+
return (0, _jsxRuntime.jsx)(DialogPrimitive.Close, (0, _extends2["default"])({
|
|
33
|
+
asChild: true
|
|
34
|
+
}, props, {
|
|
35
|
+
ref: forwardedRef,
|
|
36
|
+
children: (0, _jsxRuntime.jsx)("button", {
|
|
37
|
+
"aria-label": "Close",
|
|
38
|
+
sx: {
|
|
39
|
+
all: 'unset',
|
|
40
|
+
fontFamily: 'inherit',
|
|
41
|
+
borderRadius: '100%',
|
|
42
|
+
height: 25,
|
|
43
|
+
width: 25,
|
|
44
|
+
display: 'inline-flex',
|
|
45
|
+
alignItems: 'center',
|
|
46
|
+
justifyContent: 'center',
|
|
47
|
+
color: function color(theme) {
|
|
48
|
+
var _theme$colors;
|
|
49
|
+
|
|
50
|
+
return "" + (theme == null ? void 0 : (_theme$colors = theme.colors) == null ? void 0 : _theme$colors.text);
|
|
51
|
+
},
|
|
52
|
+
position: 'absolute',
|
|
53
|
+
top: 10,
|
|
54
|
+
right: 10,
|
|
55
|
+
'&:hover': {
|
|
56
|
+
backgroundColor: 'border',
|
|
57
|
+
outlineStyle: 'solid',
|
|
58
|
+
outlineColor: 'primary',
|
|
59
|
+
outlineWidth: '2px'
|
|
60
|
+
},
|
|
61
|
+
'&:focus': function focus(theme) {
|
|
62
|
+
return theme.outline;
|
|
63
|
+
},
|
|
64
|
+
'&:focus-visible': function focusVisible(theme) {
|
|
65
|
+
return theme.outline;
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
children: (0, _jsxRuntime.jsx)(_io.IoClose, {
|
|
69
|
+
"aria-hidden": "true"
|
|
70
|
+
})
|
|
71
|
+
})
|
|
72
|
+
}));
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
exports.DialogClose = DialogClose;
|
|
76
|
+
DialogClose.displayName = 'DialogClose';
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
6
|
+
|
|
7
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
8
|
+
|
|
9
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
|
+
|
|
11
|
+
var _reactDialog = require("@radix-ui/react-dialog");
|
|
12
|
+
|
|
13
|
+
var _react = require("@testing-library/react");
|
|
14
|
+
|
|
15
|
+
var _jestAxe = require("jest-axe");
|
|
16
|
+
|
|
17
|
+
var _DialogClose = require("./DialogClose");
|
|
18
|
+
|
|
19
|
+
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* External dependencies
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Internal dependencies
|
|
27
|
+
*/
|
|
28
|
+
// If you render any Dialog child without the `<Dialog />` parent, it will throw an error.
|
|
29
|
+
var Wrapper = function Wrapper(props) {
|
|
30
|
+
return (0, _jsxRuntime.jsx)(_reactDialog.Dialog, (0, _extends2["default"])({
|
|
31
|
+
open: true
|
|
32
|
+
}, props));
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
var defaultProps = {
|
|
36
|
+
title: 'This is a DialogClose'
|
|
37
|
+
};
|
|
38
|
+
describe('<DialogClose />', function () {
|
|
39
|
+
it('renders the DialogClose component', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
40
|
+
var _render, container;
|
|
41
|
+
|
|
42
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
43
|
+
while (1) {
|
|
44
|
+
switch (_context.prev = _context.next) {
|
|
45
|
+
case 0:
|
|
46
|
+
_render = (0, _react.render)((0, _jsxRuntime.jsx)(Wrapper, {
|
|
47
|
+
children: (0, _jsxRuntime.jsx)(_DialogClose.DialogClose, (0, _extends2["default"])({}, defaultProps))
|
|
48
|
+
})), container = _render.container;
|
|
49
|
+
expect(_react.screen.getByLabelText('Close')).toBeInTheDocument(); // Check for accessibility issues
|
|
50
|
+
|
|
51
|
+
_context.t0 = expect;
|
|
52
|
+
_context.next = 5;
|
|
53
|
+
return (0, _jestAxe.axe)(container);
|
|
54
|
+
|
|
55
|
+
case 5:
|
|
56
|
+
_context.t1 = _context.sent;
|
|
57
|
+
_context.next = 8;
|
|
58
|
+
return (0, _context.t0)(_context.t1).toHaveNoViolations();
|
|
59
|
+
|
|
60
|
+
case 8:
|
|
61
|
+
case "end":
|
|
62
|
+
return _context.stop();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}, _callee);
|
|
66
|
+
})));
|
|
67
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.contentStyles = void 0;
|
|
5
|
+
|
|
6
|
+
/** @jsxImportSource theme-ui */
|
|
7
|
+
var contentStyles = {
|
|
8
|
+
background: 'white',
|
|
9
|
+
borderRadius: 10,
|
|
10
|
+
boxShadow: 'hsl(206 22% 7% / 35%) 0px 10px 38px -10px, hsl(206 22% 7% / 20%) 0px 10px 20px -15px',
|
|
11
|
+
position: 'fixed',
|
|
12
|
+
top: '50%',
|
|
13
|
+
left: '50%',
|
|
14
|
+
transform: 'translate(-50%, -50%)',
|
|
15
|
+
width: '90vw',
|
|
16
|
+
maxWidth: '640px',
|
|
17
|
+
maxHeight: '85vh',
|
|
18
|
+
padding: 25,
|
|
19
|
+
'&:focus': {
|
|
20
|
+
outline: 'none'
|
|
21
|
+
},
|
|
22
|
+
'> h1, > h2': {
|
|
23
|
+
marginTop: '0 !important'
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
exports.contentStyles = contentStyles;
|