@pingux/astro 2.1.3 → 2.2.0-alpha.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.
@@ -52,7 +52,19 @@ Icon.propTypes = {
52
52
  * rendering 15, 20, and 25 pixel svg containers. */
53
53
  size: _propTypes["default"].oneOfType([_propTypes["default"].number, _propTypes["default"].string]),
54
54
  /** A theme-aware prop to set the icon's color. */
55
- color: _propTypes["default"].string
55
+ color: _propTypes["default"].string,
56
+ /**
57
+ * The title associated with the icon. It is recommended that icons always have an associated
58
+ * title in order to allow a better user experience for those using screen readers.
59
+ * The **`id`** in the title object will be the id of the title and
60
+ * is also what will be supplied to the **`aria-labelledby`** attribute in the SVG.
61
+ * The **`name`** in the title object will be the content of the title.
62
+ * This prop can only be used when importing the icon from [@pingux/mdi-react](https://www.npmjs.com/package/@pingux/mdi-react).
63
+ * */
64
+ title: _propTypes["default"].shape({
65
+ id: _propTypes["default"].string,
66
+ name: _propTypes["default"].string
67
+ })
56
68
  };
57
69
  Icon.defaultProps = {
58
70
  size: 20
@@ -11,11 +11,11 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/hel
11
11
  var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/keys"));
12
12
  var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
13
13
  var _react = _interopRequireDefault(require("react"));
14
- var _AccountGroupIcon = _interopRequireDefault(require("mdi-react/AccountGroupIcon"));
15
- var _AccountIcon = _interopRequireDefault(require("mdi-react/AccountIcon"));
16
- var _LockIcon = _interopRequireDefault(require("mdi-react/LockIcon"));
17
- var _SearchIcon = _interopRequireDefault(require("mdi-react/SearchIcon"));
18
- var _TagIcon = _interopRequireDefault(require("mdi-react/TagIcon"));
14
+ var _AccountGroupIcon = _interopRequireDefault(require("@pingux/mdi-react/AccountGroupIcon"));
15
+ var _AccountIcon = _interopRequireDefault(require("@pingux/mdi-react/AccountIcon"));
16
+ var _LockIcon = _interopRequireDefault(require("@pingux/mdi-react/LockIcon"));
17
+ var _SearchIcon = _interopRequireDefault(require("@pingux/mdi-react/SearchIcon"));
18
+ var _TagIcon = _interopRequireDefault(require("@pingux/mdi-react/TagIcon"));
19
19
  var _uuid = require("uuid");
20
20
  var _storybookDocsLayout = _interopRequireDefault(require("../../../.storybook/storybookDocsLayout"));
21
21
  var _index = require("../../index");
@@ -66,7 +66,12 @@ var _default = {
66
66
  };
67
67
  exports["default"] = _default;
68
68
  var Default = function Default(args) {
69
- return (0, _react2.jsx)(_index.Icon, args);
69
+ return (0, _react2.jsx)(_index.Icon, (0, _extends2["default"])({}, args, {
70
+ title: {
71
+ id: 'search-icon-title',
72
+ name: 'Search Icon'
73
+ }
74
+ }));
70
75
  };
71
76
  exports.Default = Default;
72
77
  var SVGIcons = function SVGIcons() {
@@ -113,7 +118,11 @@ var Sizes = function Sizes() {
113
118
  fontFamily: "monospace"
114
119
  }, '<Icon icon={SearchIcon}/> size="xs"/>')), (0, _react2.jsx)(_index.TableCell, null, (0, _react2.jsx)(_index.Icon, {
115
120
  icon: _SearchIcon["default"],
116
- size: "xs"
121
+ size: "xs",
122
+ title: {
123
+ id: 'search-icon-title',
124
+ name: 'Search Icon'
125
+ }
117
126
  }))), (0, _react2.jsx)(_index.TableRow, {
118
127
  height: "45px",
119
128
  bg: "transparent !important"
@@ -121,7 +130,11 @@ var Sizes = function Sizes() {
121
130
  fontFamily: "monospace"
122
131
  }, '<Icon icon={SearchIcon}/> size="sm"/>')), (0, _react2.jsx)(_index.TableCell, null, (0, _react2.jsx)(_index.Icon, {
123
132
  icon: _SearchIcon["default"],
124
- size: "sm"
133
+ size: "sm",
134
+ title: {
135
+ id: 'search-icon-title',
136
+ name: 'Search Icon'
137
+ }
125
138
  }))), (0, _react2.jsx)(_index.TableRow, {
126
139
  height: "45px",
127
140
  bg: "transparent !important"
@@ -129,7 +142,11 @@ var Sizes = function Sizes() {
129
142
  fontFamily: "monospace"
130
143
  }, '<Icon icon={SearchIcon}/> size="md"/>')), (0, _react2.jsx)(_index.TableCell, null, (0, _react2.jsx)(_index.Icon, {
131
144
  icon: _SearchIcon["default"],
132
- size: "md"
145
+ size: "md",
146
+ title: {
147
+ id: 'search-icon-title',
148
+ name: 'Search Icon'
149
+ }
133
150
  })))));
