@sb1/ffe-symbols-react 2.0.2 → 2.0.4
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/CHANGELOG.md +12 -0
- package/es/Symbol.js +6 -11
- package/lib/Symbol.js +8 -15
- package/lib/index.js +2 -2
- package/package.json +2 -2
- package/src/Symbol.js +5 -22
- package/src/Symbol.spec.js +6 -11
- package/src/index.d.ts +4 -2
- package/types/index.d.ts +4 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [2.0.4](https://github.com/SpareBank1/designsystem/compare/@sb1/ffe-symbols-react@2.0.3...@sb1/ffe-symbols-react@2.0.4) (2023-11-02)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- **ffe-symbols-react:** oppdater symbol implementasjon ([6f2369d](https://github.com/SpareBank1/designsystem/commit/6f2369def69327cb981ae6b54ee6b503591c357a))
|
|
11
|
+
|
|
12
|
+
## [2.0.3](https://github.com/SpareBank1/designsystem/compare/@sb1/ffe-symbols-react@2.0.2...@sb1/ffe-symbols-react@2.0.3) (2023-10-02)
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
- **ffe-symbols-react:** legg til export statement i index.d.ts ([c71e8d2](https://github.com/SpareBank1/designsystem/commit/c71e8d226db4a08d5cb36f946cb99d656af892f2))
|
|
17
|
+
|
|
6
18
|
## [2.0.2](https://github.com/SpareBank1/designsystem/compare/@sb1/ffe-symbols-react@2.0.1...@sb1/ffe-symbols-react@2.0.2) (2023-09-15)
|
|
7
19
|
|
|
8
20
|
**Note:** Version bump only for package @sb1/ffe-symbols-react
|
package/es/Symbol.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _excluded = ["className", "
|
|
1
|
+
var _excluded = ["className", "size", "weight", "fill", "ariaLabel", "icon"];
|
|
2
2
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); }
|
|
3
3
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
4
4
|
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; }
|
|
@@ -7,18 +7,18 @@ import { string, bool, oneOf } from 'prop-types';
|
|
|
7
7
|
import classNames from 'classnames';
|
|
8
8
|
var _Symbol = function _Symbol(props) {
|
|
9
9
|
var className = props.className,
|
|
10
|
-
children = props.children,
|
|
11
10
|
size = props.size,
|
|
12
11
|
weight = props.weight,
|
|
13
12
|
fill = props.fill,
|
|
14
13
|
ariaLabel = props.ariaLabel,
|
|
14
|
+
icon = props.icon,
|
|
15
15
|
rest = _objectWithoutProperties(props, _excluded);
|
|
16
16
|
return /*#__PURE__*/React.createElement("span", _extends({
|
|
17
17
|
className: classNames('ffe-symbol', fill ? "ffe-symbol--filled-".concat(weight) : "ffe-symbol--".concat(weight), size && "ffe-symbol--".concat(size), className),
|
|
18
18
|
role: "graphics-symbol img",
|
|
19
19
|
"aria-label": ariaLabel ? ariaLabel : null,
|
|
20
20
|
"aria-hidden": !ariaLabel
|
|
21
|
-
}, rest),
|
|
21
|
+
}, rest), icon);
|
|
22
22
|
};
|
|
23
23
|
export { _Symbol as Symbol };
|
|
24
24
|
_Symbol.defaultProps = {
|
|
@@ -29,19 +29,14 @@ _Symbol.propTypes = {
|
|
|
29
29
|
/** Fills the icon with color */
|
|
30
30
|
fill: bool,
|
|
31
31
|
/** The name of the icon that should be shown */
|
|
32
|
-
|
|
32
|
+
icon: string.isRequired,
|
|
33
33
|
/** Size of the icon, default is the closest defined font-size */
|
|
34
34
|
size: oneOf(['xs', 'sm', 'md', 'lg', 'xl', '2xl']),
|
|
35
35
|
/** Symbols stroke weight. This can affect overall size of symbol, 400 is default */
|
|
36
36
|
weight: oneOf([300, 400, 500]),
|
|
37
37
|
/** Additional classnames */
|
|
38
38
|
className: string,
|
|
39
|
-
/** Aria label text. If null, aria-hidden is automatically set to true */
|
|
40
|
-
ariaLabel:
|
|
41
|
-
var propValue = props[propName];
|
|
42
|
-
if (propValue !== null && typeof propValue !== 'string') {
|
|
43
|
-
return new Error("Invalid prop '".concat(propName, "' supplied to '").concat(componentName, "'. ") + "'".concat(propName, "' must be a string or null."));
|
|
44
|
-
}
|
|
45
|
-
}
|
|
39
|
+
/** Aria label text. If null/undefined, aria-hidden is automatically set to true */
|
|
40
|
+
ariaLabel: string
|
|
46
41
|
};
|
|
47
42
|
export default _Symbol;
|
package/lib/Symbol.js
CHANGED
|
@@ -7,27 +7,26 @@ exports.default = exports.Symbol = void 0;
|
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
8
|
var _propTypes = require("prop-types");
|
|
9
9
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
10
|
-
var _excluded = ["className", "
|
|
10
|
+
var _excluded = ["className", "size", "weight", "fill", "ariaLabel", "icon"];
|
|
11
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
12
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); }
|
|
13
13
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
14
14
|
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; }
|
|
15
|
-
var _Symbol = function _Symbol(props) {
|
|
15
|
+
var _Symbol = exports.Symbol = function _Symbol(props) {
|
|
16
16
|
var className = props.className,
|
|
17
|
-
children = props.children,
|
|
18
17
|
size = props.size,
|
|
19
18
|
weight = props.weight,
|
|
20
19
|
fill = props.fill,
|
|
21
20
|
ariaLabel = props.ariaLabel,
|
|
21
|
+
icon = props.icon,
|
|
22
22
|
rest = _objectWithoutProperties(props, _excluded);
|
|
23
23
|
return /*#__PURE__*/_react.default.createElement("span", _extends({
|
|
24
24
|
className: (0, _classnames.default)('ffe-symbol', fill ? "ffe-symbol--filled-".concat(weight) : "ffe-symbol--".concat(weight), size && "ffe-symbol--".concat(size), className),
|
|
25
25
|
role: "graphics-symbol img",
|
|
26
26
|
"aria-label": ariaLabel ? ariaLabel : null,
|
|
27
27
|
"aria-hidden": !ariaLabel
|
|
28
|
-
}, rest),
|
|
28
|
+
}, rest), icon);
|
|
29
29
|
};
|
|
30
|
-
exports.Symbol = _Symbol;
|
|
31
30
|
_Symbol.defaultProps = {
|
|
32
31
|
fill: false,
|
|
33
32
|
weight: 400
|
|
@@ -36,20 +35,14 @@ _Symbol.propTypes = {
|
|
|
36
35
|
/** Fills the icon with color */
|
|
37
36
|
fill: _propTypes.bool,
|
|
38
37
|
/** The name of the icon that should be shown */
|
|
39
|
-
|
|
38
|
+
icon: _propTypes.string.isRequired,
|
|
40
39
|
/** Size of the icon, default is the closest defined font-size */
|
|
41
40
|
size: (0, _propTypes.oneOf)(['xs', 'sm', 'md', 'lg', 'xl', '2xl']),
|
|
42
41
|
/** Symbols stroke weight. This can affect overall size of symbol, 400 is default */
|
|
43
42
|
weight: (0, _propTypes.oneOf)([300, 400, 500]),
|
|
44
43
|
/** Additional classnames */
|
|
45
44
|
className: _propTypes.string,
|
|
46
|
-
/** Aria label text. If null, aria-hidden is automatically set to true */
|
|
47
|
-
ariaLabel:
|
|
48
|
-
var propValue = props[propName];
|
|
49
|
-
if (propValue !== null && typeof propValue !== 'string') {
|
|
50
|
-
return new Error("Invalid prop '".concat(propName, "' supplied to '").concat(componentName, "'. ") + "'".concat(propName, "' must be a string or null."));
|
|
51
|
-
}
|
|
52
|
-
}
|
|
45
|
+
/** Aria label text. If null/undefined, aria-hidden is automatically set to true */
|
|
46
|
+
ariaLabel: _propTypes.string
|
|
53
47
|
};
|
|
54
|
-
var _default = _Symbol;
|
|
55
|
-
exports.default = _default;
|
|
48
|
+
var _default = exports.default = _Symbol;
|
package/lib/index.js
CHANGED
|
@@ -17,5 +17,5 @@ Object.defineProperty(exports, "default", {
|
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
19
|
var _Symbol = _interopRequireWildcard(require("./Symbol"));
|
|
20
|
-
function _getRequireWildcardCache(
|
|
21
|
-
function _interopRequireWildcard(
|
|
20
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
21
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sb1/ffe-symbols-react",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.4",
|
|
4
4
|
"description": "React-komponenter for Material Symbols tilpasset Sb1 sine behov",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"publishConfig": {
|
|
36
36
|
"access": "public"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "6887537e950b6104716ac2b8145f78bf64b69b07"
|
|
39
39
|
}
|
package/src/Symbol.js
CHANGED
|
@@ -3,15 +3,7 @@ import { string, bool, oneOf } from 'prop-types';
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
|
|
5
5
|
export const Symbol = props => {
|
|
6
|
-
const {
|
|
7
|
-
className,
|
|
8
|
-
children,
|
|
9
|
-
size,
|
|
10
|
-
weight,
|
|
11
|
-
fill,
|
|
12
|
-
ariaLabel,
|
|
13
|
-
...rest
|
|
14
|
-
} = props;
|
|
6
|
+
const { className, size, weight, fill, ariaLabel, icon, ...rest } = props;
|
|
15
7
|
|
|
16
8
|
return (
|
|
17
9
|
<span
|
|
@@ -26,7 +18,7 @@ export const Symbol = props => {
|
|
|
26
18
|
aria-hidden={!ariaLabel}
|
|
27
19
|
{...rest}
|
|
28
20
|
>
|
|
29
|
-
{
|
|
21
|
+
{icon}
|
|
30
22
|
</span>
|
|
31
23
|
);
|
|
32
24
|
};
|
|
@@ -40,24 +32,15 @@ Symbol.propTypes = {
|
|
|
40
32
|
/** Fills the icon with color */
|
|
41
33
|
fill: bool,
|
|
42
34
|
/** The name of the icon that should be shown */
|
|
43
|
-
|
|
35
|
+
icon: string.isRequired,
|
|
44
36
|
/** Size of the icon, default is the closest defined font-size */
|
|
45
37
|
size: oneOf(['xs', 'sm', 'md', 'lg', 'xl', '2xl']),
|
|
46
38
|
/** Symbols stroke weight. This can affect overall size of symbol, 400 is default */
|
|
47
39
|
weight: oneOf([300, 400, 500]),
|
|
48
40
|
/** Additional classnames */
|
|
49
41
|
className: string,
|
|
50
|
-
/** Aria label text. If null, aria-hidden is automatically set to true */
|
|
51
|
-
ariaLabel:
|
|
52
|
-
const propValue = props[propName];
|
|
53
|
-
|
|
54
|
-
if (propValue !== null && typeof propValue !== 'string') {
|
|
55
|
-
return new Error(
|
|
56
|
-
`Invalid prop '${propName}' supplied to '${componentName}'. ` +
|
|
57
|
-
`'${propName}' must be a string or null.`,
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
},
|
|
42
|
+
/** Aria label text. If null/undefined, aria-hidden is automatically set to true */
|
|
43
|
+
ariaLabel: string,
|
|
61
44
|
};
|
|
62
45
|
|
|
63
46
|
export default Symbol;
|
package/src/Symbol.spec.js
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import Symbol from '.';
|
|
3
3
|
|
|
4
|
-
const getWrapper = props =>
|
|
5
|
-
shallow(
|
|
6
|
-
<Symbol ariaLabel="hus icon" {...props}>
|
|
7
|
-
home
|
|
8
|
-
</Symbol>,
|
|
9
|
-
);
|
|
4
|
+
const getWrapper = props => shallow(<Symbol icon="home" {...props} />);
|
|
10
5
|
|
|
11
6
|
describe('<Symbol />', () => {
|
|
12
7
|
it('renders without exploding', () => {
|
|
@@ -37,12 +32,12 @@ describe('<Symbol />', () => {
|
|
|
37
32
|
const wrapper = getWrapper({ id: 'test-id' });
|
|
38
33
|
expect(wrapper.prop('id')).toBe('test-id');
|
|
39
34
|
});
|
|
40
|
-
it('set aria-hidden to
|
|
35
|
+
it('set aria-hidden to true when aria-label is undefined', () => {
|
|
41
36
|
const wrapper = getWrapper();
|
|
42
|
-
expect(wrapper.prop('aria-hidden')).toBe(false);
|
|
43
|
-
});
|
|
44
|
-
it('set aria-hidden to true when aria-label is empty string', () => {
|
|
45
|
-
const wrapper = getWrapper({ ariaLabel: '' });
|
|
46
37
|
expect(wrapper.prop('aria-hidden')).toBe(true);
|
|
47
38
|
});
|
|
39
|
+
it('set aria-hidden to false when aria-label is set', () => {
|
|
40
|
+
const wrapper = getWrapper({ ariaLabel: 'hus icon' });
|
|
41
|
+
expect(wrapper.prop('aria-hidden')).toBe(false);
|
|
42
|
+
});
|
|
48
43
|
});
|
package/src/index.d.ts
CHANGED
|
@@ -4,9 +4,11 @@ export interface SymbolProps {
|
|
|
4
4
|
fill?: boolean;
|
|
5
5
|
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl';
|
|
6
6
|
weight?: 300 | 400 | 500;
|
|
7
|
-
|
|
7
|
+
icon: string;
|
|
8
8
|
className?: string;
|
|
9
|
-
ariaLabel
|
|
9
|
+
ariaLabel?: string;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
declare class Symbol extends React.Component<SymbolProps, any> {}
|
|
13
|
+
|
|
14
|
+
export default Symbol;
|
package/types/index.d.ts
CHANGED
|
@@ -4,9 +4,11 @@ export interface SymbolProps {
|
|
|
4
4
|
fill?: boolean;
|
|
5
5
|
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl';
|
|
6
6
|
weight?: 300 | 400 | 500;
|
|
7
|
-
|
|
7
|
+
icon: string;
|
|
8
8
|
className?: string;
|
|
9
|
-
ariaLabel
|
|
9
|
+
ariaLabel?: string;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
declare class Symbol extends React.Component<SymbolProps, any> {}
|
|
13
|
+
|
|
14
|
+
export default Symbol;
|