@pingux/astro 2.170.1-alpha.0 → 2.172.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.
- package/lib/cjs/components/Avatar/Avatar.js +13 -2
- package/lib/cjs/components/Avatar/Avatar.test.js +95 -1
- package/lib/cjs/components/Avatar/constants.d.ts +2 -0
- package/lib/cjs/components/Avatar/constants.js +8 -0
- package/lib/cjs/components/Avatar/getColorFromUuid.d.ts +2 -0
- package/lib/cjs/components/Avatar/getColorFromUuid.js +37 -0
- package/lib/cjs/components/Icon/Icon.js +15 -49
- package/lib/cjs/components/Icon/Icon.test.js +7 -36
- package/lib/cjs/components/Icon/IconDefault.d.ts +4 -0
- package/lib/cjs/components/Icon/IconDefault.js +63 -0
- package/lib/cjs/components/Icon/IconDefault.test.js +92 -0
- package/lib/cjs/components/Icon/IconSymbol.d.ts +4 -0
- package/lib/cjs/components/Icon/IconSymbol.js +60 -0
- package/lib/cjs/components/Icon/IconSymbol.mdx +46 -0
- package/lib/cjs/components/Icon/IconSymbol.test.js +80 -0
- package/lib/cjs/components/Icon/MaterialSymbolIcon.stories.d.ts +7 -0
- package/lib/cjs/components/Icon/MaterialSymbolIcon.stories.js +207 -0
- package/lib/cjs/hooks/useGetTheme/useGetTheme.d.ts +31 -31
- package/lib/cjs/index.d.ts +1 -0
- package/lib/cjs/index.js +1 -0
- package/lib/cjs/styles/themeOverrides/nextGenDarkMode/customProperties/icons.d.ts +31 -31
- package/lib/cjs/styles/themeOverrides/nextGenDarkMode/customProperties/index.d.ts +31 -31
- package/lib/cjs/styles/themeOverrides/nextGenDarkMode/variants/variants.d.ts +18 -20
- package/lib/cjs/styles/themeOverrides/nextGenDarkMode/variants/variants.js +18 -20
- package/lib/cjs/styles/themeOverrides/onyxSideNav.d.ts +32 -29
- package/lib/cjs/styles/themeOverrides/onyxSideNav.js +3 -0
- package/lib/cjs/styles/themes/next-gen/convertedComponentList.d.ts +1 -0
- package/lib/cjs/styles/themes/next-gen/convertedComponentList.js +3 -2
- package/lib/cjs/styles/themes/next-gen/customProperties/icons.d.ts +32 -32
- package/lib/cjs/styles/themes/next-gen/customProperties/icons.js +1 -32
- package/lib/cjs/styles/themes/next-gen/customProperties/index.d.ts +32 -32
- package/lib/cjs/styles/themes/next-gen/next-gen.d.ts +60 -56
- package/lib/cjs/styles/themes/next-gen/variants/variants.d.ts +28 -24
- package/lib/cjs/styles/themes/next-gen/variants/variants.js +28 -24
- package/lib/cjs/types/avatar.d.ts +2 -0
- package/lib/cjs/types/icon.d.ts +3 -1
- package/lib/cjs/types/navBar.d.ts +2 -1
- package/lib/components/Avatar/Avatar.js +14 -3
- package/lib/components/Avatar/Avatar.test.js +95 -1
- package/lib/components/Avatar/constants.js +2 -0
- package/lib/components/Avatar/getColorFromUuid.js +29 -0
- package/lib/components/Icon/Icon.js +11 -47
- package/lib/components/Icon/Icon.test.js +5 -34
- package/lib/components/Icon/IconDefault.js +53 -0
- package/lib/components/Icon/IconDefault.test.js +84 -0
- package/lib/components/Icon/IconSymbol.js +50 -0
- package/lib/components/Icon/IconSymbol.mdx +46 -0
- package/lib/components/Icon/IconSymbol.test.js +77 -0
- package/lib/components/Icon/MaterialSymbolIcon.stories.js +200 -0
- package/lib/index.js +1 -1
- package/lib/styles/themeOverrides/nextGenDarkMode/variants/variants.js +18 -20
- package/lib/styles/themeOverrides/onyxSideNav.js +3 -0
- package/lib/styles/themes/next-gen/convertedComponentList.js +3 -2
- package/lib/styles/themes/next-gen/customProperties/icons.js +1 -32
- package/lib/styles/themes/next-gen/variants/variants.js +28 -24
- package/lib/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +4 -2
|
@@ -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
|
|
18
|
-
import
|
|
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
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
|
48
|
+
test('icon render for type symbol', function () {
|
|
49
49
|
getComponent({
|
|
50
|
-
|
|
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
|
-
|
|
80
|
-
|
|
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
|
+
});
|
|
@@ -0,0 +1,200 @@
|
|
|
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 _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
|
12
|
+
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; }
|
|
13
|
+
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; }
|
|
14
|
+
import React from 'react';
|
|
15
|
+
import { withDesign } from 'storybook-addon-designs';
|
|
16
|
+
import DocsLayout from '../../../.storybook/storybookDocsLayout';
|
|
17
|
+
import { Box, Icon, Table, TableBody, TableCell, TableHead, TableRow, Text } from '../../index';
|
|
18
|
+
import { FIGMA_LINKS } from '../../utils/designUtils/figmaLinks';
|
|
19
|
+
import { sizeArgTypes } from '../../utils/docUtils/iconSizeProps';
|
|
20
|
+
import IconReadme from './IconSymbol.mdx';
|
|
21
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
22
|
+
export default {
|
|
23
|
+
title: 'Components/MaterialSymbolIcon',
|
|
24
|
+
component: Icon,
|
|
25
|
+
decorators: [withDesign],
|
|
26
|
+
parameters: {
|
|
27
|
+
docs: {
|
|
28
|
+
page: function page() {
|
|
29
|
+
return ___EmotionJSX(React.Fragment, null, ___EmotionJSX(IconReadme, null), ___EmotionJSX(DocsLayout, null));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
argTypes: _objectSpread({
|
|
34
|
+
icon: {
|
|
35
|
+
control: {
|
|
36
|
+
type: {
|
|
37
|
+
name: 'string'
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
description: 'The font icon to render. List of font icons at https://marella.github.io/material-symbols/demo/'
|
|
41
|
+
}
|
|
42
|
+
}, sizeArgTypes),
|
|
43
|
+
args: {
|
|
44
|
+
icon: 'disabled_by_default',
|
|
45
|
+
className: 'material-symbols-outlined',
|
|
46
|
+
size: 'md'
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
export var Default = function Default(args) {
|
|
50
|
+
return ___EmotionJSX(Icon, _extends({}, args, {
|
|
51
|
+
icon: "search",
|
|
52
|
+
title: {
|
|
53
|
+
name: 'Search Icon'
|
|
54
|
+
}
|
|
55
|
+
}));
|
|
56
|
+
};
|
|
57
|
+
Default.parameters = {
|
|
58
|
+
design: {
|
|
59
|
+
type: 'figma',
|
|
60
|
+
url: FIGMA_LINKS.icon["default"]
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
var rowHeadings = ['Size', 'Code Example', 'Icon Example'];
|
|
64
|
+
export var Sizes = function Sizes() {
|
|
65
|
+
return ___EmotionJSX(Table, null, ___EmotionJSX(TableHead, null, ___EmotionJSX(TableRow, {
|
|
66
|
+
key: "head"
|
|
67
|
+
}, _mapInstanceProperty(rowHeadings).call(rowHeadings, function (head) {
|
|
68
|
+
return ___EmotionJSX(TableCell, {
|
|
69
|
+
isHeading: true,
|
|
70
|
+
key: head
|
|
71
|
+
}, head);
|
|
72
|
+
}))), ___EmotionJSX(TableBody, {
|
|
73
|
+
sx: {
|
|
74
|
+
borderBottom: 'unset'
|
|
75
|
+
}
|
|
76
|
+
}, ___EmotionJSX(TableRow, {
|
|
77
|
+
height: "80px",
|
|
78
|
+
bg: "transparent !important"
|
|
79
|
+
}, ___EmotionJSX(TableCell, {
|
|
80
|
+
justifyContent: "center"
|
|
81
|
+
}, ___EmotionJSX(Text, null, "XXS | 9px")), ___EmotionJSX(TableCell, null, ___EmotionJSX(Text, {
|
|
82
|
+
fontFamily: "monospace"
|
|
83
|
+
}, '<Icon icon="search" size="xxs"/>')), ___EmotionJSX(TableCell, {
|
|
84
|
+
justifyContent: "center"
|
|
85
|
+
}, ___EmotionJSX(Icon, {
|
|
86
|
+
icon: "search",
|
|
87
|
+
title: {
|
|
88
|
+
name: 'Search Icon'
|
|
89
|
+
},
|
|
90
|
+
size: "xxs"
|
|
91
|
+
}))), ___EmotionJSX(TableRow, {
|
|
92
|
+
height: "80px",
|
|
93
|
+
bg: "transparent !important"
|
|
94
|
+
}, ___EmotionJSX(TableCell, {
|
|
95
|
+
justifyContent: "center"
|
|
96
|
+
}, ___EmotionJSX(Text, null, "XS | 15px")), ___EmotionJSX(TableCell, null, ___EmotionJSX(Text, {
|
|
97
|
+
fontFamily: "monospace"
|
|
98
|
+
}, '<Icon icon="search" size="xs"/>')), ___EmotionJSX(TableCell, {
|
|
99
|
+
justifyContent: "center"
|
|
100
|
+
}, ___EmotionJSX(Icon, {
|
|
101
|
+
icon: "search",
|
|
102
|
+
size: "xs",
|
|
103
|
+
title: {
|
|
104
|
+
name: 'Search Icon'
|
|
105
|
+
}
|
|
106
|
+
}))), ___EmotionJSX(TableRow, {
|
|
107
|
+
height: "80px",
|
|
108
|
+
bg: "transparent !important"
|
|
109
|
+
}, ___EmotionJSX(TableCell, {
|
|
110
|
+
justifyContent: "center"
|
|
111
|
+
}, ___EmotionJSX(Text, null, "SM | 20px")), ___EmotionJSX(TableCell, null, ___EmotionJSX(Text, {
|
|
112
|
+
fontFamily: "monospace"
|
|
113
|
+
}, '<Icon icon="search" size="sm"/>')), ___EmotionJSX(TableCell, {
|
|
114
|
+
justifyContent: "center"
|
|
115
|
+
}, ___EmotionJSX(Icon, {
|
|
116
|
+
icon: "search",
|
|
117
|
+
size: "sm",
|
|
118
|
+
title: {
|
|
119
|
+
name: 'Search Icon'
|
|
120
|
+
}
|
|
121
|
+
}))), ___EmotionJSX(TableRow, {
|
|
122
|
+
height: "80px",
|
|
123
|
+
bg: "transparent !important"
|
|
124
|
+
}, ___EmotionJSX(TableCell, {
|
|
125
|
+
justifyContent: "center"
|
|
126
|
+
}, ___EmotionJSX(Text, null, "MD | 25px")), ___EmotionJSX(TableCell, null, ___EmotionJSX(Text, {
|
|
127
|
+
fontFamily: "monospace"
|
|
128
|
+
}, '<Icon icon="search" size="md"/>')), ___EmotionJSX(TableCell, {
|
|
129
|
+
justifyContent: "center"
|
|
130
|
+
}, ___EmotionJSX(Icon, {
|
|
131
|
+
icon: "search",
|
|
132
|
+
size: "md",
|
|
133
|
+
title: {
|
|
134
|
+
name: 'Search Icon'
|
|
135
|
+
}
|
|
136
|
+
})))));
|
|
137
|
+
};
|
|
138
|
+
export var CommonlyUsed = function CommonlyUsed() {
|
|
139
|
+
return ___EmotionJSX(React.Fragment, null, ___EmotionJSX(Box, {
|
|
140
|
+
isRow: true,
|
|
141
|
+
gap: "md",
|
|
142
|
+
mb: "xs"
|
|
143
|
+
}, ___EmotionJSX(Icon, {
|
|
144
|
+
icon: "account_circle",
|
|
145
|
+
color: "accent.40",
|
|
146
|
+
size: "sm",
|
|
147
|
+
title: {
|
|
148
|
+
name: 'Account Icon'
|
|
149
|
+
},
|
|
150
|
+
hasFill: true
|
|
151
|
+
})), ___EmotionJSX(Box, {
|
|
152
|
+
isRow: true,
|
|
153
|
+
gap: "md",
|
|
154
|
+
mb: "xs"
|
|
155
|
+
}, ___EmotionJSX(Icon, {
|
|
156
|
+
icon: "groups",
|
|
157
|
+
color: "accent.40",
|
|
158
|
+
size: "sm",
|
|
159
|
+
title: {
|
|
160
|
+
name: 'Account Group Icon'
|
|
161
|
+
},
|
|
162
|
+
hasFill: true
|
|
163
|
+
})), ___EmotionJSX(Box, {
|
|
164
|
+
isRow: true,
|
|
165
|
+
gap: "md",
|
|
166
|
+
mb: "xs"
|
|
167
|
+
}, ___EmotionJSX(Icon, {
|
|
168
|
+
icon: "lock",
|
|
169
|
+
color: "accent.40",
|
|
170
|
+
size: "sm",
|
|
171
|
+
title: {
|
|
172
|
+
name: 'Lock Icon'
|
|
173
|
+
},
|
|
174
|
+
hasFill: true
|
|
175
|
+
})), ___EmotionJSX(Box, {
|
|
176
|
+
isRow: true,
|
|
177
|
+
gap: "md",
|
|
178
|
+
mb: "xs"
|
|
179
|
+
}, ___EmotionJSX(Icon, {
|
|
180
|
+
icon: "search",
|
|
181
|
+
color: "accent.40",
|
|
182
|
+
size: "sm",
|
|
183
|
+
title: {
|
|
184
|
+
name: 'Search Icon'
|
|
185
|
+
},
|
|
186
|
+
hasFill: true
|
|
187
|
+
})), ___EmotionJSX(Box, {
|
|
188
|
+
isRow: true,
|
|
189
|
+
gap: "md",
|
|
190
|
+
mb: "xs"
|
|
191
|
+
}, ___EmotionJSX(Icon, {
|
|
192
|
+
icon: "notifications",
|
|
193
|
+
color: "accent.40",
|
|
194
|
+
size: "sm",
|
|
195
|
+
title: {
|
|
196
|
+
name: 'Notification Icon'
|
|
197
|
+
},
|
|
198
|
+
hasFill: true
|
|
199
|
+
})));
|
|
200
|
+
};
|
package/lib/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// NOTE: Named exports must be unique across files, otherwise collisions will occur.
|
|
2
2
|
|
|
3
3
|
/* eslint-disable import/export */
|
|
4
|
-
|
|
4
|
+
import '@material-symbols/font-400';
|
|
5
5
|
export { default as AccordionGridGroup } from './components/AccordionGridGroup';
|
|
6
6
|
export * from './components/AccordionGridGroup';
|
|
7
7
|
export { default as AccordionGridItem } from './components/AccordionGridItem';
|