134
151
  };
135
152
  exports.Sizes = Sizes;
@@ -141,49 +158,69 @@ var CommonlyUsed = function CommonlyUsed() {
141
158
  }, (0, _react2.jsx)(_index.Icon, {
142
159
  icon: _AccountIcon["default"],
143
160
  color: "accent.40",
144
- size: "sm"
161
+ size: "sm",
162
+ title: {
163
+ id: 'account-icon-title',
164
+ name: 'Account Icon'
165
+ }
145
166
  }), (0, _react2.jsx)(_index.Text, {
146
167
  fontFamily: "monospace"
147
- }, "import AccountIcon from 'mdi-react/AccountIcon'; ")), (0, _react2.jsx)(_index.Box, {
168
+ }, "import AccountIcon from '@pingux/mdi-react/AccountIcon'; ")), (0, _react2.jsx)(_index.Box, {
148
169
  isRow: true,
149
170
  gap: "md",
150
171
  mb: "xs"
151
172
  }, (0, _react2.jsx)(_index.Icon, {
152
173
  icon: _AccountGroupIcon["default"],
153
174
  color: "accent.40",
154
- size: "sm"
175
+ size: "sm",
176
+ title: {
177
+ id: 'account-group-title',
178
+ name: 'Account Group Icon'
179
+ }
155
180
  }), (0, _react2.jsx)(_index.Text, {
156
181
  fontFamily: "monospace"
157
- }, "import AccountGroupIcon from 'mdi-react/AccountGroupIcon'; ")), (0, _react2.jsx)(_index.Box, {
182
+ }, "import AccountGroupIcon from '@pingux/mdi-react/AccountGroupIcon'; ")), (0, _react2.jsx)(_index.Box, {
158
183
  isRow: true,
159
184
  gap: "md",
160
185
  mb: "xs"
161
186
  }, (0, _react2.jsx)(_index.Icon, {
162
187
  icon: _LockIcon["default"],
163
188
  color: "accent.40",
164
- size: "sm"
189
+ size: "sm",
190
+ title: {
191
+ id: 'lock-icon-title',
192
+ name: 'Lock Icon'
193
+ }
165
194
  }), (0, _react2.jsx)(_index.Text, {
166
195
  fontFamily: "monospace"
167
- }, "import LockIcon from 'mdi-react/LockIcon'; ")), (0, _react2.jsx)(_index.Box, {
196
+ }, "import LockIcon from '@pingux/mdi-react/LockIcon'; ")), (0, _react2.jsx)(_index.Box, {
168
197
  isRow: true,
169
198
  gap: "md",
170
199
  mb: "xs"
171
200
  }, (0, _react2.jsx)(_index.Icon, {
172
201
  icon: _SearchIcon["default"],
173
202
  color: "accent.40",
174
- size: "sm"
203
+ size: "sm",
204
+ title: {
205
+ id: 'search-icon-title',
206
+ name: 'Search Icon'
207
+ }
175
208
  }), (0, _react2.jsx)(_index.Text, {
176
209
  fontFamily: "monospace"
177
- }, "import SearchIcon from 'mdi-react/SearchIcon'; ")), (0, _react2.jsx)(_index.Box, {
210
+ }, "import SearchIcon from '@pingux/mdi-react/SearchIcon'; ")), (0, _react2.jsx)(_index.Box, {
178
211
  isRow: true,
179
212
  gap: "md",
180
213
  mb: "xs"
181
214
  }, (0, _react2.jsx)(_index.Icon, {
182
215
  icon: _TagIcon["default"],
183
216
  color: "accent.40",
184
- size: "sm"
217
+ size: "sm",
218
+ title: {
219
+ id: 'tag-icon-title',
220
+ name: 'Tag Icon'
221
+ }
185
222
  }), (0, _react2.jsx)(_index.Text, {
186
223
  fontFamily: "monospace"
187
- }, "import TagIcon from 'mdi-react/TagIcon'; ")));
224
+ }, "import TagIcon from '@pingux/mdi-react/TagIcon'; ")));
188
225
  };
