@pingux/astro 2.171.0-alpha.0 → 2.172.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 (46) hide show
  1. package/lib/cjs/components/Icon/Icon.js +15 -49
  2. package/lib/cjs/components/Icon/Icon.test.js +7 -36
  3. package/lib/cjs/components/Icon/IconDefault.d.ts +4 -0
  4. package/lib/cjs/components/Icon/IconDefault.js +63 -0
  5. package/lib/cjs/components/Icon/IconDefault.test.js +92 -0
  6. package/lib/cjs/components/Icon/IconSymbol.d.ts +4 -0
  7. package/lib/cjs/components/Icon/IconSymbol.js +60 -0
  8. package/lib/cjs/components/Icon/IconSymbol.mdx +46 -0
  9. package/lib/cjs/components/Icon/IconSymbol.test.js +80 -0
  10. package/lib/cjs/components/Icon/MaterialSymbolIcon.stories.d.ts +7 -0
  11. package/lib/cjs/components/Icon/MaterialSymbolIcon.stories.js +207 -0
  12. package/lib/cjs/hooks/useGetTheme/useGetTheme.d.ts +31 -31
  13. package/lib/cjs/index.d.ts +1 -0
  14. package/lib/cjs/index.js +1 -0
  15. package/lib/cjs/styles/themeOverrides/nextGenDarkMode/customProperties/icons.d.ts +31 -31
  16. package/lib/cjs/styles/themeOverrides/nextGenDarkMode/customProperties/index.d.ts +31 -31
  17. package/lib/cjs/styles/themeOverrides/nextGenDarkMode/variants/variants.d.ts +18 -20
  18. package/lib/cjs/styles/themeOverrides/nextGenDarkMode/variants/variants.js +18 -20
  19. package/lib/cjs/styles/themeOverrides/onyxSideNav.d.ts +32 -29
  20. package/lib/cjs/styles/themeOverrides/onyxSideNav.js +3 -0
  21. package/lib/cjs/styles/themes/next-gen/convertedComponentList.d.ts +1 -0
  22. package/lib/cjs/styles/themes/next-gen/convertedComponentList.js +3 -2
  23. package/lib/cjs/styles/themes/next-gen/customProperties/icons.d.ts +32 -32
  24. package/lib/cjs/styles/themes/next-gen/customProperties/icons.js +1 -32
  25. package/lib/cjs/styles/themes/next-gen/customProperties/index.d.ts +32 -32
  26. package/lib/cjs/styles/themes/next-gen/next-gen.d.ts +60 -56
  27. package/lib/cjs/styles/themes/next-gen/variants/variants.d.ts +28 -24
  28. package/lib/cjs/styles/themes/next-gen/variants/variants.js +28 -24
  29. package/lib/cjs/types/icon.d.ts +3 -1
  30. package/lib/cjs/types/navBar.d.ts +2 -1
  31. package/lib/components/Icon/Icon.js +11 -47
  32. package/lib/components/Icon/Icon.test.js +5 -34
  33. package/lib/components/Icon/IconDefault.js +53 -0
  34. package/lib/components/Icon/IconDefault.test.js +84 -0
  35. package/lib/components/Icon/IconSymbol.js +50 -0
  36. package/lib/components/Icon/IconSymbol.mdx +46 -0
  37. package/lib/components/Icon/IconSymbol.test.js +77 -0
  38. package/lib/components/Icon/MaterialSymbolIcon.stories.js +200 -0
  39. package/lib/index.js +1 -1
  40. package/lib/styles/themeOverrides/nextGenDarkMode/variants/variants.js +18 -20
  41. package/lib/styles/themeOverrides/onyxSideNav.js +3 -0
  42. package/lib/styles/themes/next-gen/convertedComponentList.js +3 -2
  43. package/lib/styles/themes/next-gen/customProperties/icons.js +1 -32
  44. package/lib/styles/themes/next-gen/variants/variants.js +28 -24
  45. package/lib/tsconfig.lib.tsbuildinfo +1 -1
  46. package/package.json +4 -2
