@automattic/vip-design-system 0.9.2 → 0.9.5

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 (63) hide show
  1. package/build/system/Avatar/Avatar.stories.js +23 -8
  2. package/build/system/Avatar/Avatar.test.js +41 -22
  3. package/build/system/Badge/Badge.stories.js +25 -8
  4. package/build/system/Badge/Badge.test.js +73 -0
  5. package/build/system/BlankState/BlankState.js +12 -9
  6. package/build/system/BlankState/BlankState.stories.js +27 -11
  7. package/build/system/BlankState/BlankState.test.js +124 -0
  8. package/build/system/Box/Box.stories.js +25 -8
  9. package/build/system/Button/Button.stories.js +36 -23
  10. package/build/system/Button/Button.test.js +44 -0
  11. package/build/system/Card/Card.stories.js +25 -8
  12. package/build/system/Card/Card.test.js +78 -0
  13. package/build/system/Code/Code.js +11 -8
  14. package/build/system/Code/Code.stories.js +25 -8
  15. package/build/system/Code/Code.test.js +167 -0
  16. package/build/system/ConfirmationDialog/ConfirmationDialog.stories.js +45 -22
  17. package/build/system/Dialog/Dialog.stories.js +71 -31
  18. package/build/system/Dialog/DialogContent.js +3 -1
  19. package/build/system/Flex/Flex.stories.js +25 -8
  20. package/build/system/Form/AsyncSearchSelect.js +38 -0
  21. package/build/system/Form/Input.js +2 -2
  22. package/build/system/Form/Input.stories.js +23 -8
  23. package/build/system/Form/SearchSelect.js +47 -11
  24. package/build/system/Form/Select.js +48 -12
  25. package/build/system/Form/Select.stories.js +108 -78
  26. package/build/system/Form/Select.test.js +52 -0
  27. package/build/system/Grid/Grid.stories.js +25 -8
  28. package/build/system/Heading/Heading.stories.js +43 -20
  29. package/build/system/Link/Link.stories.js +26 -10
  30. package/build/system/Notice/Notice.stories.js +47 -81
  31. package/build/system/Notification/Notification.stories.js +23 -8
  32. package/build/system/OptionRow/OptionRow.stories.js +36 -20
  33. package/build/system/Progress/Progress.stories.js +23 -8
  34. package/build/system/Spinner/Spinner.stories.js +23 -8
  35. package/build/system/Table/Table.stories.js +64 -42
  36. package/build/system/Tabs/Tabs.stories.js +32 -10
  37. package/build/system/Text/Text.stories.js +25 -8
  38. package/build/system/Timeline/Timeline.js +69 -0
  39. package/build/system/Timeline/Timeline.stories.js +44 -21
  40. package/build/system/Timeline/index.js +2 -66
  41. package/build/system/Tooltip/Tooltip.stories.js +41 -19
  42. package/build/system/Wizard/Wizard.stories.js +65 -37
  43. package/package.json +17 -5
  44. package/src/system/Avatar/Avatar.test.js +9 -10
  45. package/src/system/Badge/Badge.test.js +30 -0
  46. package/src/system/BlankState/BlankState.js +13 -5
  47. package/src/system/BlankState/BlankState.test.js +58 -0
  48. package/src/system/Button/Button.test.js +21 -0
  49. package/src/system/Card/Card.test.js +33 -0
  50. package/src/system/Code/Code.js +12 -9
  51. package/src/system/Code/Code.stories.js +2 -0
  52. package/src/system/Code/Code.test.js +69 -0
  53. package/src/system/Dialog/DialogContent.js +2 -0
  54. package/src/system/Form/AsyncSearchSelect.js +29 -0
  55. package/src/system/Form/Input.js +2 -2
  56. package/src/system/Form/SearchSelect.js +43 -3
  57. package/src/system/Form/Select.js +29 -6
  58. package/src/system/Form/Select.stories.js +82 -24
  59. package/src/system/Form/Select.test.js +37 -0
  60. package/src/system/Timeline/Timeline.js +46 -0
  61. package/src/system/Timeline/Timeline.stories.js +34 -0
  62. package/src/system/Timeline/index.js +2 -41
  63. package/build/system/UsageChart/UsageChart.stories.js +0 -20