189
226
  exports.CommonlyUsed = CommonlyUsed;
@@ -3,15 +3,19 @@
3
3
  var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
4
4
  var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
5
5
  var _react = _interopRequireDefault(require("react"));
6
+ var _EarthIcon = _interopRequireDefault(require("@pingux/mdi-react/EarthIcon"));
6
7
  var _react2 = require("@testing-library/react");
7
- var _EarthIcon = _interopRequireDefault(require("mdi-react/EarthIcon"));
8
8
  var _testAxe = _interopRequireDefault(require("../../utils/testUtils/testAxe"));
9
9
  var _ = _interopRequireDefault(require("."));
10
10
  var _react3 = require("@emotion/react");
11
11
  var testId = 'test-icon';
12
12
  var defaultProps = {
13
13
  'data-testid': testId,
14
- icon: _EarthIcon["default"]
14
+ icon: _EarthIcon["default"],
15
+ title: {
16
+ id: 'title-id',
17
+ name: 'Earth Icon'
18
+ }
15
19
  };
16
20
  var getComponent = function getComponent() {
17
21
  var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
@@ -46,4 +50,13 @@ test('icon renders correct medium tshirt size', function () {
46
50
  });
47
51
  var mdIcon = _react2.screen.getByTestId(testId);
48
52
  expect(mdIcon).toHaveStyleRule('width', '25px');
53
+ });
54
+ test('icon renders with associated title', function () {
55
+ getComponent();
56
+ var icon = _react2.screen.getByTestId(testId);
57
+ var title = _react2.screen.getByText('Earth Icon');
58
+ expect(icon).toBeInstanceOf(SVGSVGElement);
59
+ expect(icon).toBeInTheDocument();
60
+ expect(icon).toHaveAttribute('aria-labelledby', 'title-id');
61
+ expect(title).toBeInTheDocument();
49
62
  });
@@ -41,7 +41,19 @@ Icon.propTypes = {
41
41
  * rendering 15, 20, and 25 pixel svg containers. */
42
42
  size: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
43
43
  /** A theme-aware prop to set the icon's color. */
44
- color: PropTypes.string
44
+ color: PropTypes.string,
45
+ /**
46
+ * The title associated with the icon. It is recommended that icons always have an associated
47
+ * title in order to allow a better user experience for those using screen readers.
48
+ * The **`id`** in the title object will be the id of the title and
49
+ * is also what will be supplied to the **`aria-labelledby`** attribute in the SVG.
50
+ * The **`name`** in the title object will be the content of the title.
51
+ * This prop can only be used when importing the icon from [@pingux/mdi-react](https://www.npmjs.com/package/@pingux/mdi-react).
52
+ * */
53
+ title: PropTypes.shape({
54
+ id: PropTypes.string,
55
+ name: PropTypes.string
56
+ })
45
57
  };
46
58
  Icon.defaultProps = {
47
59
  size: 20
@@ -3,11 +3,11 @@ import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
3
3
  import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
4
4
  import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
5
5
  import React from 'react';
6
- import AccountGroupIcon from 'mdi-react/AccountGroupIcon';
7
- import AccountIcon from 'mdi-react/AccountIcon';
8
- import LockIcon from 'mdi-react/LockIcon';
9
- import SearchIcon from 'mdi-react/SearchIcon';
10
- import TagIcon from 'mdi-react/TagIcon';
6
+ import AccountGroupIcon from '@pingux/mdi-react/AccountGroupIcon';
7
+ import AccountIcon from '@pingux/mdi-react/AccountIcon';
8
+ import LockIcon from '@pingux/mdi-react/LockIcon';
9
+ import SearchIcon from '@pingux/mdi-react/SearchIcon';
10
+ import TagIcon from '@pingux/mdi-react/TagIcon';
11
11
  import { v4 as uuid } from 'uuid';
12
12
  import DocsLayout from '../../../.storybook/storybookDocsLayout';
13
13
  import { Box, Icon, Table, TableBody, TableCell, TableHead, TableRow, Text } from '../../index';
@@ -57,7 +57,12 @@ export default {
57
57
  }
58
58
  };
