@automattic/vip-design-system 0.10.3 → 0.11.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/.eslines.json +8 -8
- package/.eslintrc.json +9 -4
- package/.github/PULL_REQUEST_TEMPLATE.md +1 -1
- package/.github/workflows/nodejs.yaml +14 -14
- package/.prettierrc +1 -2
- package/.storybook/main.js +1 -1
- package/.storybook/preview.js +4 -8
- package/README.md +1 -0
- package/babel.config.js +1 -1
- package/build/system/Avatar/Avatar.js +2 -1
- package/build/system/BlankState/BlankState.stories.js +3 -3
- package/build/system/BlankState/BlankState.test.js +2 -2
- package/build/system/Card/Card.test.js +0 -2
- package/build/system/Code/Code.js +7 -2
- package/build/system/Code/Code.test.js +22 -57
- package/build/system/Form/MultiSelect.js +45 -25
- package/build/system/Form/Select.stories.js +3 -4
- package/build/system/Form/Select.test.js +2 -2
- package/build/system/Notification/Notification.js +24 -15
- package/build/system/Notification/Notification.stories.js +14 -4
- package/build/system/OptionRow/OptionRow.js +23 -17
- package/build/system/OptionRow/OptionRow.stories.js +5 -5
- package/build/system/OptionRow/OptionRow.test.js +4 -4
- package/build/system/ResourceList/ResourceList.js +34 -25
- package/build/system/ResourceList/ResourceList.stories.js +2 -0
- package/build/system/ScreenReaderText/ScreenReader.test.js +37 -0
- package/build/system/ScreenReaderText/ScreenReaderText.js +49 -0
- package/build/system/ScreenReaderText/index.js +7 -0
- package/build/system/Time/index.js +1 -1
- package/build/system/UsageChart/UsageChart.js +47 -45
- package/build/system/UsageChart/UsageChart.stories.js +8 -8
- package/build/system/UsageChart/index.js +3 -3
- package/build/system/Wizard/Wizard.stories.js +1 -1
- package/package.json +8 -4
- package/src/system/Avatar/Avatar.js +1 -0
- package/src/system/Avatar/index.js +0 -1
- package/src/system/Badge/index.js +0 -1
- package/src/system/BlankState/BlankState.js +8 -5
- package/src/system/BlankState/BlankState.stories.jsx +5 -4
- package/src/system/BlankState/BlankState.test.js +21 -21
- package/src/system/BlankState/index.js +0 -1
- package/src/system/Box/Box.js +7 -1
- package/src/system/Box/index.js +0 -1
- package/src/system/Button/Button.js +3 -3
- package/src/system/Button/Button.stories.jsx +2 -2
- package/src/system/Button/index.js +0 -1
- package/src/system/Card/Card.js +4 -4
- package/src/system/Card/Card.test.js +1 -2
- package/src/system/Card/index.js +0 -1
- package/src/system/Code/Code.js +6 -2
- package/src/system/Code/Code.stories.jsx +10 -5
- package/src/system/Code/Code.test.js +3 -16
- package/src/system/ConfirmationDialog/ConfirmationDialog.js +8 -1
- package/src/system/Dialog/Dialog.js +17 -8
- package/src/system/Dialog/Dialog.stories.jsx +9 -13
- package/src/system/Dialog/DialogButton.js +18 -14
- package/src/system/Dialog/DialogDivider.js +1 -1
- package/src/system/Dialog/DialogMenu.js +1 -5
- package/src/system/Dialog/DialogMenuItem.js +4 -8
- package/src/system/Dialog/DialogTrigger.js +1 -1
- package/src/system/Dialog/index.js +0 -1
- package/src/system/Flex/Flex.js +1 -1
- package/src/system/Flex/index.js +0 -1
- package/src/system/Form/AsyncSearchSelect.js +3 -7
- package/src/system/Form/Checkbox.js +32 -28
- package/src/system/Form/InlineSelect.js +21 -17
- package/src/system/Form/Input.js +43 -45
- package/src/system/Form/Label.js +2 -2
- package/src/system/Form/RadioBoxGroup.js +34 -32
- package/src/system/Form/RadioBoxGroup.stories.jsx +8 -1
- package/src/system/Form/SearchSelect.js +7 -7
- package/src/system/Form/Select.js +21 -2
- package/src/system/Form/Select.stories.jsx +31 -34
- package/src/system/Form/Select.test.js +3 -8
- package/src/system/Form/Textarea.js +38 -40
- package/src/system/Form/Toggle.js +9 -11
- package/src/system/Form/ToggleGroup.js +29 -31
- package/src/system/Form/ToggleGroup.stories.jsx +8 -1
- package/src/system/Form/ToggleRow.js +6 -1
- package/src/system/Form/Validation.js +6 -1
- package/src/system/Form/index.js +13 -1
- package/src/system/Grid/Grid.js +1 -1
- package/src/system/Grid/index.js +0 -1
- package/src/system/Heading/Heading.js +4 -4
- package/src/system/Heading/index.js +0 -1
- package/src/system/Link/index.js +0 -1
- package/src/system/Notice/Notice.js +27 -13
- package/src/system/Notice/Notice.stories.jsx +6 -8
- package/src/system/Notice/index.js +0 -1
- package/src/system/Notification/Notification.js +25 -20
- package/src/system/Notification/Notification.stories.jsx +4 -4
- package/src/system/Notification/index.js +0 -1
- package/src/system/OptionRow/OptionRow.js +46 -44
- package/src/system/OptionRow/OptionRow.stories.jsx +10 -8
- package/src/system/OptionRow/OptionRow.test.js +12 -11
- package/src/system/OptionRow/index.js +0 -1
- package/src/system/Progress/Progress.js +3 -1
- package/src/system/Progress/Progress.stories.jsx +4 -4
- package/src/system/Progress/index.js +0 -1
- package/src/system/ResourceList/ResourceItem.js +15 -15
- package/src/system/ResourceList/ResourceList.js +28 -16
- package/src/system/ResourceList/ResourceList.stories.jsx +77 -71
- package/src/system/ScreenReaderText/ScreenReader.test.js +22 -0
- package/src/system/ScreenReaderText/ScreenReaderText.js +40 -0
- package/src/system/ScreenReaderText/index.js +7 -0
- package/src/system/Spinner/Spinner.js +4 -4
- package/src/system/Spinner/index.js +0 -1
- package/src/system/Table/Table.js +5 -5
- package/src/system/Table/Table.stories.jsx +10 -8
- package/src/system/Table/index.js +0 -1
- package/src/system/Tabs/Tabs.js +3 -3
- package/src/system/Tabs/index.js +0 -1
- package/src/system/Text/Text.js +3 -3
- package/src/system/Text/Text.stories.jsx +4 -6
- package/src/system/Text/index.js +0 -1
- package/src/system/Time/Time.stories.jsx +2 -6
- package/src/system/Time/index.js +5 -5
- package/src/system/Timeline/Timeline.js +6 -12
- package/src/system/Timeline/Timeline.stories.jsx +3 -12
- package/src/system/Timeline/index.js +0 -1
- package/src/system/Tooltip/Tooltip.js +4 -8
- package/src/system/Wizard/Wizard.js +23 -21
- package/src/system/Wizard/Wizard.stories.jsx +7 -12
- package/src/system/Wizard/WizardStep.js +8 -8
- package/src/system/Wizard/WizardStepHorizontal.js +4 -4
- package/src/system/Wizard/index.js +0 -1
- package/src/system/theme/index.js +3 -4
- package/tokens/valet-color.json +1919 -0
|
@@ -22,6 +22,27 @@ var _classnames = _interopRequireDefault(require("classnames"));
|
|
|
22
22
|
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
23
23
|
|
|
24
24
|
var _excluded = ["image", "icon", "badge", "label", "inline", "subTitle", "body", "meta", "to", "small", "disabled", "order", "className"];
|
|
25
|
+
var disabledStyles = {
|
|
26
|
+
border: '1px solid',
|
|
27
|
+
borderColor: 'border',
|
|
28
|
+
background: 'none',
|
|
29
|
+
boxShadow: 'none',
|
|
30
|
+
color: 'grey.70'
|
|
31
|
+
};
|
|
32
|
+
var gridInlineStyle = {
|
|
33
|
+
py: 2,
|
|
34
|
+
px: 2,
|
|
35
|
+
mx: -2
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
var regularGridStyle = function regularGridStyle(small) {
|
|
39
|
+
return {
|
|
40
|
+
py: 3,
|
|
41
|
+
px: [3, 3, small ? 3 : 5],
|
|
42
|
+
borderBottom: '1px solid',
|
|
43
|
+
borderColor: 'border'
|
|
44
|
+
};
|
|
45
|
+
};
|
|
25
46
|
|
|
26
47
|
var OptionRow = function OptionRow(_ref) {
|
|
27
48
|
var image = _ref.image,
|
|
@@ -43,23 +64,8 @@ var OptionRow = function OptionRow(_ref) {
|
|
|
43
64
|
_ref$className = _ref.className,
|
|
44
65
|
className = _ref$className === void 0 ? null : _ref$className,
|
|
45
66
|
props = (0, _objectWithoutPropertiesLoose2["default"])(_ref, _excluded);
|
|
46
|
-
var mergedCard = disabled ? {
|
|
47
|
-
|
|
48
|
-
borderColor: 'border',
|
|
49
|
-
background: 'none',
|
|
50
|
-
boxShadow: 'none',
|
|
51
|
-
color: 'grey.70'
|
|
52
|
-
} : {};
|
|
53
|
-
var inlineStyles = inline ? {
|
|
54
|
-
py: 2,
|
|
55
|
-
px: 2,
|
|
56
|
-
mx: -2
|
|
57
|
-
} : {
|
|
58
|
-
py: 3,
|
|
59
|
-
px: [3, 3, small ? 3 : 5],
|
|
60
|
-
borderBottom: '1px solid',
|
|
61
|
-
borderColor: 'border'
|
|
62
|
-
};
|
|
67
|
+
var mergedCard = disabled ? disabledStyles : {};
|
|
68
|
+
var inlineStyles = inline ? gridInlineStyle : regularGridStyle(small);
|
|
63
69
|
return (0, _jsxRuntime.jsxs)(_.Grid, (0, _extends2["default"])({
|
|
64
70
|
to: to,
|
|
65
71
|
columns: [1, 1, 'auto 1fr auto'],
|
|
@@ -13,12 +13,12 @@ var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
|
13
13
|
var _default = {
|
|
14
14
|
title: 'OptionRow',
|
|
15
15
|
component: _.OptionRow
|
|
16
|
-
};
|
|
17
|
-
|
|
16
|
+
};
|
|
18
17
|
exports["default"] = _default;
|
|
19
|
-
var image1 =
|
|
20
|
-
|
|
21
|
-
var image2 =
|
|
18
|
+
var image1 = // eslint-disable-next-line max-len
|
|
19
|
+
"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='79' height='79' viewBox='0 0 79 79' fill='none' %3E%3Cpath d='M71.4 15.3L54.2 4.2C54 4 53.7 4 53.4 4H26.4C26.1 4 25.8 4.1 25.6 4.2L8.29997 15.3C7.89997 15.6 7.59998 16 7.59998 16.5V32.1V63C7.59998 63.5 7.89997 64 8.29997 64.2L25.5 75.3C25.5 75.3 25.6 75.3 25.6 75.4C25.6 75.4 25.7 75.4 25.7 75.5C25.9 75.6 26 75.6 26.2 75.6H53.2C53.4 75.6 53.5 75.6 53.7 75.5C53.8 75.5 53.8 75.5 53.8 75.4C53.8 75.4 53.9 75.4 53.9 75.3L71.4 64.2C71.5 64.1 71.7 64 71.8 63.8C71.8 63.8 71.8 63.7 71.9 63.7C72 63.6 72.1 63.4 72.1 63.2V63.1C72.1 63 72.1 62.9 72.1 62.8V32.1V16.5C72.1 16 71.8 15.6 71.4 15.3ZM24.9 71.4L10.6 62.2V34.8L24.9 44V71.4ZM51.9 72.6H27.8V44.7H51.9V72.6ZM69.1 31.3L52.9 41.7H26.8L10.6 31.3V17.3L26.8 6.9H52.9L69.1 17.3V31.3Z' fill='%23BD9D70' /%3E%3C/svg%3E";
|
|
20
|
+
var image2 = // eslint-disable-next-line max-len
|
|
21
|
+
"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='79' height='79' viewBox='0 0 79 79' fill='none'%3E%3Cpath d='M66.3001 15.9C66.3001 15.9 66.3 15.8 66.2 15.8C66.1 15.7 66 15.5 65.9001 15.4C65.9001 15.4 65.9001 15.4 65.9001 15.3L44.4001 0.2C44.3001 0.0999998 44.2 0.0999994 44.1 0.0999994C44 0.0999994 44.0001 0 43.9001 0H43.3C43.2 0 43.1 0.0999994 43.1 0.0999994C43 0.0999994 42.9 0.2 42.8 0.2L28.2001 10.3C28.1 10.4 28.0001 10.5 27.9001 10.6C27.9001 10.6 27.9001 10.6 27.9001 10.7C27.8001 10.8 27.7001 11 27.7001 11.2C27.7001 11.2 27.7001 11.2 27.7001 11.3V31.1L13.9 40.8L13.7001 41C13.6001 41.1 13.6 41.1 13.6 41.2L13.5 41.3C13.5 41.4 13.4 41.5 13.4 41.5V41.6C13.4 41.7 13.3 41.8 13.3 42V62.2C13.3 62.4 13.3 62.6 13.4 62.7V62.8C13.5 62.9 13.6001 63.1 13.7001 63.2C13.7001 63.2 13.7 63.2 13.8 63.3L13.9 63.4L35.3 78.6H35.4001C35.4001 78.6 35.5 78.6 35.5 78.7H35.6C35.8 78.8 36 78.8 36.2001 78.8C36.3001 78.8 36.5 78.8 36.6 78.7H36.7001C36.8001 78.7 36.8001 78.7 36.9001 78.6C36.9001 78.6 37 78.6 37 78.5H37.1L66 58.3C66.1 58.2 66.2001 58.1 66.3001 58V15.9ZM34.6 74.5L16.1 61.3V44.7L34.6 57.8V74.5ZM36 55.3L17.2001 41.9L29 33.5L47.9001 46.9L36 55.3ZM49 44.1L30.5 31V14.4L49 27.5V44.1ZM50.5 24.9L31.6 11.5L43.5 3.2L62.4001 16.6L50.5 24.9Z' fill='%23BD9D70'/%3E%3C/svg%3E";
|
|
22
22
|
|
|
23
23
|
var Default = function Default() {
|
|
24
24
|
return (0, _jsxRuntime.jsxs)(_.Box, {
|
|
@@ -19,8 +19,8 @@ var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
|
-
* Internal dependencies
|
|
23
|
-
*/
|
|
22
|
+
* Internal dependencies
|
|
23
|
+
*/
|
|
24
24
|
describe('<OptionRow />', function () {
|
|
25
25
|
it('renders the OptionRow', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
26
26
|
var _render, container;
|
|
@@ -59,8 +59,8 @@ describe('<OptionRow />', function () {
|
|
|
59
59
|
while (1) {
|
|
60
60
|
switch (_context2.prev = _context2.next) {
|
|
61
61
|
case 0:
|
|
62
|
-
// eslint-disable-next-line max-len
|
|
63
|
-
|
|
62
|
+
image1 = // eslint-disable-next-line max-len
|
|
63
|
+
"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='79' height='79' viewBox='0 0 79 79' fill='none' %3E%3Cpath d='M71.4 15.3L54.2 4.2C54 4 53.7 4 53.4 4H26.4C26.1 4 25.8 4.1 25.6 4.2L8.29997 15.3C7.89997 15.6 7.59998 16 7.59998 16.5V32.1V63C7.59998 63.5 7.89997 64 8.29997 64.2L25.5 75.3C25.5 75.3 25.6 75.3 25.6 75.4C25.6 75.4 25.7 75.4 25.7 75.5C25.9 75.6 26 75.6 26.2 75.6H53.2C53.4 75.6 53.5 75.6 53.7 75.5C53.8 75.5 53.8 75.5 53.8 75.4C53.8 75.4 53.9 75.4 53.9 75.3L71.4 64.2C71.5 64.1 71.7 64 71.8 63.8C71.8 63.8 71.8 63.7 71.9 63.7C72 63.6 72.1 63.4 72.1 63.2V63.1C72.1 63 72.1 62.9 72.1 62.8V32.1V16.5C72.1 16 71.8 15.6 71.4 15.3ZM24.9 71.4L10.6 62.2V34.8L24.9 44V71.4ZM51.9 72.6H27.8V44.7H51.9V72.6ZM69.1 31.3L52.9 41.7H26.8L10.6 31.3V17.3L26.8 6.9H52.9L69.1 17.3V31.3Z' fill='%23BD9D70' /%3E%3C/svg%3E";
|
|
64
64
|
_render2 = (0, _react.render)((0, _jsxRuntime.jsx)(_OptionRow.OptionRow, {
|
|
65
65
|
image: image1,
|
|
66
66
|
label: "Option Row",
|
|
@@ -9,6 +9,8 @@ var _extends3 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
9
9
|
|
|
10
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
11
|
|
|
12
|
+
var _react = require("react");
|
|
13
|
+
|
|
12
14
|
var _ = require("..");
|
|
13
15
|
|
|
14
16
|
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
@@ -85,6 +87,37 @@ var ResourceList = function ResourceList(_ref) {
|
|
|
85
87
|
});
|
|
86
88
|
};
|
|
87
89
|
|
|
90
|
+
var renderGoupedItems = function renderGoupedItems() {
|
|
91
|
+
return (0, _react.useMemo)(function () {
|
|
92
|
+
return Object.keys(groupedItems).map(function (groupName, index) {
|
|
93
|
+
return (0, _jsxRuntime.jsxs)(_.Box, {
|
|
94
|
+
sx: {
|
|
95
|
+
mb: 4
|
|
96
|
+
},
|
|
97
|
+
as: "li",
|
|
98
|
+
children: [(0, _jsxRuntime.jsx)(_.Heading, {
|
|
99
|
+
variant: "h4",
|
|
100
|
+
as: "h4",
|
|
101
|
+
sx: {
|
|
102
|
+
mb: 3
|
|
103
|
+
},
|
|
104
|
+
children: groupName
|
|
105
|
+
}), (0, _jsxRuntime.jsx)(_.Box, {
|
|
106
|
+
as: "ul",
|
|
107
|
+
sx: {
|
|
108
|
+
listStyleType: 'none',
|
|
109
|
+
m: 0,
|
|
110
|
+
p: 0,
|
|
111
|
+
borderTop: '1px solid',
|
|
112
|
+
borderColor: 'border'
|
|
113
|
+
},
|
|
114
|
+
children: renderItemList(groupedItems[groupName])
|
|
115
|
+
})]
|
|
116
|
+
}, index);
|
|
117
|
+
});
|
|
118
|
+
}, [groupedItems]);
|
|
119
|
+
};
|
|
120
|
+
|
|
88
121
|
return (0, _jsxRuntime.jsx)(_.Box, {
|
|
89
122
|
as: "ul",
|
|
90
123
|
sx: {
|
|
@@ -93,31 +126,7 @@ var ResourceList = function ResourceList(_ref) {
|
|
|
93
126
|
p: 0
|
|
94
127
|
},
|
|
95
128
|
className: "vip-resource-list-component",
|
|
96
|
-
children: groupedByDay ?
|
|
97
|
-
return (0, _jsxRuntime.jsxs)(_.Box, {
|
|
98
|
-
sx: {
|
|
99
|
-
mb: 4
|
|
100
|
-
},
|
|
101
|
-
children: [(0, _jsxRuntime.jsx)(_.Heading, {
|
|
102
|
-
variant: "h4",
|
|
103
|
-
as: "h4",
|
|
104
|
-
sx: {
|
|
105
|
-
mb: 3
|
|
106
|
-
},
|
|
107
|
-
children: groupName
|
|
108
|
-
}), (0, _jsxRuntime.jsx)(_.Box, {
|
|
109
|
-
as: "ul",
|
|
110
|
-
sx: {
|
|
111
|
-
listStyleType: 'none',
|
|
112
|
-
m: 0,
|
|
113
|
-
p: 0,
|
|
114
|
-
borderTop: '1px solid',
|
|
115
|
-
borderColor: 'border'
|
|
116
|
-
},
|
|
117
|
-
children: renderItemList(groupedItems[groupName])
|
|
118
|
-
})]
|
|
119
|
-
}, index);
|
|
120
|
-
}) : renderItemList(items)
|
|
129
|
+
children: groupedByDay ? renderGoupedItems(groupedItems) : renderItemList(items)
|
|
121
130
|
});
|
|
122
131
|
};
|
|
123
132
|
|
|
@@ -129,6 +129,7 @@ var Grouped = function Grouped() {
|
|
|
129
129
|
children: "#443"
|
|
130
130
|
})]
|
|
131
131
|
}), (0, _jsxRuntime.jsxs)(_.Text, {
|
|
132
|
+
as: "div",
|
|
132
133
|
sx: {
|
|
133
134
|
mb: 0,
|
|
134
135
|
fontSize: 1,
|
|
@@ -337,6 +338,7 @@ var Relative = function Relative() {
|
|
|
337
338
|
children: "Running"
|
|
338
339
|
})]
|
|
339
340
|
}), (0, _jsxRuntime.jsxs)(_.Text, {
|
|
341
|
+
as: "div",
|
|
340
342
|
sx: {
|
|
341
343
|
mb: 0,
|
|
342
344
|
color: 'muted',
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
6
|
+
|
|
7
|
+
var _react = require("@testing-library/react");
|
|
8
|
+
|
|
9
|
+
require("@testing-library/jest-dom");
|
|
10
|
+
|
|
11
|
+
var _ScreenReaderText = _interopRequireDefault(require("./ScreenReaderText"));
|
|
12
|
+
|
|
13
|
+
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* External dependencies
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Internal dependencies
|
|
21
|
+
*/
|
|
22
|
+
describe('<ScreenReaderText />', function () {
|
|
23
|
+
it('should render correctly', function () {
|
|
24
|
+
var props = {};
|
|
25
|
+
var text = 'Hello there';
|
|
26
|
+
|
|
27
|
+
var _render = (0, _react.render)((0, _jsxRuntime.jsx)(_ScreenReaderText["default"], (0, _extends2["default"])({}, props, {
|
|
28
|
+
children: text
|
|
29
|
+
}))),
|
|
30
|
+
container = _render.container; // we're using the querySelector to ensure the class is rendered since it affects the A11Y
|
|
31
|
+
// in case it's removed it could compromise the A11Y of the components using it.
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
expect(container.querySelector('.screen-reader-text')).toBeInTheDocument();
|
|
35
|
+
expect(_react.screen.queryByText(text)).toBeInTheDocument();
|
|
36
|
+
});
|
|
37
|
+
});
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
exports.__esModule = true;
|
|
6
|
+
exports["default"] = ScreenReaderText;
|
|
7
|
+
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
12
|
+
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
13
|
+
|
|
14
|
+
/** @jsxImportSource theme-ui */
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* External dependencies
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Internal dependencies
|
|
22
|
+
*/
|
|
23
|
+
function ScreenReaderText(props) {
|
|
24
|
+
return (0, _jsxRuntime.jsx)("span", (0, _extends2["default"])({
|
|
25
|
+
className: "screen-reader-text",
|
|
26
|
+
sx: {
|
|
27
|
+
border: 'none',
|
|
28
|
+
clip: 'rect(1px, 1px, 1px, 1px)',
|
|
29
|
+
clipPath: 'inset(50%)',
|
|
30
|
+
height: '1px',
|
|
31
|
+
margin: '-1px',
|
|
32
|
+
overflow: 'hidden',
|
|
33
|
+
padding: '0',
|
|
34
|
+
position: 'absolute',
|
|
35
|
+
width: '1px',
|
|
36
|
+
wordWrap: 'normal !important'
|
|
37
|
+
}
|
|
38
|
+
}, props, {
|
|
39
|
+
children: props.children
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* propTypes
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
ScreenReaderText.propTypes = {
|
|
48
|
+
children: _propTypes["default"].node.isRequired
|
|
49
|
+
};
|
|
@@ -88,7 +88,7 @@ var Time = function Time(_ref) {
|
|
|
88
88
|
|
|
89
89
|
exports.Time = Time;
|
|
90
90
|
Time.propTypes = {
|
|
91
|
-
time: _propTypes["default"].string,
|
|
91
|
+
time: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].date]),
|
|
92
92
|
timeOnly: _propTypes["default"].bool,
|
|
93
93
|
relativeTime: _propTypes["default"].bool,
|
|
94
94
|
className: _propTypes["default"].any
|
|
@@ -1,60 +1,62 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports.UsageChart = void 0;
|
|
5
5
|
|
|
6
|
-
var _framerMotion = require(
|
|
6
|
+
var _framerMotion = require( 'framer-motion' );
|
|
7
7
|
|
|
8
|
-
var _propTypes = _interopRequireDefault(require(
|
|
8
|
+
var _propTypes = _interopRequireDefault( require( 'prop-types' ) );
|
|
9
9
|
|
|
10
|
-
var _jsxRuntime = require(
|
|
10
|
+
var _jsxRuntime = require( 'theme-ui/jsx-runtime' );
|
|
11
11
|
|
|
12
|
-
function _interopRequireDefault(
|
|
12
|
+
function _interopRequireDefault( obj ) {
|
|
13
|
+
return obj && obj.__esModule ? obj : { default: obj };
|
|
14
|
+
}
|
|
13
15
|
|
|
14
16
|
/**
|
|
15
17
|
* External dependencies
|
|
16
18
|
*/
|
|
17
|
-
var UsageChart = function UsageChart(_ref) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
19
|
+
var UsageChart = function UsageChart( _ref ) {
|
|
20
|
+
var total = _ref.total,
|
|
21
|
+
max = _ref.max,
|
|
22
|
+
_ref$variant = _ref.variant,
|
|
23
|
+
variant = _ref$variant === void 0 ? 'primary' : _ref$variant;
|
|
24
|
+
var width = ( total / max ) * 100 + '%';
|
|
25
|
+
var formattedTotal = total;
|
|
26
|
+
|
|
27
|
+
if ( total > 1000000 ) {
|
|
28
|
+
formattedTotal = ( total / 1000000 ).toFixed( 2 ) + 'M';
|
|
29
|
+
} else if ( total > 1000 ) {
|
|
30
|
+
formattedTotal = ( total / 1000 ).toFixed( 2 ) + 'K';
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return ( 0, _jsxRuntime.jsx )( 'div', {
|
|
34
|
+
sx: {
|
|
35
|
+
height: variant === 'primary' ? 32 : 8,
|
|
36
|
+
overflow: 'hidden',
|
|
37
|
+
backgroundColor: variant === 'primary' ? 'border' : 'transparent',
|
|
38
|
+
},
|
|
39
|
+
children: ( 0, _jsxRuntime.jsx )( _framerMotion.motion.div, {
|
|
40
|
+
initial: {
|
|
41
|
+
width: 0,
|
|
42
|
+
},
|
|
43
|
+
animate: {
|
|
44
|
+
width: width,
|
|
45
|
+
},
|
|
46
|
+
transition: {
|
|
47
|
+
duration: 0.7,
|
|
48
|
+
},
|
|
49
|
+
sx: {
|
|
50
|
+
height: '100%',
|
|
51
|
+
backgroundColor: variant === 'primary' ? 'primary' : 'grey.40',
|
|
52
|
+
},
|
|
53
|
+
} ),
|
|
54
|
+
} );
|
|
53
55
|
};
|
|
54
56
|
|
|
55
57
|
exports.UsageChart = UsageChart;
|
|
56
58
|
UsageChart.propTypes = {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
};
|
|
59
|
+
total: _propTypes[ 'default' ].number,
|
|
60
|
+
max: _propTypes[ 'default' ].number,
|
|
61
|
+
variant: _propTypes[ 'default' ].string,
|
|
62
|
+
};
|
|
@@ -8,13 +8,13 @@ import React from 'react';
|
|
|
8
8
|
|
|
9
9
|
import { UsageChart } from '..';
|
|
10
10
|
export default {
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
title: 'UsageChart',
|
|
12
|
+
component: UsageChart,
|
|
13
13
|
};
|
|
14
14
|
export var Default = function Default() {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
};
|
|
15
|
+
return /*#__PURE__*/ React.createElement( UsageChart, {
|
|
16
|
+
total: 50,
|
|
17
|
+
max: 75,
|
|
18
|
+
variant: 'primary',
|
|
19
|
+
} );
|
|
20
|
+
};
|
package/package.json
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@automattic/vip-design-system",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"main": "build/system/index.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build-storybook": "build-storybook",
|
|
7
7
|
"build": "cross-env NODE_ENV=production babel src --out-dir build",
|
|
8
|
-
"format": "
|
|
8
|
+
"format": "prettier --write \"src/**/*.{js,ts,tsx,md,mdx,json}\"",
|
|
9
|
+
"format:check": "prettier --list-different -- \"src/**/*.{js,ts,tsx,md,mdx,json}\"",
|
|
9
10
|
"jest": "NODE_ENV=test jest --detectOpenHandles --env=jsdom",
|
|
10
11
|
"jest:coverage": "npm run jest && open-cli ./coverage/index.html",
|
|
11
12
|
"jest:watch": "npm run jest --watch",
|
|
12
|
-
"lint": "eslint . -
|
|
13
|
+
"lint": "eslint . --fix --max-warnings 0",
|
|
13
14
|
"storybook": "start-storybook -p 6006",
|
|
14
15
|
"dev": "npm run storybook",
|
|
15
16
|
"test": "npm run lint && npm run jest",
|
|
@@ -92,12 +93,14 @@
|
|
|
92
93
|
"cross-env": "^7.0.3",
|
|
93
94
|
"eslines": "2.1.0",
|
|
94
95
|
"eslint": "7.32.0",
|
|
96
|
+
"eslint-config-prettier": "^8.5.0",
|
|
95
97
|
"eslint-config-react-app": "6.0.0",
|
|
96
|
-
"eslint-config-wpvip": "automattic/eslint-config-wpvip#
|
|
98
|
+
"eslint-config-wpvip": "github:automattic/eslint-config-wpvip#b73cd84",
|
|
97
99
|
"eslint-plugin-jest": "24.4.2",
|
|
98
100
|
"eslint-plugin-json": "3.1.0",
|
|
99
101
|
"eslint-plugin-jsx-a11y": "6.4.1",
|
|
100
102
|
"eslint-plugin-no-async-foreach": "0.1.1",
|
|
103
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
101
104
|
"eslint-plugin-react": "7.25.3",
|
|
102
105
|
"eslint-plugin-storybook": "^0.5.12",
|
|
103
106
|
"eslint-plugin-wpcalypso": "4.1.0",
|
|
@@ -109,6 +112,7 @@
|
|
|
109
112
|
"jsdom-global": "3.0.2",
|
|
110
113
|
"open-cli": "^7.0.1",
|
|
111
114
|
"optimize-css-assets-webpack-plugin": "^6.0.1",
|
|
115
|
+
"prettier": "npm:wp-prettier@^2.6.2",
|
|
112
116
|
"react": "^17.0.2",
|
|
113
117
|
"react-dom": "^17.0.2",
|
|
114
118
|
"react-input-autosize": "^3.0.0",
|
|
@@ -21,11 +21,14 @@ const BlankState = ( {
|
|
|
21
21
|
className = null,
|
|
22
22
|
} ) => {
|
|
23
23
|
return (
|
|
24
|
-
<Box
|
|
25
|
-
{
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
<
|
|
24
|
+
<Box
|
|
25
|
+
sx={ { textAlign: 'center', padding: 5 } }
|
|
26
|
+
className={ classNames( 'vip-blank-state-component', className ) }
|
|
27
|
+
>
|
|
28
|
+
{ icon ? icon : <img src={ image } sx={ { mb: 3 } } alt={ imageAlt } /> }
|
|
29
|
+
<Heading variant="h4">{ title }</Heading>
|
|
30
|
+
<Text>{ body }</Text>
|
|
31
|
+
<Box sx={ { mt: 3 } }>{ cta }</Box>
|
|
29
32
|
</Box>
|
|
30
33
|
);
|
|
31
34
|
};
|
|
@@ -8,16 +8,17 @@ export default {
|
|
|
8
8
|
component: BlankState,
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
const image2 =
|
|
12
|
+
// eslint-disable-next-line max-len
|
|
13
|
+
"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='79' height='79' viewBox='0 0 79 79' fill='none'%3E%3Cpath d='M66.3001 15.9C66.3001 15.9 66.3 15.8 66.2 15.8C66.1 15.7 66 15.5 65.9001 15.4C65.9001 15.4 65.9001 15.4 65.9001 15.3L44.4001 0.2C44.3001 0.0999998 44.2 0.0999994 44.1 0.0999994C44 0.0999994 44.0001 0 43.9001 0H43.3C43.2 0 43.1 0.0999994 43.1 0.0999994C43 0.0999994 42.9 0.2 42.8 0.2L28.2001 10.3C28.1 10.4 28.0001 10.5 27.9001 10.6C27.9001 10.6 27.9001 10.6 27.9001 10.7C27.8001 10.8 27.7001 11 27.7001 11.2C27.7001 11.2 27.7001 11.2 27.7001 11.3V31.1L13.9 40.8L13.7001 41C13.6001 41.1 13.6 41.1 13.6 41.2L13.5 41.3C13.5 41.4 13.4 41.5 13.4 41.5V41.6C13.4 41.7 13.3 41.8 13.3 42V62.2C13.3 62.4 13.3 62.6 13.4 62.7V62.8C13.5 62.9 13.6001 63.1 13.7001 63.2C13.7001 63.2 13.7 63.2 13.8 63.3L13.9 63.4L35.3 78.6H35.4001C35.4001 78.6 35.5 78.6 35.5 78.7H35.6C35.8 78.8 36 78.8 36.2001 78.8C36.3001 78.8 36.5 78.8 36.6 78.7H36.7001C36.8001 78.7 36.8001 78.7 36.9001 78.6C36.9001 78.6 37 78.6 37 78.5H37.1L66 58.3C66.1 58.2 66.2001 58.1 66.3001 58V15.9ZM34.6 74.5L16.1 61.3V44.7L34.6 57.8V74.5ZM36 55.3L17.2001 41.9L29 33.5L47.9001 46.9L36 55.3ZM49 44.1L30.5 31V14.4L49 27.5V44.1ZM50.5 24.9L31.6 11.5L43.5 3.2L62.4001 16.6L50.5 24.9Z' fill='%23BD9D70'/%3E%3C/svg%3E";
|
|
13
14
|
|
|
14
15
|
export const Default = () => (
|
|
15
16
|
<BlankState
|
|
16
|
-
image={image2}
|
|
17
|
+
image={ image2 }
|
|
17
18
|
title="Power up your application"
|
|
18
19
|
body="Add-ons give you the ability to bolt on extra capabilities to
|
|
19
20
|
your application, including logging, analytics and performance
|
|
20
21
|
monitoring."
|
|
21
|
-
cta={<Link as="a">Explore add-ons →</Link>}
|
|
22
|
+
cta={ <Link as="a">Explore add-ons →</Link> }
|
|
22
23
|
/>
|
|
23
24
|
);
|
|
@@ -11,8 +11,8 @@ import { MdContentCopy } from 'react-icons/md';
|
|
|
11
11
|
import { BlankState } from './BlankState';
|
|
12
12
|
import { Link } from '../Link';
|
|
13
13
|
|
|
14
|
-
// eslint-disable-next-line max-len
|
|
15
14
|
const image =
|
|
15
|
+
// eslint-disable-next-line max-len
|
|
16
16
|
"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='79' height='79' viewBox='0 0 79 79' fill='none'%3E%3Cpath d='M66.3001 15.9C66.3001 15.9 66.3 15.8 66.2 15.8C66.1 15.7 66 15.5 65.9001 15.4C65.9001 15.4 65.9001 15.4 65.9001 15.3L44.4001 0.2C44.3001 0.0999998 44.2 0.0999994 44.1 0.0999994C44 0.0999994 44.0001 0 43.9001 0H43.3C43.2 0 43.1 0.0999994 43.1 0.0999994C43 0.0999994 42.9 0.2 42.8 0.2L28.2001 10.3C28.1 10.4 28.0001 10.5 27.9001 10.6C27.9001 10.6 27.9001 10.6 27.9001 10.7C27.8001 10.8 27.7001 11 27.7001 11.2C27.7001 11.2 27.7001 11.2 27.7001 11.3V31.1L13.9 40.8L13.7001 41C13.6001 41.1 13.6 41.1 13.6 41.2L13.5 41.3C13.5 41.4 13.4 41.5 13.4 41.5V41.6C13.4 41.7 13.3 41.8 13.3 42V62.2C13.3 62.4 13.3 62.6 13.4 62.7V62.8C13.5 62.9 13.6001 63.1 13.7001 63.2C13.7001 63.2 13.7 63.2 13.8 63.3L13.9 63.4L35.3 78.6H35.4001C35.4001 78.6 35.5 78.6 35.5 78.7H35.6C35.8 78.8 36 78.8 36.2001 78.8C36.3001 78.8 36.5 78.8 36.6 78.7H36.7001C36.8001 78.7 36.8001 78.7 36.9001 78.6C36.9001 78.6 37 78.6 37 78.5H37.1L66 58.3C66.1 58.2 66.2001 58.1 66.3001 58V15.9ZM34.6 74.5L16.1 61.3V44.7L34.6 57.8V74.5ZM36 55.3L17.2001 41.9L29 33.5L47.9001 46.9L36 55.3ZM49 44.1L30.5 31V14.4L49 27.5V44.1ZM50.5 24.9L31.6 11.5L43.5 3.2L62.4001 16.6L50.5 24.9Z' fill='%23BD9D70'/%3E%3C/svg%3E";
|
|
17
17
|
|
|
18
18
|
const defaultProps = {
|
|
@@ -23,37 +23,37 @@ const defaultProps = {
|
|
|
23
23
|
title: 'Power up your application',
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
describe('<BlankState />', () => {
|
|
27
|
-
it('renders the BlankState component', async () => {
|
|
28
|
-
const { container } = render(<BlankState {...defaultProps} />);
|
|
26
|
+
describe( '<BlankState />', () => {
|
|
27
|
+
it( 'renders the BlankState component', async () => {
|
|
28
|
+
const { container } = render( <BlankState { ...defaultProps } /> );
|
|
29
29
|
|
|
30
|
-
expect(screen.getByText(defaultProps.body)).toBeInTheDocument();
|
|
31
|
-
expect(screen.getByText(defaultProps.title)).toBeInTheDocument();
|
|
32
|
-
expect(screen.getByText('Explore add-ons →')).toBeInTheDocument();
|
|
33
|
-
expect(screen.getByAltText(defaultProps.imageAlt)).toBeInTheDocument();
|
|
30
|
+
expect( screen.getByText( defaultProps.body ) ).toBeInTheDocument();
|
|
31
|
+
expect( screen.getByText( defaultProps.title ) ).toBeInTheDocument();
|
|
32
|
+
expect( screen.getByText( 'Explore add-ons →' ) ).toBeInTheDocument();
|
|
33
|
+
expect( screen.getByAltText( defaultProps.imageAlt ) ).toBeInTheDocument();
|
|
34
34
|
|
|
35
35
|
// Check for accessibility issues
|
|
36
|
-
await expect(await axe(container)).toHaveNoViolations();
|
|
37
|
-
});
|
|
36
|
+
await expect( await axe( container ) ).toHaveNoViolations();
|
|
37
|
+
} );
|
|
38
38
|
|
|
39
|
-
it('renders the BlankState component with default alt text for the given image', async () => {
|
|
39
|
+
it( 'renders the BlankState component with default alt text for the given image', async () => {
|
|
40
40
|
const props = { ...defaultProps, imageAlt: undefined };
|
|
41
|
-
const { container } = render(<BlankState {...props} />);
|
|
41
|
+
const { container } = render( <BlankState { ...props } /> );
|
|
42
42
|
|
|
43
|
-
expect(screen.getByAltText('Image representing the blank state')).toBeInTheDocument();
|
|
43
|
+
expect( screen.getByAltText( 'Image representing the blank state' ) ).toBeInTheDocument();
|
|
44
44
|
|
|
45
45
|
// Check for accessibility issues
|
|
46
|
-
await expect(await axe(container)).toHaveNoViolations();
|
|
47
|
-
});
|
|
46
|
+
await expect( await axe( container ) ).toHaveNoViolations();
|
|
47
|
+
} );
|
|
48
48
|
|
|
49
|
-
it('renders the BlankState component with an icon', async () => {
|
|
49
|
+
it( 'renders the BlankState component with an icon', async () => {
|
|
50
50
|
const icon = <MdContentCopy title="this is an icon" />;
|
|
51
51
|
const props = { ...defaultProps, icon };
|
|
52
|
-
const { container } = render(<BlankState {...props} />);
|
|
52
|
+
const { container } = render( <BlankState { ...props } /> );
|
|
53
53
|
|
|
54
|
-
expect(screen.getByTitle('this is an icon')).toBeInTheDocument();
|
|
54
|
+
expect( screen.getByTitle( 'this is an icon' ) ).toBeInTheDocument();
|
|
55
55
|
|
|
56
56
|
// Check for accessibility issues
|
|
57
|
-
await expect(await axe(container)).toHaveNoViolations();
|
|
58
|
-
});
|
|
59
|
-
});
|
|
57
|
+
await expect( await axe( container ) ).toHaveNoViolations();
|
|
58
|
+
} );
|
|
59
|
+
} );
|