@@ -1,29 +1,52 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.Default = exports["default"] = void 0;
5
+
6
+ var _react = _interopRequireDefault(require("react"));
7
+
8
+ var _ = require("..");
9
+
10
+ var _jsxRuntime = require("theme-ui/jsx-runtime");
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
13
+
1
14
  /**
2
15
  * External dependencies
3
16
  */
4
- import React from 'react';
17
+
5
18
  /**
6
19
  * Internal dependencies
7
20
  */
8
-
9
- import { Timeline, Grid, Box } from '..';
10
- export default {
21
+ var _default = {
11
22
  title: 'Timeline',
12
- component: Timeline
23
+ component: _.Timeline
13
24
  };
14
- export var Default = function Default() {
15
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Grid, {
16
- gap: 2,
17
- columns: [2, '100px 300px'],
18
- sx: {
19
- mb: '20px'
20
- }
21
- }, /*#__PURE__*/React.createElement(Timeline, {
22
- time: "7pm"
23
- }), /*#__PURE__*/React.createElement(Box, null, "It looks like everything is recovered now. You can forget about the last event.")), /*#__PURE__*/React.createElement(Grid, {
24
- gap: 2,
25
- columns: [2, '100px 200px']
26
- }, /*#__PURE__*/React.createElement(Timeline, {
27
- time: "6pm"
28
- }), /*#__PURE__*/React.createElement(Box, null, "At this particular moment in the day, something happened with your environment.")));
29
- };
25
+ exports["default"] = _default;
26
+
27
+ var Default = function Default() {
28
+ return (0, _jsxRuntime.jsxs)(_react["default"].Fragment, {
29
+ children: [(0, _jsxRuntime.jsxs)(_.Grid, {
30
+ gap: 2,
31
+ columns: [2, '100px 300px'],
32
+ sx: {
33
+ mb: '20px'
34
+ },
35
+ children: [(0, _jsxRuntime.jsx)(_.Timeline, {
36
+ time: "7pm"
37
+ }), (0, _jsxRuntime.jsx)(_.Box, {
38
+ children: "It looks like everything is recovered now. You can forget about the last event."
39
+ })]
40
+ }), (0, _jsxRuntime.jsxs)(_.Grid, {
41
+ gap: 2,
42
+ columns: [2, '100px 200px'],
43
+ children: [(0, _jsxRuntime.jsx)(_.Timeline, {
44
+ time: "6pm"
45
+ }), (0, _jsxRuntime.jsx)(_.Box, {
46
+ children: "At this particular moment in the day, something happened with your environment."
47
+ })]
48
+ })]
49
+ });
50
+ };
51
+
52
+ exports.Default = Default;
@@ -1,71 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  exports.__esModule = true;
4
- exports.Timeline = void 0;
5
4
 
6
- var _themeUi = require("theme-ui");
5
+ var _Timeline = require("./Timeline");
7
6
 
