@automattic/vip-design-system 0.10.3 → 0.12.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.
Files changed (141) hide show
  1. package/.eslines.json +8 -8
  2. package/.eslintrc.json +9 -4
  3. package/.github/PULL_REQUEST_TEMPLATE.md +1 -1
  4. package/.github/workflows/nodejs.yaml +14 -14
  5. package/.prettierrc +1 -2
  6. package/.storybook/main.js +2 -1
  7. package/.storybook/preview.js +5 -8
  8. package/README.md +1 -0
  9. package/babel.config.js +1 -1
  10. package/build/system/Avatar/Avatar.js +2 -1
  11. package/build/system/BlankState/BlankState.stories.js +3 -3
  12. package/build/system/BlankState/BlankState.test.js +2 -2
  13. package/build/system/Card/Card.test.js +0 -2
  14. package/build/system/Code/Code.js +7 -2
  15. package/build/system/Code/Code.test.js +22 -57
  16. package/build/system/Form/Select.stories.js +3 -4
  17. package/build/system/Form/Select.test.js +2 -2
  18. package/build/system/Form/Toggle.js +45 -72
  19. package/build/system/Form/Toggle.stories.js +63 -0
  20. package/build/system/Form/Toggle.test.js +55 -0
  21. package/build/system/Notification/Notification.js +24 -15
  22. package/build/system/Notification/Notification.stories.js +14 -4
  23. package/build/system/OptionRow/OptionRow.js +23 -17
  24. package/build/system/OptionRow/OptionRow.stories.js +5 -5
  25. package/build/system/OptionRow/OptionRow.test.js +4 -4
  26. package/build/system/ResourceList/ResourceList.js +34 -25
  27. package/build/system/ResourceList/ResourceList.stories.js +2 -0
  28. package/build/system/ScreenReaderText/ScreenReader.test.js +37 -0
  29. package/build/system/ScreenReaderText/ScreenReaderText.js +49 -0
  30. package/build/system/ScreenReaderText/index.js +7 -0
  31. package/build/system/Table/Table.stories.js +46 -3
  32. package/build/system/Table/TableCell.js +57 -0
  33. package/build/system/Table/TableRow.js +12 -57
  34. package/build/system/Table/index.js +5 -1
  35. package/build/system/Time/index.js +1 -1
  36. package/build/system/Wizard/Wizard.stories.js +1 -1
  37. package/build/system/index.js +1 -0
  38. package/package.json +10 -4
  39. package/src/system/Avatar/Avatar.js +1 -0
  40. package/src/system/Avatar/index.js +0 -1
  41. package/src/system/Badge/index.js +0 -1
  42. package/src/system/BlankState/BlankState.js +8 -5
  43. package/src/system/BlankState/BlankState.stories.jsx +5 -4
  44. package/src/system/BlankState/BlankState.test.js +21 -21
  45. package/src/system/BlankState/index.js +0 -1
  46. package/src/system/Box/Box.js +7 -1
  47. package/src/system/Box/index.js +0 -1
  48. package/src/system/Button/Button.js +3 -3
  49. package/src/system/Button/Button.stories.jsx +2 -2
  50. package/src/system/Button/index.js +0 -1
  51. package/src/system/Card/Card.js +4 -4
  52. package/src/system/Card/Card.test.js +1 -2
  53. package/src/system/Card/index.js +0 -1
  54. package/src/system/Code/Code.js +6 -2
  55. package/src/system/Code/Code.stories.jsx +10 -5
  56. package/src/system/Code/Code.test.js +3 -16
  57. package/src/system/ConfirmationDialog/ConfirmationDialog.js +8 -1
  58. package/src/system/Dialog/Dialog.js +17 -8
  59. package/src/system/Dialog/Dialog.stories.jsx +9 -13
  60. package/src/system/Dialog/DialogButton.js +18 -14
  61. package/src/system/Dialog/DialogDivider.js +1 -1
  62. package/src/system/Dialog/DialogMenu.js +1 -5
  63. package/src/system/Dialog/DialogMenuItem.js +4 -8
  64. package/src/system/Dialog/DialogTrigger.js +1 -1
  65. package/src/system/Dialog/index.js +0 -1
  66. package/src/system/Flex/Flex.js +1 -1
  67. package/src/system/Flex/index.js +0 -1
  68. package/src/system/Form/AsyncSearchSelect.js +3 -7
  69. package/src/system/Form/Checkbox.js +32 -28
  70. package/src/system/Form/InlineSelect.js +21 -17
  71. package/src/system/Form/Input.js +43 -45
  72. package/src/system/Form/Label.js +2 -2
  73. package/src/system/Form/RadioBoxGroup.js +34 -32
  74. package/src/system/Form/RadioBoxGroup.stories.jsx +8 -1
  75. package/src/system/Form/SearchSelect.js +7 -7
  76. package/src/system/Form/Select.js +21 -2
  77. package/src/system/Form/Select.stories.jsx +31 -34
  78. package/src/system/Form/Select.test.js +3 -8
  79. package/src/system/Form/Textarea.js +38 -40
  80. package/src/system/Form/Toggle.js +37 -65
  81. package/src/system/Form/Toggle.stories.jsx +42 -0
  82. package/src/system/Form/Toggle.test.js +23 -0
  83. package/src/system/Form/ToggleGroup.js +29 -31
  84. package/src/system/Form/ToggleGroup.stories.jsx +8 -1
  85. package/src/system/Form/ToggleRow.js +6 -1
  86. package/src/system/Form/Validation.js +6 -1
  87. package/src/system/Form/index.js +13 -1
  88. package/src/system/Grid/Grid.js +1 -1
  89. package/src/system/Grid/index.js +0 -1
  90. package/src/system/Heading/Heading.js +4 -4
  91. package/src/system/Heading/index.js +0 -1
  92. package/src/system/Link/index.js +0 -1
  93. package/src/system/Notice/Notice.js +27 -13
  94. package/src/system/Notice/Notice.stories.jsx +6 -8
  95. package/src/system/Notice/index.js +0 -1
  96. package/src/system/Notification/Notification.js +25 -20
  97. package/src/system/Notification/Notification.stories.jsx +4 -4
  98. package/src/system/Notification/index.js +0 -1
  99. package/src/system/OptionRow/OptionRow.js +46 -44
  100. package/src/system/OptionRow/OptionRow.stories.jsx +10 -8
  101. package/src/system/OptionRow/OptionRow.test.js +12 -11
  102. package/src/system/OptionRow/index.js +0 -1
  103. package/src/system/Progress/Progress.js +3 -1
  104. package/src/system/Progress/Progress.stories.jsx +4 -4
  105. package/src/system/Progress/index.js +0 -1
  106. package/src/system/ResourceList/ResourceItem.js +15 -15
  107. package/src/system/ResourceList/ResourceList.js +28 -16
  108. package/src/system/ResourceList/ResourceList.stories.jsx +77 -71
  109. package/src/system/ScreenReaderText/ScreenReader.test.js +22 -0
  110. package/src/system/ScreenReaderText/ScreenReaderText.js +40 -0
  111. package/src/system/ScreenReaderText/index.js +7 -0
  112. package/src/system/Spinner/Spinner.js +4 -4
  113. package/src/system/Spinner/index.js +0 -1
  114. package/src/system/Table/Table.js +5 -5
  115. package/src/system/Table/Table.stories.jsx +39 -9
  116. package/src/system/Table/TableCell.js +48 -0
  117. package/src/system/Table/TableRow.js +10 -47
  118. package/src/system/Table/index.js +2 -2
  119. package/src/system/Tabs/Tabs.js +3 -3
  120. package/src/system/Tabs/index.js +0 -1
  121. package/src/system/Text/Text.js +3 -3
  122. package/src/system/Text/Text.stories.jsx +4 -6
  123. package/src/system/Text/index.js +0 -1
  124. package/src/system/Time/Time.stories.jsx +2 -6
  125. package/src/system/Time/index.js +5 -5
  126. package/src/system/Timeline/Timeline.js +6 -12
  127. package/src/system/Timeline/Timeline.stories.jsx +3 -12
  128. package/src/system/Timeline/index.js +0 -1
  129. package/src/system/Tooltip/Tooltip.js +4 -8
  130. package/src/system/Wizard/Wizard.js +23 -21
  131. package/src/system/Wizard/Wizard.stories.jsx +7 -12
  132. package/src/system/Wizard/WizardStep.js +8 -8
  133. package/src/system/Wizard/WizardStepHorizontal.js +4 -4
  134. package/src/system/Wizard/index.js +0 -1
  135. package/src/system/index.js +2 -1
  136. package/src/system/theme/index.js +3 -4
  137. package/tokens/valet-color.json +1919 -0
  138. package/build/system/Form/MultiSelect.js +0 -38
  139. package/build/system/UsageChart/UsageChart.js +0 -60
  140. package/build/system/UsageChart/UsageChart.stories.js +0 -20
  141. package/build/system/UsageChart/index.js +0 -7
