@automattic/vip-design-system 0.11.0 → 0.13.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/withThemeProvider.jsx +4 -6
- package/.storybook/main.js +1 -0
- package/.storybook/preview.js +1 -0
- package/build/system/Form/Toggle.js +53 -72
- package/build/system/Form/Toggle.stories.js +103 -0
- package/build/system/Form/Toggle.test.js +55 -0
- package/build/system/NewDialog/DialogClose.js +75 -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/Table/Table.stories.js +46 -3
- package/build/system/Table/TableCell.js +57 -0
- package/build/system/Table/TableRow.js +12 -57
- package/build/system/Table/index.js +5 -1
- package/build/system/Time/index.js +1 -1
- package/build/system/index.js +5 -0
- package/package.json +8 -4
- package/src/system/Form/Toggle.js +54 -62
- package/src/system/Form/Toggle.stories.jsx +84 -0
- package/src/system/Form/Toggle.test.js +23 -0
- package/src/system/NewDialog/DialogClose.js +45 -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/Table/Table.stories.jsx +29 -1
- package/src/system/Table/TableCell.js +48 -0
- package/src/system/Table/TableRow.js +10 -47
- package/src/system/Table/index.js +2 -1
- package/src/system/Time/index.js +1 -1
- package/src/system/index.js +5 -1
- package/build/system/Form/MultiSelect.js +0 -58
- package/build/system/UsageChart/UsageChart.js +0 -62
- package/build/system/UsageChart/UsageChart.stories.js +0 -20
- package/build/system/UsageChart/index.js +0 -7
|
@@ -23,8 +23,8 @@ var Default = function Default() {
|
|
|
23
23
|
head: true,
|
|
24
24
|
cells: ['User', 'Command', 'Duration', 'Time']
|
|
25
25
|
})
|
|
26
|
-
}), (0, _jsxRuntime.
|
|
27
|
-
children: (0, _jsxRuntime.jsx)(_.TableRow, {
|
|
26
|
+
}), (0, _jsxRuntime.jsxs)("tbody", {
|
|
27
|
+
children: [(0, _jsxRuntime.jsx)(_.TableRow, {
|
|
28
28
|
cells: [(0, _jsxRuntime.jsx)(_.Flex, {
|
|
29
29
|
sx: {
|
|
30
30
|
alignItems: 'center'
|
|
@@ -56,7 +56,50 @@ var Default = function Default() {
|
|
|
56
56
|
},
|
|
57
57
|
children: "11th Mar 2020, 16:49:22"
|
|
58
58
|
}, "time")]
|
|
59
|
-
})
|
|
59
|
+
}), (0, _jsxRuntime.jsxs)(_.TableRow, {
|
|
60
|
+
children: [(0, _jsxRuntime.jsx)(_.TableCell, {
|
|
61
|
+
sx: {
|
|
62
|
+
backgroundColor: 'lightgray'
|
|
63
|
+
},
|
|
64
|
+
children: (0, _jsxRuntime.jsx)(_.Flex, {
|
|
65
|
+
sx: {
|
|
66
|
+
alignItems: 'center'
|
|
67
|
+
},
|
|
68
|
+
children: (0, _jsxRuntime.jsx)(_.Heading, {
|
|
69
|
+
variant: "h4",
|
|
70
|
+
sx: {
|
|
71
|
+
mb: 0
|
|
72
|
+
},
|
|
73
|
+
children: "simon"
|
|
74
|
+
})
|
|
75
|
+
}, "user")
|
|
76
|
+
}), (0, _jsxRuntime.jsx)(_.TableCell, {
|
|
77
|
+
children: (0, _jsxRuntime.jsx)(_.Heading, {
|
|
78
|
+
variant: "h4",
|
|
79
|
+
sx: {
|
|
80
|
+
mb: 0,
|
|
81
|
+
display: 'flex',
|
|
82
|
+
alignItems: 'center'
|
|
83
|
+
},
|
|
84
|
+
children: "wp posts list"
|
|
85
|
+
}, "command")
|
|
86
|
+
}), (0, _jsxRuntime.jsx)(_.TableCell, {
|
|
87
|
+
children: (0, _jsxRuntime.jsx)(_.Text, {
|
|
88
|
+
sx: {
|
|
89
|
+
mb: 0
|
|
90
|
+
},
|
|
91
|
+
children: "3s"
|
|
92
|
+
}, "duration")
|
|
93
|
+
}), (0, _jsxRuntime.jsx)(_.TableCell, {
|
|
94
|
+
children: (0, _jsxRuntime.jsx)(_.Text, {
|
|
95
|
+
sx: {
|
|
96
|
+
mb: 0,
|
|
97
|
+
color: 'muted'
|
|
98
|
+
},
|
|
99
|
+
children: "3rd May 2021, 13:22:13"
|
|
100
|
+
}, "time")
|
|
101
|
+
})]
|
|
102
|
+
})]
|
|
60
103
|
})]
|
|
61
104
|
});
|
|
62
105
|
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
exports.__esModule = true;
|
|
6
|
+
exports.TableCell = void 0;
|
|
7
|
+
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
|
|
10
|
+
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
11
|
+
|
|
12
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
+
|
|
14
|
+
var _ = require("../");
|
|
15
|
+
|
|
16
|
+
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
17
|
+
|
|
18
|
+
var _excluded = ["head", "children"];
|
|
19
|
+
|
|
20
|
+
var TableCell = function TableCell(_ref) {
|
|
21
|
+
var head = _ref.head,
|
|
22
|
+
children = _ref.children,
|
|
23
|
+
rest = (0, _objectWithoutPropertiesLoose2["default"])(_ref, _excluded);
|
|
24
|
+
var sx = (0, _extends2["default"])({
|
|
25
|
+
borderBottom: '1px solid',
|
|
26
|
+
borderTop: head ? '1px solid' : 'none',
|
|
27
|
+
// borderColor should come after borderTop so it can override it
|
|
28
|
+
borderColor: 'border',
|
|
29
|
+
fontWeight: 'body',
|
|
30
|
+
px: 3,
|
|
31
|
+
py: 2,
|
|
32
|
+
textAlign: 'left',
|
|
33
|
+
'&:first-of-type': {
|
|
34
|
+
pl: 5
|
|
35
|
+
}
|
|
36
|
+
}, rest.sx);
|
|
37
|
+
return (0, _jsxRuntime.jsx)(_.Box, (0, _extends2["default"])({
|
|
38
|
+
as: head ? 'th' : 'td'
|
|
39
|
+
}, (0, _extends2["default"])({}, rest, {
|
|
40
|
+
sx: sx
|
|
41
|
+
}), {
|
|
42
|
+
children: head ? (0, _jsxRuntime.jsx)(_.Heading, {
|
|
43
|
+
variant: "caps",
|
|
44
|
+
as: "div",
|
|
45
|
+
sx: {
|
|
46
|
+
mb: 0
|
|
47
|
+
},
|
|
48
|
+
children: children
|
|
49
|
+
}) : children
|
|
50
|
+
}));
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
exports.TableCell = TableCell;
|
|
54
|
+
TableCell.propTypes = {
|
|
55
|
+
children: _propTypes["default"].node,
|
|
56
|
+
head: _propTypes["default"].bool
|
|
57
|
+
};
|
|
@@ -7,7 +7,7 @@ exports.TableRow = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _TableCell = require("./TableCell");
|
|
11
11
|
|
|
12
12
|
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
13
13
|
|
|
@@ -24,9 +24,9 @@ var TableRow = function TableRow(_ref) {
|
|
|
24
24
|
var onClick = _ref.onClick,
|
|
25
25
|
_ref$head = _ref.head,
|
|
26
26
|
head = _ref$head === void 0 ? false : _ref$head,
|
|
27
|
-
_ref$
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
_ref$cells = _ref.cells,
|
|
28
|
+
cells = _ref$cells === void 0 ? [] : _ref$cells,
|
|
29
|
+
children = _ref.children;
|
|
30
30
|
var hoverStyles = onClick ? {
|
|
31
31
|
cursor: 'pointer',
|
|
32
32
|
'&:hover': {
|
|
@@ -41,69 +41,24 @@ var TableRow = function TableRow(_ref) {
|
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
-
return (0, _jsxRuntime.
|
|
44
|
+
return (0, _jsxRuntime.jsxs)("tr", {
|
|
45
45
|
sx: hoverStyles,
|
|
46
46
|
onClick: onClick,
|
|
47
47
|
tabIndex: onClick ? 0 : null,
|
|
48
48
|
onKeyDown: handleKeyPress,
|
|
49
|
-
children: cells.map(function (cell, index) {
|
|
50
|
-
return (0, _jsxRuntime.jsx)(TableCell, {
|
|
51
|
-
cell: cell,
|
|
49
|
+
children: [cells.map(function (cell, index) {
|
|
50
|
+
return (0, _jsxRuntime.jsx)(_TableCell.TableCell, {
|
|
52
51
|
head: head,
|
|
53
|
-
|
|
52
|
+
children: cell
|
|
54
53
|
}, index);
|
|
55
|
-
})
|
|
54
|
+
}), children]
|
|
56
55
|
});
|
|
57
56
|
};
|
|
58
57
|
|
|
59
58
|
exports.TableRow = TableRow;
|
|
60
|
-
|
|
61
|
-
var TableCell = function TableCell(_ref2) {
|
|
62
|
-
var head = _ref2.head,
|
|
63
|
-
isRowHead = _ref2.isRowHead,
|
|
64
|
-
cell = _ref2.cell;
|
|
65
|
-
var scope = null;
|
|
66
|
-
|
|
67
|
-
if (head) {
|
|
68
|
-
scope = 'col';
|
|
69
|
-
} else if (isRowHead) {
|
|
70
|
-
scope = 'row';
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return (0, _jsxRuntime.jsx)(_.Box, {
|
|
74
|
-
as: isRowHead || head ? 'th' : 'td',
|
|
75
|
-
scope: scope,
|
|
76
|
-
sx: {
|
|
77
|
-
px: 3,
|
|
78
|
-
py: 2,
|
|
79
|
-
textAlign: 'left',
|
|
80
|
-
borderBottom: '1px solid',
|
|
81
|
-
fontWeight: 'body',
|
|
82
|
-
borderTop: head ? '1px solid' : 'none',
|
|
83
|
-
borderColor: 'border',
|
|
84
|
-
'&:first-of-type': {
|
|
85
|
-
pl: 5
|
|
86
|
-
}
|
|
87
|
-
},
|
|
88
|
-
children: head ? (0, _jsxRuntime.jsx)(_.Heading, {
|
|
89
|
-
variant: "caps",
|
|
90
|
-
as: "div",
|
|
91
|
-
sx: {
|
|
92
|
-
mb: 0
|
|
93
|
-
},
|
|
94
|
-
children: cell
|
|
95
|
-
}) : cell
|
|
96
|
-
});
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
TableCell.propTypes = {
|
|
100
|
-
head: _propTypes["default"].bool,
|
|
101
|
-
isRowHead: _propTypes["default"].bool,
|
|
102
|
-
cell: _propTypes["default"].node
|
|
103
|
-
};
|
|
104
59
|
TableRow.propTypes = {
|
|
105
|
-
onClick: _propTypes["default"].func,
|
|
106
|
-
head: _propTypes["default"].bool,
|
|
107
60
|
cells: _propTypes["default"].array,
|
|
108
|
-
|
|
61
|
+
children: _propTypes["default"].node,
|
|
62
|
+
head: _propTypes["default"].bool,
|
|
63
|
+
onClick: _propTypes["default"].func
|
|
109
64
|
};
|
|
@@ -88,7 +88,7 @@ var Time = function Time(_ref) {
|
|
|
88
88
|
|
|
89
89
|
exports.Time = Time;
|
|
90
90
|
Time.propTypes = {
|
|
91
|
-
time: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].
|
|
91
|
+
time: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].instanceOf(Date)]),
|
|
92
92
|
timeOnly: _propTypes["default"].bool,
|
|
93
93
|
relativeTime: _propTypes["default"].bool,
|
|
94
94
|
className: _propTypes["default"].any
|
package/build/system/index.js
CHANGED
|
@@ -42,6 +42,10 @@ exports.DialogMenuItem = _Dialog.DialogMenuItem;
|
|
|
42
42
|
exports.DialogTrigger = _Dialog.DialogTrigger;
|
|
43
43
|
exports.DialogContent = _Dialog.DialogContent;
|
|
44
44
|
|
|
45
|
+
var _NewDialog = require("./NewDialog");
|
|
46
|
+
|
|
47
|
+
exports.NewDialog = _NewDialog.NewDialog;
|
|
48
|
+
|
|
45
49
|
var _ConfirmationDialog = require("./ConfirmationDialog");
|
|
46
50
|
|
|
47
51
|
exports.ConfirmationDialog = _ConfirmationDialog.ConfirmationDialog;
|
|
@@ -117,6 +121,7 @@ var _Table = require("./Table");
|
|
|
117
121
|
|
|
118
122
|
exports.Table = _Table.Table;
|
|
119
123
|
exports.TableRow = _Table.TableRow;
|
|
124
|
+
exports.TableCell = _Table.TableCell;
|
|
120
125
|
|
|
121
126
|
var _Tabs = require("./Tabs");
|
|
122
127
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@automattic/vip-design-system",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"main": "build/system/index.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build-storybook": "build-storybook",
|
|
@@ -17,9 +17,12 @@
|
|
|
17
17
|
"watch": "npm run build -- --watch"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@radix-ui/react-checkbox": "^0.1.
|
|
21
|
-
"@radix-ui/react-
|
|
22
|
-
"@radix-ui/react-
|
|
20
|
+
"@radix-ui/react-checkbox": "^0.1.5",
|
|
21
|
+
"@radix-ui/react-dialog": "^0.1.7",
|
|
22
|
+
"@radix-ui/react-radio-group": "^0.1.5",
|
|
23
|
+
"@radix-ui/react-switch": "^0.1.5",
|
|
24
|
+
"@radix-ui/react-tooltip": "^0.1.7",
|
|
25
|
+
"@radix-ui/react-visually-hidden": "^0.1.4",
|
|
23
26
|
"babel-loader": "^8.2.2",
|
|
24
27
|
"classnames": "^2.3.1",
|
|
25
28
|
"framer-motion": "^3.9.1",
|
|
@@ -83,6 +86,7 @@
|
|
|
83
86
|
"@mdx-js/react": "^2.1.1",
|
|
84
87
|
"@storybook/addon-a11y": "^6.5.9",
|
|
85
88
|
"@storybook/addon-actions": "^6.5.9",
|
|
89
|
+
"@storybook/addon-controls": "^6.5.9",
|
|
86
90
|
"@storybook/addon-essentials": "^6.5.9",
|
|
87
91
|
"@storybook/addon-links": "^6.5.9",
|
|
88
92
|
"@storybook/react": "^6.5.9",
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable max-len */
|
|
1
2
|
/** @jsxImportSource theme-ui */
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -6,73 +7,64 @@
|
|
|
6
7
|
import classNames from 'classnames';
|
|
7
8
|
import PropTypes from 'prop-types';
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
<CheckBoxWrapper className={ classNames( 'vip-checkbox-component', className ) }>
|
|
11
|
-
<CheckBox name={ name } id={ name } type="checkbox" { ...props } />
|
|
12
|
-
<CheckBoxLabel htmlFor={ name } />
|
|
13
|
-
</CheckBoxWrapper>
|
|
14
|
-
);
|
|
15
|
-
|
|
16
|
-
Toggle.propTypes = {
|
|
17
|
-
name: PropTypes.string,
|
|
18
|
-
className: PropTypes.any,
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export { Toggle };
|
|
10
|
+
import * as Switch from '@radix-ui/react-switch';
|
|
22
11
|
|
|
23
|
-
|
|
12
|
+
// Documentation for Radix Switch component
|
|
13
|
+
// https://www.radix-ui.com/docs/primitives/components/switch
|
|
24
14
|
|
|
25
|
-
const
|
|
26
|
-
|
|
15
|
+
export const Toggle = ( {
|
|
16
|
+
name = 'toggle',
|
|
17
|
+
onChange,
|
|
18
|
+
className = null,
|
|
19
|
+
variant = 'primary',
|
|
20
|
+
...rest
|
|
21
|
+
} ) => (
|
|
22
|
+
<Switch.Root
|
|
23
|
+
className={ classNames( 'vip-toggle-component', className ) }
|
|
27
24
|
sx={ {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
borderRadius: '15px',
|
|
25
|
+
all: 'unset',
|
|
26
|
+
position: 'relative',
|
|
27
|
+
width: 40,
|
|
28
|
+
height: 20,
|
|
29
|
+
borderRadius: '32px',
|
|
34
30
|
backgroundColor: 'muted',
|
|
35
|
-
|
|
36
|
-
'
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
width: '18px',
|
|
41
|
-
height: '18px',
|
|
42
|
-
margin: '3px',
|
|
43
|
-
backgroundColor: 'card',
|
|
44
|
-
boxShadow: 'low',
|
|
45
|
-
transition: '0.2s',
|
|
46
|
-
},
|
|
47
|
-
} }
|
|
48
|
-
{ ...props }
|
|
49
|
-
/>
|
|
50
|
-
);
|
|
31
|
+
backgroundRepeat: 'no-repeat',
|
|
32
|
+
backgroundPosition: 'right 2px top 2px',
|
|
33
|
+
backgroundImage: `url(
|
|
34
|
+
'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>')`,
|
|
35
|
+
WebkitTapHighlightColor: 'rgba(0, 0, 0, 0)',
|
|
51
36
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
borderRadius: '15px',
|
|
58
|
-
width: '42px',
|
|
59
|
-
height: '24px',
|
|
60
|
-
padding: 0,
|
|
61
|
-
margin: 0,
|
|
62
|
-
display: 'block',
|
|
63
|
-
'&:checked + label': {
|
|
64
|
-
backgroundColor: 'success',
|
|
65
|
-
'&::after': {
|
|
66
|
-
content: "''",
|
|
67
|
-
display: 'block',
|
|
68
|
-
borderRadius: '50%',
|
|
69
|
-
width: '18px',
|
|
70
|
-
height: '18px',
|
|
71
|
-
marginLeft: '21px',
|
|
72
|
-
transition: '0.2s',
|
|
73
|
-
},
|
|
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>')`,
|
|
74
42
|
},
|
|
75
43
|
} }
|
|
76
|
-
{
|
|
77
|
-
|
|
44
|
+
name={ name }
|
|
45
|
+
onCheckedChange={ onChange || undefined }
|
|
46
|
+
{ ...rest }
|
|
47
|
+
>
|
|
48
|
+
<Switch.Thumb
|
|
49
|
+
sx={ {
|
|
50
|
+
display: 'block',
|
|
51
|
+
width: 16,
|
|
52
|
+
height: 16,
|
|
53
|
+
backgroundColor: 'white',
|
|
54
|
+
borderRadius: '50%',
|
|
55
|
+
boxShadow: 'rgb(0 0 0 / 5%) 0px 1px 5px, rgb(0 0 0 / 15%) 0px 1px 1px',
|
|
56
|
+
transition: 'transform 100ms',
|
|
57
|
+
transform: 'translateX(2px)',
|
|
58
|
+
willChange: 'transform',
|
|
59
|
+
'&[data-state="checked"]': { transform: 'translateX(22px)' },
|
|
60
|
+
} }
|
|
61
|
+
/>
|
|
62
|
+
</Switch.Root>
|
|
78
63
|
);
|
|
64
|
+
|
|
65
|
+
Toggle.propTypes = {
|
|
66
|
+
name: PropTypes.string,
|
|
67
|
+
className: PropTypes.any,
|
|
68
|
+
onChange: PropTypes.func,
|
|
69
|
+
variant: PropTypes.string,
|
|
70
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
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
|
+
</form>
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
const WithLabel = args => (
|
|
40
|
+
<form>
|
|
41
|
+
<Label htmlFor="custom-label-input">Custom Label here</Label>
|
|
42
|
+
|
|
43
|
+
<Toggle
|
|
44
|
+
id="custom-label-input"
|
|
45
|
+
defaultChecked
|
|
46
|
+
checked={ args.checked }
|
|
47
|
+
aria-label="Feature flag"
|
|
48
|
+
/>
|
|
49
|
+
</form>
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
const CustomStyling = args => (
|
|
53
|
+
<form>
|
|
54
|
+
<Label htmlFor="custom-label-input">Custom Styling</Label>
|
|
55
|
+
|
|
56
|
+
<div>
|
|
57
|
+
<Toggle
|
|
58
|
+
id="custom-label-input"
|
|
59
|
+
defaultChecked
|
|
60
|
+
checked={ args.checked }
|
|
61
|
+
aria-label="Feature flag"
|
|
62
|
+
variant="success"
|
|
63
|
+
/>{ ' ' }
|
|
64
|
+
<Toggle
|
|
65
|
+
id="custom-label-input-error"
|
|
66
|
+
defaultChecked
|
|
67
|
+
checked={ args.checked }
|
|
68
|
+
aria-label="Error flag"
|
|
69
|
+
variant="error"
|
|
70
|
+
/>{ ' ' }
|
|
71
|
+
<Toggle
|
|
72
|
+
id="custom-label-input-warning"
|
|
73
|
+
defaultChecked
|
|
74
|
+
checked={ args.checked }
|
|
75
|
+
aria-label="Warning flag"
|
|
76
|
+
variant="warning"
|
|
77
|
+
/>
|
|
78
|
+
</div>
|
|
79
|
+
</form>
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
export const Primary = Default.bind( { checked: true } );
|
|
83
|
+
export const ExternalLabel = WithLabel.bind( { checked: true } );
|
|
84
|
+
export const CustomStyle = CustomStyling.bind( { checked: true } );
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { render, screen } from '@testing-library/react';
|
|
5
|
+
import { axe } from 'jest-axe';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
import { Toggle } from './Toggle';
|
|
11
|
+
|
|
12
|
+
describe( '<Toggle />', () => {
|
|
13
|
+
it( 'renders the Toggle component', async () => {
|
|
14
|
+
const { container } = render(
|
|
15
|
+
<Toggle aria-label="Dinner room Light" defaultChecked name="my-toggle" />
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
expect( screen.getByRole( 'switch' ) ).toBeInTheDocument();
|
|
19
|
+
|
|
20
|
+
// Check for accessibility issues
|
|
21
|
+
await expect( await axe( container ) ).toHaveNoViolations();
|
|
22
|
+
} );
|
|
23
|
+
} );
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/** @jsxImportSource theme-ui */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* External dependencies
|
|
5
|
+
*/
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
8
|
+
import { IoClose } from 'react-icons/io5';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Internal dependencies
|
|
12
|
+
*/
|
|
13
|
+
export const DialogClose = React.forwardRef( ( props, forwardedRef ) => (
|
|
14
|
+
<DialogPrimitive.Close asChild { ...props } ref={ forwardedRef }>
|
|
15
|
+
<button
|
|
16
|
+
aria-label="Close"
|
|
17
|
+
sx={ {
|
|
18
|
+
all: 'unset',
|
|
19
|
+
fontFamily: 'inherit',
|
|
20
|
+
borderRadius: '100%',
|
|
21
|
+
height: 25,
|
|
22
|
+
width: 25,
|
|
23
|
+
display: 'inline-flex',
|
|
24
|
+
alignItems: 'center',
|
|
25
|
+
justifyContent: 'center',
|
|
26
|
+
color: theme => `${ theme?.colors?.text }`,
|
|
27
|
+
position: 'absolute',
|
|
28
|
+
top: 10,
|
|
29
|
+
right: 10,
|
|
30
|
+
|
|
31
|
+
'&:hover': {
|
|
32
|
+
backgroundColor: 'border',
|
|
33
|
+
outlineStyle: 'solid',
|
|
34
|
+
outlineColor: 'primary',
|
|
35
|
+
outlineWidth: '2px',
|
|
36
|
+
},
|
|
37
|
+
'&:focus': { outlineStyle: 'solid', outlineColor: 'primary', outlineWidth: '2px' },
|
|
38
|
+
} }
|
|
39
|
+
>
|
|
40
|
+
<IoClose aria-hidden="true" />
|
|
41
|
+
</button>
|
|
42
|
+
</DialogPrimitive.Close>
|
|
43
|
+
) );
|
|
44
|
+
|
|
45
|
+
DialogClose.displayName = 'DialogClose';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { Dialog } from '@radix-ui/react-dialog';
|
|
5
|
+
import { render, screen } from '@testing-library/react';
|
|
6
|
+
import { axe } from 'jest-axe';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Internal dependencies
|
|
10
|
+
*/
|
|
11
|
+
import { DialogClose } from './DialogClose';
|
|
12
|
+
|
|
13
|
+
// If you render any Dialog child without the `<Dialog />` parent, it will throw an error.
|
|
14
|
+
const Wrapper = props => <Dialog open={ true } { ...props } />;
|
|
15
|
+
const defaultProps = {
|
|
16
|
+
title: 'This is a DialogClose',
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
describe( '<DialogClose />', () => {
|
|
20
|
+
it( 'renders the DialogClose component', async () => {
|
|
21
|
+
const { container } = render(
|
|
22
|
+
<Wrapper>
|
|
23
|
+
<DialogClose { ...defaultProps } />
|
|
24
|
+
</Wrapper>
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
expect( screen.getByLabelText( 'Close' ) ).toBeInTheDocument();
|
|
28
|
+
|
|
29
|
+
// Check for accessibility issues
|
|
30
|
+
await expect( await axe( container ) ).toHaveNoViolations();
|
|
31
|
+
} );
|
|
32
|
+
} );
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** @jsxImportSource theme-ui */
|
|
2
|
+
|
|
3
|
+
export const contentStyles = {
|
|
4
|
+
background: 'white',
|
|
5
|
+
borderRadius: 10,
|
|
6
|
+
boxShadow: 'hsl(206 22% 7% / 35%) 0px 10px 38px -10px, hsl(206 22% 7% / 20%) 0px 10px 20px -15px',
|
|
7
|
+
position: 'fixed',
|
|
8
|
+
top: '50%',
|
|
9
|
+
left: '50%',
|
|
10
|
+
transform: 'translate(-50%, -50%)',
|
|
11
|
+
width: '90vw',
|
|
12
|
+
maxWidth: '640px',
|
|
13
|
+
maxHeight: '85vh',
|
|
14
|
+
padding: 25,
|
|
15
|
+
'&:focus': { outline: 'none' },
|
|
16
|
+
'> h1, > h2': { marginTop: '0 !important' },
|
|
17
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/** @jsxImportSource theme-ui */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* External dependencies
|
|
5
|
+
*/
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
9
|
+
import ScreenReaderText from '../ScreenReaderText/ScreenReaderText';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Internal dependencies
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
export const DialogDescription = React.forwardRef(
|
|
16
|
+
( { description, hidden, ...rest }, forwardedRef ) => {
|
|
17
|
+
let text = description;
|
|
18
|
+
|
|
19
|
+
if ( hidden ) {
|
|
20
|
+
text = <ScreenReaderText>{ text }</ScreenReaderText>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<DialogPrimitive.Description { ...rest } ref={ forwardedRef }>
|
|
25
|
+
{ text }
|
|
26
|
+
</DialogPrimitive.Description>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
DialogDescription.displayName = 'DialogDescription';
|
|
32
|
+
|
|
33
|
+
DialogDescription.propTypes = {
|
|
34
|
+
description: PropTypes.string,
|
|
35
|
+
hidden: PropTypes.bool,
|
|
36
|
+
};
|