8
- var _md = require("react-icons/md");
9
-
10
- var _propTypes = _interopRequireDefault(require("prop-types"));
11
-
12
- var _jsxRuntime = require("theme-ui/jsx-runtime");
13
-
14
- var _excluded = ["time", "first", "last"];
15
-
16
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
17
-
18
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
19
-
20
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
21
-
22
- var VerticalLine = function VerticalLine() {
23
- return (0, _jsxRuntime.jsx)("div", {
24
- sx: {
25
- borderLeft: '2px solid',
26
- borderColor: 'border',
27
- height: 'calc( 50% - 16px )',
28
- borderRadius: '2px'
29
- }
30
- });
31
- };
32
-
33
- var Timeline = function Timeline(_ref) {
34
- var time = _ref.time,
35
- _ref$first = _ref.first,
36
- first = _ref$first === void 0 ? false : _ref$first,
37
- _ref$last = _ref.last,
38
- last = _ref$last === void 0 ? false : _ref$last,
39
- props = _objectWithoutPropertiesLoose(_ref, _excluded);
40
-
41
- return (0, _jsxRuntime.jsxs)(_themeUi.Flex, _extends({}, props, {
42
- children: [(0, _jsxRuntime.jsxs)(_themeUi.Flex, {
43
- sx: {
44
- flexDirection: 'column',
45
- justifyContent: 'space-evenly',
46
- alignItems: 'center'
47
- },
48
- children: [!first && (0, _jsxRuntime.jsx)(VerticalLine, {}), (0, _jsxRuntime.jsx)(_md.MdWatchLater, {
49
- sx: {
50
- color: 'border'
51
- },
52
- size: 18
53
- }), !last && (0, _jsxRuntime.jsx)(VerticalLine, {})]
54
- }), (0, _jsxRuntime.jsx)(_themeUi.Flex, {
55
- sx: {
56
- alignItems: 'center',
57
- ml: 2
58
- },
59
- children: (0, _jsxRuntime.jsx)("span", {
60
- children: time
61
- })
62
- })]
63
- }));
64
- };
65
-
66
- exports.Timeline = Timeline;
67
- Timeline.propTypes = {
68
- first: _propTypes["default"].bool,
69
- time: _propTypes["default"].string,
70
- last: _propTypes["default"].bool
71
- };
7
+ exports.Timeline = _Timeline.Timeline;
@@ -1,29 +1,51 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.Default = exports["default"] = void 0;
5
+
6
+ var _react = _interopRequireDefault(require("react"));
7
+
8
+ var _ = require("..");
9
+
10
+ var _jsxRuntime = require("theme-ui/jsx-runtime");
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
13
+
1
14
  /**
2
15
  * External dependencies
3
16
  */
4
- import React from 'react';
17
+
5
18
  /**
6
19
  * Internal dependencies
7
20
  */
8
-
9
- import { Flex, Heading, Tooltip, Text, Link } from '..';
10
- export default {
21
+ var _default = {
11
22
  title: 'Tooltip',
12
- component: Tooltip
23
+ component: _.Tooltip
13
24
  };
14
- export var Default = function Default() {
15
- return /*#__PURE__*/React.createElement(Flex, {
25
+ exports["default"] = _default;
26
+
27
+ var Default = function Default() {
28
+ return (0, _jsxRuntime.jsxs)(_.Flex, {
16
29
  sx: {
17
30
  alignItems: 'center'
18
- }
19
- }, /*#__PURE__*/React.createElement(Heading, {
20
- sx: {
21
- mb: 0,
22
- mr: 2
23
- }
24
- }, "My Section Heading"), /*#__PURE__*/React.createElement(Tooltip, null, /*#__PURE__*/React.createElement(Text, {
25
- sx: {
26
- fontSize: 1
27
- }
28
- }, "This is a tooltip that can be used to describe various pieces of functionality.", /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement(Link, null, "Find out more \u2192"))));
29
- };
31
+ },
32
+ children: [(0, _jsxRuntime.jsx)(_.Heading, {
33
+ sx: {
34
+ mb: 0,
35
+ mr: 2
36
+ },
37
+ children: "My Section Heading"
38
+ }), (0, _jsxRuntime.jsx)(_.Tooltip, {
39
+ children: (0, _jsxRuntime.jsxs)(_.Text, {
40
+ sx: {
41
+ fontSize: 1
42
+ },
43
+ children: ["This is a tooltip that can be used to describe various pieces of functionality.", (0, _jsxRuntime.jsx)("br", {}), (0, _jsxRuntime.jsx)(_.Link, {
44
+ children: "Find out more \u2192"
45
+ })]
46
+ })
47
+ })]
48
+ });
49
+ };
50
+
51
+ exports.Default = Default;
@@ -1,24 +1,43 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.Default = exports["default"] = void 0;
5
+
6
+ var _react = _interopRequireDefault(require("react"));
7
+
8
+ var _ = require("..");
9
+
10
+ var _jsxRuntime = require("theme-ui/jsx-runtime");
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
13
+
1
14
  /**
2
15
  * External dependencies
3
16
  */
4
- import React from 'react';
17
+
5
18
  /**
6
19
  * Internal dependencies
7
20
  */