@@ -1593,10 +1593,8 @@ declare const _default: {
1593
1593
  backgroundColor: string;
1594
1594
  '& > div.status-icon': {
1595
1595
  bg: string;
1596
- '& > svg': {
1597
- path: {
1598
- fill: string;
1599
- };
1596
+ span: {
1597
+ color: string;
1600
1598
  };
1601
1599
  };
1602
1600
  };
@@ -1839,58 +1837,64 @@ declare const _default: {
1839
1837
  base: {
1840
1838
  '&.is-default': {
1841
1839
  bg: string;
1842
- path: {
1843
- fill: string;
1840
+ span: {
1841
+ fontSize: string;
1842
+ color: string;
1844
1843
  };
1845
1844
  };
1846
1845
  '&.is-critical': {
1847
1846
  bg: string;
1848
- path: {
1849
- fill: string;
1847
+ span: {
1848
+ fontSize: string;
1849
+ color: string;
1850
1850
  };
1851
1851
  };
1852
1852
  '&.is-warning': {
1853
1853
  bg: string;
1854
- path: {
1855
- fill: string;
1854
+ span: {
1855
+ fontSize: string;
1856
+ color: string;
1856
1857
  };
1857
1858
  };
1858
1859
  '&.is-info': {
1859
1860
  bg: string;
1860
- path: {
1861
- fill: string;
1861
+ span: {
1862
+ fontSize: string;
1863
+ color: string;
1862
1864
  };
1863
1865
  };
1864
1866
  '&.is-major': {
1865
1867
  bg: string;
1866
- path: {
1867
- fill: string;
1868
+ span: {
1869
+ fontSize: string;
1870
+ color: string;
1868
1871
  };
1869
1872
  };
1870
1873
  '&.is-minor': {
1871
1874
  bg: string;
1872
- path: {
1873
- fill: string;
1875
+ span: {
1876
+ fontSize: string;
1877
+ color: string;
1874
1878
  };
1875
1879
  };
1876
1880
  '&.is-warning-neutral': {
1877
1881
  bg: string;
1878
- path: {
1879
- fill: string;
1882
+ span: {
1883
+ fontSize: string;
1884
+ color: string;
1880
1885
  };
1881
1886
  };
1882
1887
  '&.is-fatal': {
1883
1888
  bg: string;
1884
- path: {
1885
- fill: string;
1889
+ span: {
1890
+ fontSize: string;
1891
+ color: string;
1886
1892
  };
1887
1893
  };
1888
1894
  '&.is-selected.is-selected': {
1889
1895
  bg: string;
1890
- '& > svg': {
1891
- path: {
1892
- fill: string;
1893
- };
1896
+ span: {
1897
+ color: string;
1894
1898
  };
1895
1899
  };
1896
1900
  };
@@ -326,10 +326,8 @@ var rockerButton = {
326
326
  backgroundColor: 'active',
327
327
  '& > div.status-icon': {
328
328
  bg: 'white',
329
- '& > svg': {
330
- path: {
331
- fill: 'active'
332
- }
329
+ span: {
330
+ color: 'active'
333
331
  }
334
332
  }
335
333
  },
@@ -368,58 +366,64 @@ var statusIcon = {
368
366
  base: {
369
367
  '&.is-default': {
370
368
  bg: 'gray-100',
371
- path: {
372
- fill: 'gray-700'
369
+ span: {
370
+ fontSize: 'md',
371
+ color: 'gray-700'
373
372
  }
374
373
  },
375
374
  '&.is-critical': {
376
375
  bg: 'red-100',
377
- path: {
378
- fill: 'red-700'
376
+ span: {
377
+ fontSize: 'md',
378
+ color: 'red-700'
379
379
  }
380
380
  },
381
381
  '&.is-warning': {
382
382
  bg: 'yellow-100',
383
- path: {
384
- fill: 'yellow-800'
383
+ span: {
384
+ fontSize: 'md',
385
+ color: 'yellow-800'
385
386
  }
386
387
  },
387
388
  '&.is-info': {
388
389
  bg: 'blue-100',
389
- path: {
390
- fill: 'blue-600'
390
+ span: {
391
+ fontSize: 'md',
392
+ color: 'blue-600'
391
393
  }
392
394
  },
393
395
  '&.is-major': {
394
396
  bg: 'orange-100',
395
- path: {
396
- fill: 'orange-700'
397
+ span: {
398
+ fontSize: 'md',
399
+ color: 'orange-700'
397
400
  }
398
401
  },
399
402
  '&.is-minor': {
400
403
  bg: 'yellow-100',
401
- path: {
402
- fill: 'yellow-800'
404
+ span: {
405
+ fontSize: 'md',
406
+ color: 'yellow-800'
403
407
  }
404
408
  },
405
409
  '&.is-warning-neutral': {
406
410
  bg: 'gray-100',
407
- path: {
408
- fill: 'gray-700'
411
+ span: {
412
+ fontSize: 'md',
413
+ color: 'gray-700'
409
414
  }
410
415
  },
411
416
  '&.is-fatal': {
412
417
  bg: 'gray-700',
413
- path: {
414
- fill: 'gray-100'
418
+ span: {
419
+ fontSize: 'md',
420
+ color: 'gray-100'
415
421
  }
416
422
  },
417
423
  '&.is-selected.is-selected': {
418
424
  bg: 'white',
419
- '& > svg': {
420
- path: {
421
- fill: 'active'
422
- }
425
+ span: {
426
+ color: 'active'
423
427
  }
424
428
  }
425
429
  }
@@ -1,4 +1,5 @@
1
1
  import { ReactNode } from 'react';
2
+ import type { MaterialSymbol } from '@material-symbols/font-400';
2
3
  import { TestingAttributes } from './shared/test';
3
4
  import { DOMAttributes, IconSize, StyleProps } from './shared';
4
5
  export type SVGComponentProps = {
@@ -23,8 +24,9 @@ export interface IconProps extends StyleProps, DOMAttributes, TestingAttributes
23
24
  name: string;
24
25
  };
25
26
  /** The icon to render. */
26
- icon?: IconTypeExtended;
27
+ icon?: IconTypeExtended | MaterialSymbol | string;
27
28
  size?: IconSize;
28
29
  /** A theme-aware prop to set the icon's color. */
29
30
  color?: string;
31
+ hasFill?: boolean;
30
32
  }
@@ -1,4 +1,5 @@
1
1
  import React, { Key } from 'react';
2
+ import type { MaterialSymbol } from '@material-symbols/font-400';
2
3
  import { ThemeUICSSObject } from 'theme-ui';
3
4
  import { IconProps, IconTypeExtended } from './icon';
4
5
  import { DOMAttributes, StyleProps } from './shared';
@@ -27,7 +28,7 @@ export interface NavBarItemProps extends StyleProps, DOMAttributes {
27
28
  /** Handler that is called when the press is released over the target. */
28
29
  onPress?: () => void;
29
30
  /** The icon to render in between each node. */
30
- icon?: IconTypeExtended;
31
+ icon?: IconTypeExtended | MaterialSymbol | string;
31
32
  /** The element's unique identifier. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id). */
32
33
  id?: string;
33
34
  /** Text that will render within the component */
@@ -1,53 +1,17 @@
1
- import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
2
- import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
3
- import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
4
- import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
5
- import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
6
- import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
7
- import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
8
- import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
9
1
  import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
10
- import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
11
- import _typeof from "@babel/runtime-corejs3/helpers/esm/typeof";
12
- import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
13
- var _excluded = ["color", "icon", "sx", "size", "variant", "title"];
14
- function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
15
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
16
2
  import React, { forwardRef } from 'react';
17
- import { useGetTheme, useTShirtSize } from '../../hooks';
18
- import Box from '../Box';
3
+ import IconDefault from './IconDefault';
4
+ import IconSymbol from './IconSymbol';
19
5
  import { jsx as ___EmotionJSX } from "@emotion/react";
20
6
  var Icon = /*#__PURE__*/forwardRef(function (props, ref) {
21
- var theme = useGetTheme();
22
- var color = props.color,
23
- IconComponent = props.icon,
24
- sx = props.sx,
25
- _props$size = props.size,
26
- size = _props$size === void 0 ? theme.defaultIconSize : _props$size,
27
- variant = props.variant,
28
- title = props.title,
29
- others = _objectWithoutProperties(props, _excluded);
30
- var _useTShirtSize = useTShirtSize({
31
- size: size,
32
- sizes: theme.tShirtSizes
33
- }),
34
- sizeProps = _useTShirtSize.sizeProps;
35
- var defaultIconColor = theme.defaultIconColor;
36
- var resolvedTitle = title !== null && title !== void 0 ? title : _typeof(IconComponent) === 'object' && 'type' in IconComponent ? {
37
- name: IconComponent.type.name
38
- } : '';
39
- return ___EmotionJSX(Box, _extends({
40
- as: IconComponent,
41
- ref: ref,
42
- role: "img",
43
- title: resolvedTitle,
44
- variant: variant,
45
- size: sizeProps.size,
46
- sx: _objectSpread({
47
- fill: color || defaultIconColor,
48
- minWidth: sizeProps.size
49
- }, sx)
50
- }, others));
7
+ var icon = props.icon;
8
+ if (typeof icon === 'string') {
9
+ return ___EmotionJSX(IconSymbol, _extends({}, props, {
10
+ ref: ref
11
+ }));
12
+ }
13
+ return ___EmotionJSX(IconDefault, _extends({}, props, {
14
+ ref: ref
15
+ }));
51
16
  });
52
- Icon.displayName = 'Icon';
53
17
  export default Icon;
@@ -3,7 +3,7 @@ import React, { forwardRef } from 'react';
3
3
  import Earth from '@pingux/mdi-react/EarthIcon';
4
4
  import { render, screen } from '@testing-library/react';
5
5
  import { universalComponentTests } from '../../utils/testUtils/universalComponentTest';
6
- import Icon from '.';
6
+ import Icon from './Icon';
7
7
  import { jsx as ___EmotionJSX } from "@emotion/react";
8
8
  var testId = 'test-icon';
9
9
  var defaultProps = {
@@ -45,40 +45,11 @@ test('default icon', function () {
45
45
  expect(icon).toBeInstanceOf(SVGSVGElement);
46
46
  expect(icon).toBeInTheDocument();
47
47
  });
48
- test('icon renders correct xxsmall tshirt size', function () {
48
+ test('icon render for type symbol', function () {
49
49
  getComponent({
50
- size: 'xxs'
50
+ icon: 'search'
51
51
  });
52
- var xsIcon = screen.getByTestId(testId);
53
- expect(xsIcon).toHaveStyleRule('width', '9px');
54
- });
55
- test('icon renders correct xsmall tshirt size', function () {
56
- getComponent({
57
- size: 'xs'
58
- });
59
- var xsIcon = screen.getByTestId(testId);
60
- expect(xsIcon).toHaveStyleRule('width', '15px');
61
- });
62
- test('icon renders correct small tshirt size', function () {
63
- getComponent({
64
- size: 'sm'
65
- });
66
- var smIcon = screen.getByTestId(testId);
67
- expect(smIcon).toHaveStyleRule('width', '20px');
68
- });
69
- test('icon renders correct medium tshirt size', function () {
70
- getComponent({
71
- size: 'md'
72
- });
73
- var mdIcon = screen.getByTestId(testId);
74
- expect(mdIcon).toHaveStyleRule('width', '25px');
75
- });
76
- test('icon renders with associated title', function () {
77
- getComponent();
78
52
  var icon = screen.getByTestId(testId);
79
- var title = screen.getByText('Earth Icon');
80
- expect(icon).toBeInstanceOf(SVGSVGElement);
81
- expect(icon).toBeInTheDocument();
82
- expect(icon).toHaveAttribute('aria-labelledby', 'title-id');
83
- expect(title).toBeInTheDocument();
53
+ expect(icon).toHaveClass('material-symbols-outlined');
54
+ screen.getByText(/search/i);
84
55
  });
@@ -0,0 +1,53 @@
1
+ import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
2
+ import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
3
+ import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
4
+ import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
5
+ import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
6
+ import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
7
+ import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
8
+ import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
9
+ import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
10
+ import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
11
+ import _typeof from "@babel/runtime-corejs3/helpers/esm/typeof";
12
+ import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
13
+ var _excluded = ["color", "icon", "sx", "size", "variant", "title"];
14
+ function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
15
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
16
+ import React, { forwardRef } from 'react';
17
+ import { useGetTheme, useTShirtSize } from '../../hooks';
18
+ import Box from '../Box';
19
+ import { jsx as ___EmotionJSX } from "@emotion/react";
20
+ var IconDefault = /*#__PURE__*/forwardRef(function (props, ref) {
21
+ var theme = useGetTheme();
22
+ var color = props.color,
23
+ IconComponent = props.icon,
24
+ sx = props.sx,
25
+ _props$size = props.size,
26
+ size = _props$size === void 0 ? theme.defaultIconSize : _props$size,
27
+ variant = props.variant,
28
+ title = props.title,
29
+ others = _objectWithoutProperties(props, _excluded);
30
+ var _useTShirtSize = useTShirtSize({
31
+ size: size,
32
+ sizes: theme.tShirtSizes
33
+ }),
34
+ sizeProps = _useTShirtSize.sizeProps;
35
+ var defaultIconColor = theme.defaultIconColor;
36
+ var resolvedTitle = title !== null && title !== void 0 ? title : _typeof(IconComponent) === 'object' && 'type' in IconComponent ? {
37
+ name: IconComponent.type.name
38
+ } : '';
39
+ return ___EmotionJSX(Box, _extends({
40
+ as: IconComponent,
41
+ ref: ref,
42
+ role: "img",
43
+ title: resolvedTitle,
44
+ variant: variant,
45
+ size: sizeProps.size,
46
+ sx: _objectSpread({
47
+ fill: color || defaultIconColor,
48
+ minWidth: sizeProps.size
49
+ }, sx)
50
+ }, others));
51
+ });
52
+ IconDefault.displayName = 'Icon';
53
+ export default IconDefault;
@@ -0,0 +1,84 @@
1
+ import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
2
+ import React, { forwardRef } from 'react';
3
+ import Earth from '@pingux/mdi-react/EarthIcon';
4
+ import { render, screen } from '@testing-library/react';
5
+ import { universalComponentTests } from '../../utils/testUtils/universalComponentTest';
6
+ import Icon from './IconDefault';
7
+ import { jsx as ___EmotionJSX } from "@emotion/react";
8
+ var testId = 'test-icon';
9
+ var defaultProps = {
10
+ 'data-testid': testId,
11
+ icon: Earth,
12
+ title: {
13
+ id: 'title-id',
14
+ name: 'Earth Icon'
15
+ }
16
+ };
17
+ var getComponent = function getComponent() {
18
+ var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
19
+ return render(___EmotionJSX(Icon, _extends({}, defaultProps, props)));
20
+ };
21
+
22
+ // The mdi-react and @pingux/mid-react libraries don't support ref forwarding
23
+ // A simple implementation of an SVG component demonstrates ref forwarding
24
+ var SVGTestComponent = /*#__PURE__*/forwardRef(function (props, ref) {
25
+ return ___EmotionJSX("svg", _extends({
26
+ ref: ref
27
+ }, props, {
28
+ "aria-labelledby": "id"
29
+ }), ___EmotionJSX("title", {
30
+ id: "id"
31
+ }, "title"));
32
+ });
33
+
34
+ // Needs to be added to each components test file
35
+ universalComponentTests({
36
+ renderComponent: function renderComponent(props) {
37
+ return ___EmotionJSX(Icon, _extends({
38
+ icon: SVGTestComponent
39
+ }, props));
40
+ }
41
+ });
42
+ test('default icon', function () {
43
+ getComponent();
44
+ var icon = screen.getByTestId(testId);
45
+ expect(icon).toBeInstanceOf(SVGSVGElement);
46
+ expect(icon).toBeInTheDocument();
47
+ });
48
+ test('icon renders correct xxsmall tshirt size', function () {
49
+ getComponent({
50
+ size: 'xxs'
51
+ });
52
+ var xsIcon = screen.getByTestId(testId);
53
+ expect(xsIcon).toHaveStyleRule('width', '9px');
54
+ });
55
+ test('icon renders correct xsmall tshirt size', function () {
56
+ getComponent({
57
+ size: 'xs'
58
+ });
59
+ var xsIcon = screen.getByTestId(testId);
60
+ expect(xsIcon).toHaveStyleRule('width', '15px');
61
+ });
62
+ test('icon renders correct small tshirt size', function () {
63
+ getComponent({
64
+ size: 'sm'
65
+ });
66
+ var smIcon = screen.getByTestId(testId);
67
+ expect(smIcon).toHaveStyleRule('width', '20px');
68
+ });
69
+ test('icon renders correct medium tshirt size', function () {
70
+ getComponent({
71
+ size: 'md'
72
+ });
73
+ var mdIcon = screen.getByTestId(testId);
74
+ expect(mdIcon).toHaveStyleRule('width', '25px');
75
+ });
76
+ test('icon renders with associated title', function () {
77
+ getComponent();
78
+ var icon = screen.getByTestId(testId);
79
+ var title = screen.getByText('Earth Icon');
80
+ expect(icon).toBeInstanceOf(SVGSVGElement);
81
+ expect(icon).toBeInTheDocument();
82
+ expect(icon).toHaveAttribute('aria-labelledby', 'title-id');
83
+ expect(title).toBeInTheDocument();
84
+ });
@@ -0,0 +1,50 @@
1
+ import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
2
+ import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
3
+ import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
4
+ import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
5
+ import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
6
+ import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
7
+ import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
8
+ import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
9
+ import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
10
+ import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
11
+ import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
12
+ var _excluded = ["icon", "className", "title", "size", "color", "hasFill"];
13
+ function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
14
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
15
+ import React, { forwardRef } from 'react';
16
+ import { useGetTheme, useTShirtSize } from '../../hooks';
17
+ import Box from '../Box';
18
+ import { jsx as ___EmotionJSX } from "@emotion/react";
19
+ var IconSymbol = /*#__PURE__*/forwardRef(function (props, ref) {
20
+ var theme = useGetTheme();
21
+ var _props$icon = props.icon,
22
+ icon = _props$icon === void 0 ? 'disabled_by_default' : _props$icon,
23
+ className = props.className,
24
+ title = props.title,
25
+ _props$size = props.size,
26
+ size = _props$size === void 0 ? theme.defaultIconSize : _props$size,
27
+ _props$color = props.color,
28
+ color = _props$color === void 0 ? theme.defaultIconColor : _props$color,
29
+ hasFill = props.hasFill,
30
+ rest = _objectWithoutProperties(props, _excluded);
31
+ var _useTShirtSize = useTShirtSize({
32
+ size: size,
33
+ sizes: theme.tShirtSizes
34
+ }),
35
+ sizeProps = _useTShirtSize.sizeProps;
36
+ return ___EmotionJSX(Box, _extends({
37
+ as: "span",
38
+ ref: ref,
39
+ className: "material-symbols-outlined ".concat(className || ''),
40
+ title: title === null || title === void 0 ? void 0 : title.name
41
+ }, rest, {
42
+ sx: _objectSpread(_objectSpread({}, rest.sx), {}, {
43
+ color: color,
44
+ fontSize: sizeProps.size,
45
+ fontVariationSettings: hasFill ? "'FILL' 1" : "'FILL' 0"
46
+ })
47
+ }), icon);
48
+ });
49
+ IconSymbol.displayName = 'Icon';
50
+ export default IconSymbol;
@@ -0,0 +1,46 @@
1
+ import { Meta } from '@storybook/addon-docs';
2
+
3
+ <Meta title="Components/Icon/Icon" />
4
+
5
+ # Icon
6
+
7
+ Icons are small images that represent concepts or capabilities that often provide information or lead users to other pages within the application.
8
+
9
+ Icon should be:
10
+ - Centrally aligned when used in a group with an appropriate amount of space between them.
11
+ - Paired with text or a tooltip when its intention is not immediately evident.
12
+ - Relatively sized when used with text.
13
+
14
+ Icon shouldn’t:
15
+ - Include letters in the icon design.
16
+ - Be randomly scaled to fit the layout.
17
+
18
+ Regarding sizing, this component uses the **1em x 1em** container by default and maintains the aspect ratios. You can:
19
+
20
+ - Use the theme to color the icon.
21
+
22
+ - Use font icon text from the [Material Symbol Library](https://marella.github.io/material-symbols/demo/)
23
+
24
+ It is built on top of the [Box from Theme-UI](https://theme-ui.com/components/box/) and uses the available [props from Theme-UI](https://theme-ui.com/sx-prop).
25
+
26
+ ### Required Components
27
+
28
+ This component can be used independently and does not require additional components.
29
+
30
+ ### Accessibility
31
+
32
+ #### Labelling
33
+
34
+ The Icon component accepts the title prop:
35
+ `title={{ id: 'unique id', name: 'short description of the icon'}}`.
36
+ The `name` will be passed inside title attribute of span element.
37
+ The `id` is optional. If not specified, it will be generated automatically.
38
+ This is needed to make font icon accessible.
39
+
40
+ #### Screen Readers
41
+
42
+ If the icon has a title associated with it, the **`aria-labelledby`** attribute is used to provide the label ID.
43
+
44
+
45
+
46
+
@@ -0,0 +1,77 @@
1
+ import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
2
+ import React from 'react';
3
+ import { render, screen } from '@testing-library/react';
4
+ import { universalComponentTests } from '../../utils/testUtils/universalComponentTest';
5
+ import IconSymbol from './IconSymbol';
6
+ import { jsx as ___EmotionJSX } from "@emotion/react";
7
+ var testId = 'test-icon';
8
+ var testIcon = 'Search';
9
+ var defaultProps = {
10
+ 'data-testid': testId,
11
+ icon: testIcon,
12
+ title: {
13
+ id: 'title-id',
14
+ name: 'Search Icon'
15
+ }
16
+ };
17
+ var getComponent = function getComponent() {
18
+ var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
19
+ return render(___EmotionJSX(IconSymbol, _extends({}, defaultProps, props)));
20
+ };
21
+
22
+ // Needs to be added to each components test file
23
+ universalComponentTests({
24
+ renderComponent: function renderComponent(props) {
25
+ return ___EmotionJSX(IconSymbol, _extends({
26
+ icon: testIcon
27
+ }, props));
28
+ }
29
+ });
30
+ test('default icon', function () {
31
+ getComponent();
32
+ var icon = screen.getByTestId(testId);
33
+ expect(icon).toHaveClass('material-symbols-outlined');
34
+ screen.getByText(/search/i);
35
+ });
36
+ test('default icon', function () {
37
+ getComponent({
38
+ icon: 'face'
39
+ });
40
+ var icon = screen.getByTestId(testId);
41
+ expect(icon).toHaveClass('material-symbols-outlined');
42
+ screen.getByText(/face/i);
43
+ });
44
+ test('size prop', function () {
45
+ getComponent({
46
+ size: 'sm'
47
+ });
48
+ var icon = screen.getByTestId(testId);
49
+ expect(icon).toHaveStyle('font-size: 20px');
50
+ });
51
+ test('color prop', function () {
52
+ getComponent({
53
+ color: 'red'
54
+ });
55
+ var icon = screen.getByTestId(testId);
56
+ expect(icon).toHaveStyle('color: red');
57
+ });
58
+ test('hasFill prop', function () {
59
+ getComponent({
60
+ hasFill: true
61
+ });
62
+ var icon = screen.getByTestId(testId);
63
+ expect(icon).toHaveStyle("font-variation-settings: 'FILL' 1");
64
+ });
65
+ test('title prop', function () {
66
+ getComponent();
67
+ var icon = screen.getByTestId(testId);
68
+ expect(icon).toHaveAttribute('title', 'Search Icon');
69
+ });
70
+ test('className prop', function () {
71
+ var customClass = 'custom-icon-class';
72
+ getComponent({
73
+ className: customClass
74
+ });
75
+ var icon = screen.getByTestId(testId);
76
+ expect(icon).toHaveClass(customClass);
77
+ });