@@ -7,7 +7,7 @@ exports.TableRow = void 0;
7
7
 
8
8
  var _propTypes = _interopRequireDefault(require("prop-types"));
9
9
 
10
- var _ = require("../");
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$rowHead = _ref.rowHead,
28
- rowHead = _ref$rowHead === void 0 ? false : _ref$rowHead,
29
- cells = _ref.cells;
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.jsx)("tr", {
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
- isRowHead: index === 0 && rowHead
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
- rowHead: _propTypes["default"].bool
61
+ children: _propTypes["default"].node,
62
+ head: _propTypes["default"].bool,
63
+ onClick: _propTypes["default"].func
109
64
  };
@@ -8,4 +8,8 @@ exports.Table = _Table.Table;
8
8
 
9
9
  var _TableRow = require("./TableRow");
10
10
 
11
- exports.TableRow = _TableRow.TableRow;
11
+ exports.TableRow = _TableRow.TableRow;
12
+
13
+ var _TableCell = require("./TableCell");
14
+
15
+ exports.TableCell = _TableCell.TableCell;
@@ -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"].instanceOf(Date)]),
92
92
  timeOnly: _propTypes["default"].bool,
93
93
  relativeTime: _propTypes["default"].bool,
94
94
  className: _propTypes["default"].any
@@ -61,7 +61,7 @@ var Default = function Default() {
61
61
  alignItems: 'center',
62
62
  mb: 1
63
63
  },
64
- children: ["Add Domain:", ' ', (0, _jsxRuntime.jsx)("span", {
64
+ children: ["Add Domain: ", (0, _jsxRuntime.jsx)("span", {
65
65
  sx: {
66
66
  color: 'muted',
67
67
  ml: 2
@@ -117,6 +117,7 @@ var _Table = require("./Table");
117
117
 
118
118
  exports.Table = _Table.Table;
119
119
  exports.TableRow = _Table.TableRow;
120
+ exports.TableCell = _Table.TableCell;
120
121
 
121
122
  var _Tabs = require("./Tabs");
122
123
 
package/package.json CHANGED
@@ -1,15 +1,16 @@
1
1
  {
2
2
  "name": "@automattic/vip-design-system",
3
- "version": "0.10.3",
3
+ "version": "0.12.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": "eslint . --fix",
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 . -f json | eslines --quiet",
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",
@@ -18,6 +19,7 @@
18
19
  "dependencies": {
19
20
  "@radix-ui/react-checkbox": "^0.1.0",
20
21
  "@radix-ui/react-radio-group": "^0.1.0",
22
+ "@radix-ui/react-switch": "^0.1.5",
21
23
  "@radix-ui/react-tooltip": "^0.1.0",
22
24
  "babel-loader": "^8.2.2",
23
25
  "classnames": "^2.3.1",
@@ -82,6 +84,7 @@
82
84
  "@mdx-js/react": "^2.1.1",
83
85
  "@storybook/addon-a11y": "^6.5.9",
84
86
  "@storybook/addon-actions": "^6.5.9",
87
+ "@storybook/addon-controls": "^6.5.9",
85
88
  "@storybook/addon-essentials": "^6.5.9",
86
89
  "@storybook/addon-links": "^6.5.9",
87
90
  "@storybook/react": "^6.5.9",
@@ -92,12 +95,14 @@
92
95
  "cross-env": "^7.0.3",
93
96
  "eslines": "2.1.0",
94
97
  "eslint": "7.32.0",
98
+ "eslint-config-prettier": "^8.5.0",
95
99
  "eslint-config-react-app": "6.0.0",
96
- "eslint-config-wpvip": "automattic/eslint-config-wpvip#c6605d1c3a545d43ac2149cd464ec3c38ebc58d5",
100
+ "eslint-config-wpvip": "github:automattic/eslint-config-wpvip#b73cd84",
97
101
  "eslint-plugin-jest": "24.4.2",
98
102
  "eslint-plugin-json": "3.1.0",
99
103
  "eslint-plugin-jsx-a11y": "6.4.1",
100
104
  "eslint-plugin-no-async-foreach": "0.1.1",
105
+ "eslint-plugin-prettier": "^4.2.1",
101
106
  "eslint-plugin-react": "7.25.3",
102
107
  "eslint-plugin-storybook": "^0.5.12",
103
108
  "eslint-plugin-wpcalypso": "4.1.0",
@@ -109,6 +114,7 @@
109
114
  "jsdom-global": "3.0.2",
110
115
  "open-cli": "^7.0.1",
111
116
  "optimize-css-assets-webpack-plugin": "^6.0.1",
117
+ "prettier": "npm:wp-prettier@^2.6.2",
112
118
  "react": "^17.0.2",
113
119
  "react-dom": "^17.0.2",
114
120
  "react-input-autosize": "^3.0.0",
@@ -37,6 +37,7 @@ const Avatar = ( {
37
37
  textAlign: 'center',
38
38
  } }
39
39
  className={ classNames( 'vip-avatar-component', className ) }
40
+ aria-hidden="true"
40
41
  { ...props }
41
42
  >
42
43
  { src ? (
@@ -1,4 +1,3 @@
1
-
2
1
  /**
3
2
  * Internal dependencies
4
3
  */
@@ -1,4 +1,3 @@
1
-
2
1
  /**
3
2
  * Internal dependencies
4
3
  */
@@ -21,11 +21,14 @@ const BlankState = ( {
21
21
  className = null,
22
22
  } ) => {
23
23
  return (
24
- <Box sx={{ textAlign: 'center', padding: 5 }} className={ classNames( 'vip-blank-state-component', className ) }>
25
- {icon ? icon : <img src={image} sx={{ mb: 3 }} alt={imageAlt} />}
26
- <Heading variant="h4">{title}</Heading>
27
- <Text>{body}</Text>
28
- <Box sx={{ mt: 3 }}>{cta}</Box>
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
- // eslint-disable-next-line max-len
12
- const image2 = "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";
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
+ } );
@@ -1,4 +1,3 @@
1
-
2
1
  /**
3
2
  * Internal dependencies
4
3
  */
@@ -8,7 +8,13 @@ import classNames from 'classnames';
8
8
  import { forwardRef } from 'react';
9
9
  import { Box as ThemeBox } from 'theme-ui';
10
10
 
11
- const Box = forwardRef( ( props, ref ) => <ThemeBox ref={ref} className={ classNames( 'vip-box-component', props.className ) } {...props} /> );
11
+ const Box = forwardRef( ( props, ref ) => (
12
+ <ThemeBox
13
+ ref={ ref }
14
+ className={ classNames( 'vip-box-component', props.className ) }
15
+ { ...props }
16
+ />
17
+ ) );
12
18
 
13
19
  Box.displayName = 'Box';
14
20
  Box.propTypes = {
@@ -1,4 +1,3 @@
1
-
2
1
  /**
3
2
  * Internal dependencies
4
3
  */
@@ -9,7 +9,7 @@ import classNames from 'classnames';
9
9
 
10
10
  const Button = ( { sx, ...props } ) => (
11
11
  <ThemeButton
12
- sx={{
12
+ sx={ {
13
13
  verticalAlign: 'middle',
14
14
  display: 'inline-flex',
15
15
  alignItems: 'center',
@@ -22,9 +22,9 @@ const Button = ( { sx, ...props } ) => (
22
22
  pointerEvents: 'all',
23
23
  },
24
24
  ...sx,
25
- }}
25
+ } }
26
26
  className={ classNames( 'vip-button-component', props.className ) }
27
- {...props}
27
+ { ...props }
28
28
  />
29
29
  );
30
30
 
@@ -15,8 +15,8 @@ export default {
15
15
 
16
16
  export const Default = () => (
17
17
  <React.Fragment>
18
- <Button sx={{ mr: 2 }}>Primary</Button>
19
- <Button variant="secondary" sx={{ ml: 2 }}>
18
+ <Button sx={ { mr: 2 } }>Primary</Button>
19
+ <Button variant="secondary" sx={ { ml: 2 } }>
20
20
  Secondary
21
21
  </Button>
22
22
  </React.Fragment>
@@ -1,4 +1,3 @@
1
-
2
1
  /**
3
2
  * Internal dependencies
4
3
  */
@@ -15,15 +15,15 @@ import classNames from 'classnames';
15
15
  const Card = React.forwardRef( ( { variant = 'primary', sx = {}, className, ...props }, ref ) => {
16
16
  return (
17
17
  <Box
18
- ref={ref}
19
- sx={{
18
+ ref={ ref }
19
+ sx={ {
20
20
  // pass variant prop to sx
21
21
  variant: `cards.${ variant }`,
22
22
  overflow: 'hidden',
23
23
  ...sx,
24
- }}
24
+ } }
25
25
  className={ classNames( 'vip-card-component', className ) }
26
- {...props}
26
+ { ...props }
27
27
  />
28
28
  );
29
29
  } );
@@ -1,9 +1,8 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { render, screen, fireEvent, waitFor } from '@testing-library/react';
4
+ import { render, screen } from '@testing-library/react';
5
5
  import { axe } from 'jest-axe';
6
- import { MdContentCopy } from 'react-icons/md';
7
6
 
8
7
  /**
9
8
  * Internal dependencies
@@ -1,4 +1,3 @@
1
-
2
1
  /**
3
2
  * Internal dependencies
4
3
  */
@@ -50,7 +50,7 @@ const Code = ( { prompt = false, showCopy = false, onCopy = null, className, ...
50
50
  { codeDom }
51
51
  {
52
52
  <button
53
- aria-label="Copy"
53
+ aria-label="Copy code"
54
54
  sx={ {
55
55
  bg: 'grey.10',
56
56
  borderTopRightRadius: 1,
@@ -79,7 +79,11 @@ const Code = ( { prompt = false, showCopy = false, onCopy = null, className, ...
79
79
  }
80
80
  } }
81
81
  >
82
- { copied ? 'Copied!' : <MdContentCopy /> }
82
+ { copied ? (
83
+ <span role="alert">Code copied to clipboard</span>
84
+ ) : (
85
+ <MdContentCopy aria-hidden="true" />
86
+ ) }
83
87
  </button>
84
88
  }
85
89
  </div>
@@ -17,11 +17,16 @@ export const Default = () => (
17
17
  <React.Fragment>
18
18
  <Code>Code</Code>
19
19
  <br />
20
- <Code showCopy={true}>Code with Icon</Code>
20
+ <Code showCopy={ true }>Code with Icon</Code>
21
21
  <br />
22
- <Code showCopy={true} onCopy={
23
- // eslint-disable-next-line no-console
24
- () => console.info( 'Hello world' )
25
- }>Code with Icon and Click callback — console.info</Code>
22
+ <Code
23
+ showCopy={ true }
24
+ onCopy={
25
+ // eslint-disable-next-line no-console
26
+ () => console.info( 'Hello world' )
27
+ }
28
+ >
29
+ Code with Icon and Click callback — console.info
30
+ </Code>
26
31
  </React.Fragment>
27
32
  );
@@ -3,7 +3,6 @@
3
3
  */
4
4
  import { render, screen, fireEvent, waitFor } from '@testing-library/react';
5
5
  import { axe } from 'jest-axe';
6
- import { MdContentCopy } from 'react-icons/md';
7
6
 
8
7
  /**
9
8
  * Internal dependencies
@@ -31,23 +30,11 @@ describe( '<Code />', () => {
31
30
  await expect( await axe( container ) ).toHaveNoViolations();
32
31
  } );
33
32
 
34
- // jsdom currently doesn't support pseudo-elements with getComputedStyle
35
- it.skip( 'renders "$" in front of the code when in prompt mode', async () => {
36
- const props = { ...defaultProps, prompt: true };
37
- const { container } = render( <Code { ...props }>This is a code</Code> );
38
- const codeElement = screen.getByText( 'This is a code' );
39
-
40
- expect( window.getComputedStyle( codeElement, ':before' ).content ).toEqual( '$' );
41
-
42
- // Check for accessibility issues
43
- await expect( await axe( container ) ).toHaveNoViolations();
44
- } );
45
-
46
33
  it( 'renders the Code component with a copy button', async () => {
47
34
  const props = { ...defaultProps, showCopy: true };
48
35
  const { container } = render( <Code { ...props }>This is a code</Code> );
49
36
 
50
- expect( screen.getByRole( 'button', { name: 'Copy' } ) ).toBeInTheDocument();
37
+ expect( screen.getByRole( 'button', { name: 'Copy code' } ) ).toBeInTheDocument();
51
38
 
52
39
  // Check for accessibility issues
53
40
  await expect( await axe( container ) ).toHaveNoViolations();
@@ -57,11 +44,11 @@ describe( '<Code />', () => {
57
44
  const props = { ...defaultProps, showCopy: true };
58
45
  const { container } = render( <Code { ...props }>This is a code</Code> );
59
46
 
60
- fireEvent.click( screen.getByRole( 'button', { name: 'Copy' } ) );
47
+ fireEvent.click( screen.getByRole( 'button', { name: 'Copy code' } ) );
61
48
 
62
49
  await waitFor( () => new Promise( res => setTimeout( res, 0 ) ) );
63
50
 
64
- expect( screen.getByText( 'Copied!' ) ).toBeInTheDocument();
51
+ expect( screen.getByText( 'Code copied to clipboard' ) ).toBeInTheDocument();
65
52
 
66
53
  // Check for accessibility issues
67
54
  await expect( await axe( container ) ).toHaveNoViolations();
@@ -12,7 +12,14 @@ import React from 'react';
12
12
  */
13
13
  import { Dialog, Box, Heading, Text, Flex, Button } from '../';
14
14
 
15
- const ConfirmationDialogContent = ( { title, body, onClose, label = 'Confirm', onConfirm, className = null } ) => (
15
+ const ConfirmationDialogContent = ( {
16
+ title,
17
+ body,
18
+ onClose,
19
+ label = 'Confirm',
20
+ onConfirm,
21
+ className = null,
22
+ } ) => (
16
23
  <Box p={ 4 } className={ classNames( 'vip-confirmation-dialog-component', className ) }>
17
24
  <Heading variant="h3" sx={ { mb: 2 } }>
18
25
  { title }
@@ -8,11 +8,18 @@ import PropTypes from 'prop-types';
8
8
  import { useEffect, useRef, useState } from 'react';
9
9
 
10
10
  /**
11
- * Internal dependencies
12
- */
11
+ * Internal dependencies
12
+ */
13
13
  import { DialogContent, DialogTrigger } from '.';
14
14
 
15
- const Dialog = ( { trigger, position = 'left', startOpen = false, content, disabled = false, ...props } ) => {
15
+ const Dialog = ( {
16
+ trigger,
17
+ position = 'left',
18
+ startOpen = false,
19
+ content,
20
+ disabled = false,
21
+ ...props
22
+ } ) => {
16
23
  const [ isOpen, setIsOpen ] = useState( startOpen );
17
24
  const dialogRef = useRef( null );
18
25
 
@@ -46,7 +53,12 @@ const Dialog = ( { trigger, position = 'left', startOpen = false, content, disab
46
53
  };
47
54
 
48
55
  return (
49
- <div onClick={ e => e.stopPropagation() } sx={ { position: 'relative' } } ref={ dialogRef } className="vip-dialog-component">
56
+ <div
57
+ onClick={ e => e.stopPropagation() }
58
+ sx={ { position: 'relative' } }
59
+ ref={ dialogRef }
60
+ className="vip-dialog-component"
61
+ >
50
62
  <DialogTrigger
51
63
  tabIndex="0"
52
64
  sx={ { display: 'inline' } }
@@ -73,10 +85,7 @@ Dialog.propTypes = {
73
85
  disabled: PropTypes.bool,
74
86
  position: PropTypes.string,
75
87
  startOpen: PropTypes.bool,
76
- content: PropTypes.oneOfType( [
77
- PropTypes.node,
78
- PropTypes.func,
79
- ] ),
88
+ content: PropTypes.oneOfType( [ PropTypes.node, PropTypes.func ] ),
80
89
  };
81
90
 
82
91
  export { Dialog };
@@ -19,7 +19,7 @@ export default {
19
19
  };
20
20
 
21
21
  const DropdownTrigger = <Button>Trigger Dropdown</Button>;
22
- const ModalTrigger = <Button sx={{ mr: 3 }}>Trigger Modal</Button>;
22
+ const ModalTrigger = <Button sx={ { mr: 3 } }>Trigger Modal</Button>;
23
23
 
24
24
  const DropdownContent = (
25
25
  <div>
@@ -36,11 +36,11 @@ const DropdownContent = (
36
36
  );
37
37
 
38
38
  const ModalContent = (
39
- <Box p={5}>
39
+ <Box p={ 5 }>
40
40
  <Heading>This is a Modal</Heading>
41
- <Text sx={{ fontSize: 3 }}>
42
- A modal is used to perform more detailed actions that don&lsquo;t
43
- necessarily need the context behind.
41
+ <Text sx={ { fontSize: 3 } }>
42
+ A modal is used to perform more detailed actions that don&lsquo;t necessarily need the context
43
+ behind.
44
44
  </Text>
45
45
  </Box>
46
46
  );
@@ -49,16 +49,12 @@ export const Default = () => (
49
49
  <Flex>
50
50
  <Box>
51
51
  <Dialog
52
- trigger={ModalTrigger}
53
- content={ModalContent}
54
- sx={{ width: 480 }}
52
+ trigger={ ModalTrigger }
53
+ content={ ModalContent }
54
+ sx={ { width: 480 } }
55
55
  variant="modal"
56
56
  />
57
57
  </Box>
58
- <Dialog
59
- trigger={DropdownTrigger}
60
- content={DropdownContent}
61
- sx={{ width: 200 }}
62
- />
58
+ <Dialog trigger={ DropdownTrigger } content={ DropdownContent } sx={ { width: 200 } } />
63
59
  </Flex>
64
60
  );