8
-
9
- import { Wizard, Flex, Box, Heading, Label, Input, Button } from '..';
10
- export default {
21
+ var _default = {
11
22
  title: 'Wizard',
12
- component: Wizard
23
+ component: _.Wizard
13
24
  };
14
- export var Default = function Default() {
25
+ exports["default"] = _default;
26
+
27
+ var Default = function Default() {
15
28
  var steps = [{
16
29
  title: 'Choose Domain',
17
30
  subTitle: 'You can bring a domain name you already own, or buy a new one.',
18
- children: /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(Label, null, "Domain"), /*#__PURE__*/React.createElement(Input, {
19
- autoFocus: true,
20
- placeholder: "yourdomain.com"
21
- }), /*#__PURE__*/React.createElement(Button, null, "Continue"))
31
+ children: (0, _jsxRuntime.jsxs)(_.Box, {
32
+ children: [(0, _jsxRuntime.jsx)(_.Label, {
33
+ children: "Domain"
34
+ }), (0, _jsxRuntime.jsx)(_.Input, {
35
+ autoFocus: true,
36
+ placeholder: "yourdomain.com"
37
+ }), (0, _jsxRuntime.jsx)(_.Button, {
38
+ children: "Continue"
39
+ })]
40
+ })
22
41
  }, {
23
42
  title: 'Configure DNS'
24
43
  }, {
@@ -26,30 +45,39 @@ export var Default = function Default() {
26
45
  }, {
27
46
  title: 'Verify Domain'
28
47
  }];
29
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Flex, {
30
- sx: {
31
- alignItems: 'center'
32
- }
33
- }, /*#__PURE__*/React.createElement(Box, {
34
- sx: {
35
- flex: '1 1 auto'
36
- }
37
- }, /*#__PURE__*/React.createElement(Heading, {
38
- variant: "h1",
39
- sx: {
40
- display: 'flex',
41
- alignItems: 'center',
42
- mb: 1
43
- }
44
- }, "Add Domain:", ' ', /*#__PURE__*/React.createElement("span", {
45
- sx: {
46
- color: 'muted',
47
- ml: 2
48
- }
49
- }, "Production")))), /*#__PURE__*/React.createElement(Box, {
50
- mt: 4
51
- }, /*#__PURE__*/React.createElement(Wizard, {
52
- activeStep: 0,
53
- steps: steps
54
- })));
55
- };
48
+ return (0, _jsxRuntime.jsxs)(_react["default"].Fragment, {
49
+ children: [(0, _jsxRuntime.jsx)(_.Flex, {
50
+ sx: {
51
+ alignItems: 'center'
52
+ },
53
+ children: (0, _jsxRuntime.jsx)(_.Box, {
54
+ sx: {
55
+ flex: '1 1 auto'
56
+ },
57
+ children: (0, _jsxRuntime.jsxs)(_.Heading, {
58
+ variant: "h1",
59
+ sx: {
60
+ display: 'flex',
61
+ alignItems: 'center',
62
+ mb: 1
63
+ },
64
+ children: ["Add Domain:", ' ', (0, _jsxRuntime.jsx)("span", {
65
+ sx: {
66
+ color: 'muted',
67
+ ml: 2
68
+ },
69
+ children: "Production"
70
+ })]
71
+ })
72
+ })
73
+ }), (0, _jsxRuntime.jsx)(_.Box, {
74
+ mt: 4,
75
+ children: (0, _jsxRuntime.jsx)(_.Wizard, {
76
+ activeStep: 0,
77
+ steps: steps
78
+ })
79
+ })]
80
+ });
81
+ };
82
+
83
+ exports.Default = Default;
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@automattic/vip-design-system",
3
- "version": "0.9.2",
3
+ "version": "0.9.5",
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
8
  "format": "eslint . --fix",
9
9
  "jest": "NODE_ENV=test jest --detectOpenHandles",
10
+ "jest:coverage": "npm run jest && open-cli ./coverage/index.html",
10
11
  "jest:watch": "npm run jest --watch",
11
12
  "lint": "eslint . -f json | eslines --quiet",