59
59
  export var Default = function Default(args) {
60
- return ___EmotionJSX(Icon, args);
60
+ return ___EmotionJSX(Icon, _extends({}, args, {
61
+ title: {
62
+ id: 'search-icon-title',
63
+ name: 'Search Icon'
64
+ }
65
+ }));
61
66
  };
62
67
  export var SVGIcons = function SVGIcons() {
63
68
  // SVGR can used to convert .svg files to components instead of doing this manually
@@ -102,7 +107,11 @@ export var Sizes = function Sizes() {
102
107
  fontFamily: "monospace"
103
108
  }, '<Icon icon={SearchIcon}/> size="xs"/>')), ___EmotionJSX(TableCell, null, ___EmotionJSX(Icon, {
104
109
  icon: SearchIcon,
105
- size: "xs"
110
+ size: "xs",
111
+ title: {
112
+ id: 'search-icon-title',
113
+ name: 'Search Icon'
114
+ }
106
115
  }))), ___EmotionJSX(TableRow, {
107
116
  height: "45px",
108
117
  bg: "transparent !important"
@@ -110,7 +119,11 @@ export var Sizes = function Sizes() {
110
119
  fontFamily: "monospace"
111
120
  }, '<Icon icon={SearchIcon}/> size="sm"/>')), ___EmotionJSX(TableCell, null, ___EmotionJSX(Icon, {
112
121
  icon: SearchIcon,
113
- size: "sm"
122
+ size: "sm",
123
+ title: {
124
+ id: 'search-icon-title',
125
+ name: 'Search Icon'
126
+ }
114
127
  }))), ___EmotionJSX(TableRow, {
115
128
  height: "45px",
116
129
  bg: "transparent !important"
@@ -118,7 +131,11 @@ export var Sizes = function Sizes() {
118
131
  fontFamily: "monospace"
119
132
  }, '<Icon icon={SearchIcon}/> size="md"/>')), ___EmotionJSX(TableCell, null, ___EmotionJSX(Icon, {
120
133
  icon: SearchIcon,
121
- size: "md"
134
+ size: "md",
135
+ title: {
136
+ id: 'search-icon-title',
137
+ name: 'Search Icon'
138
+ }
122
139
  })))));
123
140
  };