12
13
  "storybook": "start-storybook -p 6006",
@@ -20,7 +21,8 @@
20
21
  "babel-loader": "^8.2.2",
21
22
  "framer-motion": "^3.9.1",
22
23
  "react-icons": "^4.2.0",
23
- "react-select": "^4.3.1"
24
+ "react-select": "^4.3.1",
25
+ "react-select-async-paginate": "^0.6.1"
24
26
  },
25
27
  "peerDependencies": {
26
28
  "react": "*",
@@ -34,12 +36,21 @@
34
36
  "**/react-dom": "17.0.1"
35
37
  },
36
38
  "jest": {
39
+ "collectCoverage": true,
40
+ "coverageReporters": [
41
+ "json",
42
+ "html"
43
+ ],
37
44
  "testURL": "http://localhost",
45
+ "roots": [
46
+ "<rootDir>/src",
47
+ "<rootDir>/test"
48
+ ],
38
49
  "setupFiles": [
39
- "./test/setupTests.js"
50
+ "<rootDir>/test/setupTests.js"
40
51
  ],
41
52
  "setupFilesAfterEnv": [
42
- "./test/setupAfterEnv.js"
53
+ "<rootDir>/test/setupAfterEnv.js"
43
54
  ],
44
55
  "transformIgnorePatterns": [
45
56
  ".*.stories.js$"
@@ -49,7 +60,6 @@
49
60
  }
50
61
  },