124
141
  export var CommonlyUsed = function CommonlyUsed() {
@@ -129,48 +146,68 @@ export var CommonlyUsed = function CommonlyUsed() {
129
146
  }, ___EmotionJSX(Icon, {
130
147
  icon: AccountIcon,
131
148
  color: "accent.40",
132
- size: "sm"
149
+ size: "sm",
150
+ title: {
151
+ id: 'account-icon-title',
152
+ name: 'Account Icon'
153
+ }
133
154
  }), ___EmotionJSX(Text, {
134
155
  fontFamily: "monospace"
135
- }, "import AccountIcon from 'mdi-react/AccountIcon'; ")), ___EmotionJSX(Box, {
156
+ }, "import AccountIcon from '@pingux/mdi-react/AccountIcon'; ")), ___EmotionJSX(Box, {
136
157
  isRow: true,
137
158
  gap: "md",
138
159
  mb: "xs"
139
160
  }, ___EmotionJSX(Icon, {
140
161
  icon: AccountGroupIcon,
141
162
  color: "accent.40",
142
- size: "sm"
163
+ size: "sm",
164
+ title: {
165
+ id: 'account-group-title',
166
+ name: 'Account Group Icon'
167
+ }
143
168
  }), ___EmotionJSX(Text, {
144
169
  fontFamily: "monospace"
145
- }, "import AccountGroupIcon from 'mdi-react/AccountGroupIcon'; ")), ___EmotionJSX(Box, {
170
+ }, "import AccountGroupIcon from '@pingux/mdi-react/AccountGroupIcon'; ")), ___EmotionJSX(Box, {
146
171
  isRow: true,
147
172
  gap: "md",
148
173
  mb: "xs"
149
174
  }, ___EmotionJSX(Icon, {
150
175
  icon: LockIcon,
151
176
  color: "accent.40",
152
- size: "sm"
177
+ size: "sm",
178
+ title: {
179
+ id: 'lock-icon-title',
180
+ name: 'Lock Icon'
181
+ }
153
182
  }), ___EmotionJSX(Text, {
154
183
  fontFamily: "monospace"
155
- }, "import LockIcon from 'mdi-react/LockIcon'; ")), ___EmotionJSX(Box, {
184
+ }, "import LockIcon from '@pingux/mdi-react/LockIcon'; ")), ___EmotionJSX(Box, {
156
185
  isRow: true,
157
186
  gap: "md",
158
187
  mb: "xs"
159
188
  }, ___EmotionJSX(Icon, {
160
189
  icon: SearchIcon,
161
190
  color: "accent.40",
162
- size: "sm"
191
+ size: "sm",
192
+ title: {
193
+ id: 'search-icon-title',
194
+ name: 'Search Icon'
195
+ }
163
196
  }), ___EmotionJSX(Text, {
164
197
  fontFamily: "monospace"
165
- }, "import SearchIcon from 'mdi-react/SearchIcon'; ")), ___EmotionJSX(Box, {
198
+ }, "import SearchIcon from '@pingux/mdi-react/SearchIcon'; ")), ___EmotionJSX(Box, {
166
199
  isRow: true,
167
200
  gap: "md",
168
201
  mb: "xs"
169
202
  }, ___EmotionJSX(Icon, {
170
203
  icon: TagIcon,
171
204
  color: "accent.40",
172
- size: "sm"
205
+ size: "sm",
206
+ title: {
207
+ id: 'tag-icon-title',
208
+ name: 'Tag Icon'
209
+ }
173
210
  }), ___EmotionJSX(Text, {
174
211
  fontFamily: "monospace"
175
- }, "import TagIcon from 'mdi-react/TagIcon'; ")));
212
+ }, "import TagIcon from '@pingux/mdi-react/TagIcon'; ")));
176
213
  };
@@ -1,14 +1,18 @@
1
1
  import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
2
2
  import React from 'react';
3
+ import Earth from '@pingux/mdi-react/EarthIcon';
3
4
  import { render, screen } from '@testing-library/react';
4
- import Earth from 'mdi-react/EarthIcon';
5
5
  import axeTest from '../../utils/testUtils/testAxe';
6
6
  import Icon from '.';
7
7
  import { jsx as ___EmotionJSX } from "@emotion/react";
8
8
  var testId = 'test-icon';
9
9
  var defaultProps = {
10
10
  'data-testid': testId,
11
- icon: Earth
11
+ icon: Earth,
12
+ title: {
13
+ id: 'title-id',
14
+ name: 'Earth Icon'
15
+ }
12
16
  };
13
17
  var getComponent = function getComponent() {
14
18
  var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
@@ -43,4 +47,13 @@ test('icon renders correct medium tshirt size', function () {
43
47
  });
44
48
  var mdIcon = screen.getByTestId(testId);
45
49
  expect(mdIcon).toHaveStyleRule('width', '25px');
50
+ });
51
+ test('icon renders with associated title', function () {
52
+ getComponent();
53
+ var icon = screen.getByTestId(testId);
54
+ var title = screen.getByText('Earth Icon');
55
+ expect(icon).toBeInstanceOf(SVGSVGElement);
56
+ expect(icon).toBeInTheDocument();
57
+ expect(icon).toHaveAttribute('aria-labelledby', 'title-id');
58
+ expect(title).toBeInTheDocument();
46
59
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pingux/astro",
3
- "version": "2.1.3",
3
+ "version": "2.2.0-alpha.0",
4
4
  "description": "PingUX themeable React component library",
5
5
  "repository": {
6
6
  "type": "git",
@@ -40,6 +40,7 @@
40
40
  "@emotion/styled": "^11.1.1",
41
41
  "@faker-js/faker": "~7.5.0",
42
42
  "@mdx-js/react": "^1.6.22",
43
+ "@pingux/mdi-react": "^1.0.0",
43
44
  "@react-aria/accordion": "~3.0.0-alpha.11",
44
45
  "@react-aria/breadcrumbs": "^3.1.4",
45
46
  "@react-aria/button": "^3.2.1",