51
62
  "devDependencies": {
52
- "immer": ">=9.0.6",
53
63
  "@axe-core/react": "4.3.2",
54
64
  "@babel/cli": "^7.14.3",
55
65
  "@babel/core": "7.14.0",
@@ -85,7 +95,9 @@
85
95
  "eslint-plugin-no-async-foreach": "0.1.1",
86
96
  "eslint-plugin-react": "7.25.3",
87
97
  "eslint-plugin-wpcalypso": "4.1.0",
98
+ "immer": ">=9.0.6",
88
99
  "jest-axe": "5.0.1",
100
+ "open-cli": "^7.0.1",
89
101
  "optimize-css-assets-webpack-plugin": "^6.0.1",
90
102
  "react-input-autosize": "^3.0.0",
91
103
  "react-refresh": "^0.9.0",
@@ -10,22 +10,21 @@ import { axe } from 'jest-axe';
10
10
  import { Avatar } from './Avatar';
11
11
 
12
12
  describe( '<Avatar />', () => {
13
- it( 'renders the Avatar without an image', () => {
14
- render( <Avatar name="John Doe" /> );
13
+ it( 'renders the Avatar without an image', async () => {
14
+ const { container } = render( <Avatar name="John Doe" /> );
15
15
 
16
16
  expect( screen.getByText( 'J' ) ).toBeInTheDocument();
17
- } );
18
-
19
- it( 'renders the Avatar with image', () => {
20
- render( <Avatar name="John Doe" src="path/to/image" /> );
21
17
 
22
- expect( screen.getByAltText( 'Avatar image from John Doe' ) ).toBeInTheDocument();
18
+ // Check for accessibility issues
19
+ await expect( await axe( container ) ).toHaveNoViolations();
23
20
  } );
24
21
 
25
- it( 'should not have basic accessibility issues', async () => {
22
+ it( 'renders the Avatar with image', async () => {
26
23
  const { container } = render( <Avatar name="John Doe" src="path/to/image" /> );
27
- const results = await axe( container );
28
24
 
29
- expect( results ).toHaveNoViolations();
25
+ expect( screen.getByAltText( 'Avatar image from John Doe' ) ).toBeInTheDocument();
26
+
27
+ // Check for accessibility issues
28
+ await expect( await axe( container ) ).toHaveNoViolations();
30
29
  } );
31
30
  } );
@@ -0,0 +1,30 @@
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 { Badge } from './Badge';
11
+
12
+ describe( '<Badge />', () => {
13
+ it( 'renders the Badge component', async () => {
14
+ const { container } = render( <Badge>Badge text</Badge> );
15
+
16
+ expect( screen.getByText( 'Badge text' ) ).toBeInTheDocument();
17
+
18
+ // Check for accessibility issues
19
+ await expect( await axe( container ) ).toHaveNoViolations();
20
+ } );
21
+
22
+ it( 'renders the Badge component with a different variant', async () => {
23
+ const { container } = render( <Badge variant="primary">Badge text</Badge> );
24
+
25
+ expect( screen.getByText( 'Badge text' ) ).toBeInTheDocument();
26
+
27
+ // Check for accessibility issues
28
+ await expect( await axe( container ) ).toHaveNoViolations();
29
+ } );
30
+ } );
@@ -10,10 +10,17 @@ import PropTypes from 'prop-types';
10
10
  */
11
11
  import { Box, Heading, Text } from '..';
12
12
 
13
- const BlankState = ( { image, icon, title, body, cta } ) => {
13
+ const BlankState = ( {
14
+ body,
15
+ cta,
16
+ icon,
17
+ image,
18
+ imageAlt = 'Image representing the blank state',
19
+ title,
20
+ } ) => {
14
21
  return (
15
22
  <Box sx={{ textAlign: 'center', padding: 5 }}>
16
- {icon ? icon : <img src={image} sx={{ mb: 3 }} alt="Icon representing the blank state" />}
23
+ {icon ? icon : <img src={image} sx={{ mb: 3 }} alt={imageAlt} />}
17
24
  <Heading variant="h4">{title}</Heading>
18
25
  <Text>{body}</Text>
19
26
  <Box sx={{ mt: 3 }}>{cta}</Box>
@@ -22,11 +29,12 @@ const BlankState = ( { image, icon, title, body, cta } ) => {
22
29
  };
23
30
 
24
31
  BlankState.propTypes = {
25
- image: PropTypes.oneOfType( [ PropTypes.object, PropTypes.string ] ),
26
- icon: PropTypes.node,
27
- title: PropTypes.node,
28
32
  body: PropTypes.node,
29
33
  cta: PropTypes.node,
34
+ icon: PropTypes.node,
35
+ image: PropTypes.oneOfType( [ PropTypes.object, PropTypes.string ] ),
36
+ imageAlt: PropTypes.string,
37
+ title: PropTypes.node,
30
38
  };
31
39
 
32
40
  export { BlankState };
@@ -0,0 +1,58 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import { render, screen } from '@testing-library/react';
5
+ import { axe } from 'jest-axe';
6
+ import { MdContentCopy } from 'react-icons/md';
7
+
8
+ /**
9
+ * Internal dependencies
10
+ */
11
+ import { BlankState } from './BlankState';
12
+ import { Link } from '../Link';
13
+
14
+ // eslint-disable-next-line max-len
15
+ const image = "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";
16
+
17
+ const defaultProps = {
18
+ body: 'Sorry, there\'s nothing here yet.',
19
+ cta: <Link as="a">Explore add-ons →</Link>,
20
+ image,
21
+ imageAlt: 'This is the image alt',
22
+ title: 'Power up your application',
23
+ };
24
+
25
+ describe( '<BlankState />', () => {
26
+ it( 'renders the BlankState component', async () => {
27
+ const { container } = render( <BlankState { ...defaultProps } /> );
28
+
29
+ expect( screen.getByText( defaultProps.body ) ).toBeInTheDocument();
30
+ expect( screen.getByText( defaultProps.title ) ).toBeInTheDocument();
31
+ expect( screen.getByText( 'Explore add-ons →' ) ).toBeInTheDocument();
32
+ expect( screen.getByAltText( defaultProps.imageAlt ) ).toBeInTheDocument();
33
+
34
+ // Check for accessibility issues
35
+ await expect( await axe( container ) ).toHaveNoViolations();
36
+ } );
37
+
38
+ it( 'renders the BlankState component with default alt text for the given image', async () => {
39
+ const props = { ...defaultProps, imageAlt: undefined };
40
+ const { container } = render( <BlankState { ...props } /> );
41
+
42
+ expect( screen.getByAltText( 'Image representing the blank state' ) ).toBeInTheDocument();
43
+
44
+ // Check for accessibility issues
45
+ await expect( await axe( container ) ).toHaveNoViolations();
46
+ } );
47
+
48
+ it( 'renders the BlankState component with an icon', async () => {
49
+ const icon = <MdContentCopy title="this is an icon" />;
50
+ const props = { ...defaultProps, icon };
51
+ const { container } = render( <BlankState { ...props } /> );
52
+
53
+ expect( screen.getByTitle( 'this is an icon' ) ).toBeInTheDocument();
54
+
55
+ // Check for accessibility issues
56
+ await expect( await axe( container ) ).toHaveNoViolations();
57
+ } );
58
+ } );
@@ -0,0 +1,21 @@
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 { Button } from './Button';
11
+
12
+ describe( '<Button />', () => {
13
+ it( 'renders the Button component', async () => {
14
+ const { container } = render( <Button>Button text</Button> );
15
+
16
+ expect( screen.getByText( 'Button text' ) ).toBeInTheDocument();
17
+
18
+ // Check for accessibility issues
19
+ await expect( await axe( container ) ).toHaveNoViolations();
20
+ } );
21
+ } );
@@ -0,0 +1,33 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import { render, screen, fireEvent, waitFor } from '@testing-library/react';
5
+ import { axe } from 'jest-axe';
6
+ import { MdContentCopy } from 'react-icons/md';
7
+
8
+ /**
9
+ * Internal dependencies
10
+ */
11
+ import { Card } from './Card';
12
+
13
+ const defaultProps = {};
14
+
15
+ describe( '<Card />', () => {
16
+ it( 'renders the Card component', async () => {
17
+ const { container } = render( <Card { ...defaultProps }>This is a Card</Card> );
18
+
19
+ expect( screen.getByText( 'This is a Card' ) ).toBeInTheDocument();
20
+
21
+ // Check for accessibility issues
22
+ await expect( await axe( container ) ).toHaveNoViolations();
23
+ } );
24
+
25
+ it( 'renders the Card component with a different variant', async () => {
26
+ const { container } = render( <Card variant="primary">Card text</Card> );
27
+
28
+ expect( screen.getByText( 'Card text' ) ).toBeInTheDocument();
29
+
30
+ // Check for accessibility issues
31
+ await expect( await axe( container ) ).toHaveNoViolations();
32
+ } );
33
+ } );
@@ -47,18 +47,21 @@ const Code = ( { prompt = false, showCopy = false, onCopy = null, ...props } ) =
47
47
  >
48
48
  { codeDom }
49
49
  {
50
- <span
50
+ <button
51
+ aria-label="Copy"
51
52
  sx={ {
52
- position: 'absolute',
53
- top: 0,
54
53
  bg: 'grey.10',
55
- right: 0,
56
- paddingRight: 2,
57
- paddingLeft: 2,
58
- paddingTop: 1,
59
- paddingBottom: 1,
60
54
  borderTopRightRadius: 1,
55
+ borderWidth: 0,
56
+ color: 'muted',
61
57
  opacity: 0.8,
58
+ paddingBottom: 1,
59
+ paddingLeft: 2,
60
+ paddingRight: 2,
61
+ paddingTop: 1,
62
+ position: 'absolute',
63
+ right: 0,
64
+ top: '-1px',
62
65
  '&:hover': {
63
66
  opacity: 1,
64
67
  cursor: 'pointer',
@@ -75,7 +78,7 @@ const Code = ( { prompt = false, showCopy = false, onCopy = null, ...props } ) =
75
78
  } }
76
79
  >
77
80
  { copied ? 'Copied!' : <MdContentCopy /> }
78
- </span>
81
+ </button>
79
82
  }
80
83
  </div>
81
84
  );
@@ -16,7 +16,9 @@ export default {
16
16
  export const Default = () => (
17
17
  <React.Fragment>
18
18
  <Code>Code</Code>
19
+ <br />
19
20
  <Code showCopy={true}>Code with Icon</Code>
21
+ <br />
20
22
  <Code showCopy={true} onCopy={
21
23
  // eslint-disable-next-line no-console
22
24
  () => console.info( 'Hello world' )