@sb1/ffe-symbols-react 1.1.6 → 2.0.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/CHANGELOG.md CHANGED
@@ -3,6 +3,16 @@
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.0](https://github.com/SpareBank1/designsystem/compare/@sb1/ffe-symbols-react@1.1.6...@sb1/ffe-symbols-react@2.0.0) (2023-08-25)
7
+
8
+ ### Bug Fixes
9
+
10
+ - **ffe-symbols-react:** fjerner color prop ([b609d98](https://github.com/SpareBank1/designsystem/commit/b609d9827e1d0d56256c61ba10f0482af087c526))
11
+
12
+ ### BREAKING CHANGES
13
+
14
+ - **ffe-symbols-react:** fjerner color-prop da styling skal skje gjennom css
15
+
6
16
  ## [1.1.6](https://github.com/SpareBank1/designsystem/compare/@sb1/ffe-symbols-react@1.1.5...@sb1/ffe-symbols-react@1.1.6) (2023-08-24)
7
17
 
8
18
  ### Bug Fixes
package/es/Symbol.js CHANGED
@@ -1,4 +1,4 @@
1
- var _excluded = ["className", "children", "size", "weight", "fill", "color", "ariaLabel"];
1
+ var _excluded = ["className", "children", "size", "weight", "fill", "ariaLabel"];
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; }
@@ -11,15 +11,13 @@ var _Symbol = function _Symbol(props) {
11
11
  size = props.size,
12
12
  weight = props.weight,
13
13
  fill = props.fill,
14
- color = props.color,
15
14
  ariaLabel = props.ariaLabel,
16
15
  rest = _objectWithoutProperties(props, _excluded);
17
16
  return /*#__PURE__*/React.createElement("span", _extends({
18
- className: classNames('ffe-symbol', "ffe-symbol--".concat(size), className),
17
+ className: classNames('ffe-symbol', size && "ffe-symbol--".concat(size), className),
19
18
  role: "img",
20
19
  style: {
21
- fontVariationSettings: "'FILL' ".concat(fill ? 1 : 0, ", 'GRAD' 0, 'wght' ").concat(weight),
22
- color: color ? "var(--".concat(color, ")") : null
20
+ fontVariationSettings: "'FILL' ".concat(fill ? 1 : 0, ", 'GRAD' 0, 'wght' ").concat(weight)
23
21
  },
24
22
  "aria-label": ariaLabel ? ariaLabel : null,
25
23
  "aria-hidden": !ariaLabel
@@ -28,7 +26,6 @@ var _Symbol = function _Symbol(props) {
28
26
  export { _Symbol as Symbol };
29
27
  _Symbol.defaultProps = {
30
28
  fill: false,
31
- size: 'md',
32
29
  weight: 400
33
30
  };
34
31
  _Symbol.propTypes = {
@@ -36,15 +33,18 @@ _Symbol.propTypes = {
36
33
  fill: bool,
37
34
  /** The name of the icon that should be shown */
38
35
  children: string.isRequired,
39
- /** Size of the icon, medium is default */
36
+ /** Size of the icon, default is the closest defined font-size */
40
37
  size: oneOf(['xs', 'sm', 'md', 'lg', 'xl', '2xl']),
41
38
  /** Symbols stroke weight. This can affect overall size of symbol, 400 is default */
42
39
  weight: oneOf([300, 400, 500, 600]),
43
- /** Color of the symbol, value should be name of FFE color variable example: ffe-farge-vann */
44
- color: string,
45
40
  /** Additional classnames */
46
41
  className: string,
47
- /** Aria label text. If empty aria-hidden is automatically set to true */
48
- ariaLabel: string.isRequired
42
+ /** Aria label text. If null, aria-hidden is automatically set to true */
43
+ ariaLabel: function ariaLabel(props, propName, componentName) {
44
+ var propValue = props[propName];
45
+ if (propValue !== null && typeof propValue !== 'string') {
46
+ return new Error("Invalid prop '".concat(propName, "' supplied to '").concat(componentName, "'. ") + "'".concat(propName, "' must be a string or null."));
47
+ }
48
+ }
49
49
  };
50
50
  export default _Symbol;
package/lib/Symbol.js CHANGED
@@ -7,7 +7,7 @@ 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", "children", "size", "weight", "fill", "color", "ariaLabel"];
10
+ var _excluded = ["className", "children", "size", "weight", "fill", "ariaLabel"];
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; }
@@ -18,15 +18,13 @@ var _Symbol = function _Symbol(props) {
18
18
  size = props.size,
19
19
  weight = props.weight,
20
20
  fill = props.fill,
21
- color = props.color,
22
21
  ariaLabel = props.ariaLabel,
23
22
  rest = _objectWithoutProperties(props, _excluded);
24
23
  return /*#__PURE__*/_react.default.createElement("span", _extends({
25
- className: (0, _classnames.default)('ffe-symbol', "ffe-symbol--".concat(size), className),
24
+ className: (0, _classnames.default)('ffe-symbol', size && "ffe-symbol--".concat(size), className),
26
25
  role: "img",
27
26
  style: {
28
- fontVariationSettings: "'FILL' ".concat(fill ? 1 : 0, ", 'GRAD' 0, 'wght' ").concat(weight),
29
- color: color ? "var(--".concat(color, ")") : null
27
+ fontVariationSettings: "'FILL' ".concat(fill ? 1 : 0, ", 'GRAD' 0, 'wght' ").concat(weight)
30
28
  },
31
29
  "aria-label": ariaLabel ? ariaLabel : null,
32
30
  "aria-hidden": !ariaLabel
@@ -35,7 +33,6 @@ var _Symbol = function _Symbol(props) {
35
33
  exports.Symbol = _Symbol;
36
34
  _Symbol.defaultProps = {
37
35
  fill: false,
38
- size: 'md',
39
36
  weight: 400
40
37
  };
41
38
  _Symbol.propTypes = {
@@ -43,16 +40,19 @@ _Symbol.propTypes = {
43
40
  fill: _propTypes.bool,
44
41
  /** The name of the icon that should be shown */
45
42
  children: _propTypes.string.isRequired,
46
- /** Size of the icon, medium is default */
43
+ /** Size of the icon, default is the closest defined font-size */
47
44
  size: (0, _propTypes.oneOf)(['xs', 'sm', 'md', 'lg', 'xl', '2xl']),
48
45
  /** Symbols stroke weight. This can affect overall size of symbol, 400 is default */
49
46
  weight: (0, _propTypes.oneOf)([300, 400, 500, 600]),
50
- /** Color of the symbol, value should be name of FFE color variable example: ffe-farge-vann */
51
- color: _propTypes.string,
52
47
  /** Additional classnames */
53
48
  className: _propTypes.string,
54
- /** Aria label text. If empty aria-hidden is automatically set to true */
55
- ariaLabel: _propTypes.string.isRequired
49
+ /** Aria label text. If null, aria-hidden is automatically set to true */
50
+ ariaLabel: function ariaLabel(props, propName, componentName) {
51
+ var propValue = props[propName];
52
+ if (propValue !== null && typeof propValue !== 'string') {
53
+ return new Error("Invalid prop '".concat(propName, "' supplied to '").concat(componentName, "'. ") + "'".concat(propName, "' must be a string or null."));
54
+ }
55
+ }
56
56
  };
57
57
  var _default = _Symbol;
58
58
  exports.default = _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sb1/ffe-symbols-react",
3
- "version": "1.1.6",
3
+ "version": "2.0.0",
4
4
  "description": "React-komponenter for Material Symbols tilpasset Sb1 sine behov",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -23,7 +23,7 @@
23
23
  },
24
24
  "homepage": "https://github.com/SpareBank1/designsystem#readme",
25
25
  "dependencies": {
26
- "@sb1/ffe-symbols": "^1.1.3",
26
+ "@sb1/ffe-symbols": "^1.1.4",
27
27
  "classnames": "^2.3.2",
28
28
  "prop-types": "^15.8.1",
29
29
  "react": "^18.2.0"
@@ -35,5 +35,5 @@
35
35
  "publishConfig": {
36
36
  "access": "public"
37
37
  },
38
- "gitHead": "070ca7dc51f76981e58460c996a859d801589426"
38
+ "gitHead": "3c8f1c57f5ec5f09d8e6ff38569c709eddfb5a8d"
39
39
  }
package/src/Symbol.js CHANGED
@@ -9,15 +9,15 @@ export const Symbol = props => {
9
9
  size,
10
10
  weight,
11
11
  fill,
12
- color,
13
12
  ariaLabel,
14
13
  ...rest
15
14
  } = props;
15
+
16
16
  return (
17
17
  <span
18
18
  className={classNames(
19
19
  'ffe-symbol',
20
- `ffe-symbol--${size}`,
20
+ size && `ffe-symbol--${size}`,
21
21
  className,
22
22
  )}
23
23
  role="img"
@@ -25,7 +25,6 @@ export const Symbol = props => {
25
25
  fontVariationSettings: `'FILL' ${
26
26
  fill ? 1 : 0
27
27
  }, 'GRAD' 0, 'wght' ${weight}`,
28
- color: color ? `var(--${color})` : null,
29
28
  }}
30
29
  aria-label={ariaLabel ? ariaLabel : null}
31
30
  aria-hidden={!ariaLabel}
@@ -38,7 +37,6 @@ export const Symbol = props => {
38
37
 
39
38
  Symbol.defaultProps = {
40
39
  fill: false,
41
- size: 'md',
42
40
  weight: 400,
43
41
  };
44
42
 
@@ -47,16 +45,23 @@ Symbol.propTypes = {
47
45
  fill: bool,
48
46
  /** The name of the icon that should be shown */
49
47
  children: string.isRequired,
50
- /** Size of the icon, medium is default */
48
+ /** Size of the icon, default is the closest defined font-size */
51
49
  size: oneOf(['xs', 'sm', 'md', 'lg', 'xl', '2xl']),
52
50
  /** Symbols stroke weight. This can affect overall size of symbol, 400 is default */
53
51
  weight: oneOf([300, 400, 500, 600]),
54
- /** Color of the symbol, value should be name of FFE color variable example: ffe-farge-vann */
55
- color: string,
56
52
  /** Additional classnames */
57
53
  className: string,
58
- /** Aria label text. If empty aria-hidden is automatically set to true */
59
- ariaLabel: string.isRequired,
54
+ /** Aria label text. If null, aria-hidden is automatically set to true */
55
+ ariaLabel: function(props, propName, componentName) {
56
+ const propValue = props[propName];
57
+
58
+ if (propValue !== null && typeof propValue !== 'string') {
59
+ return new Error(
60
+ `Invalid prop '${propName}' supplied to '${componentName}'. ` +
61
+ `'${propName}' must be a string or null.`,
62
+ );
63
+ }
64
+ },
60
65
  };
61
66
 
62
67
  export default Symbol;
@@ -38,13 +38,6 @@ describe('<Symbol />', () => {
38
38
  "'FILL' 0, 'GRAD' 0, 'wght' 600",
39
39
  );
40
40
  });
41
- it('set correct color based of prop', () => {
42
- const wrapper = getWrapper({ color: 'ffe-farge-fjell' });
43
- expect(wrapper.get(0).props.style).toHaveProperty(
44
- 'color',
45
- 'var(--ffe-farge-fjell)',
46
- );
47
- });
48
41
  it('renders classes correctly', () => {
49
42
  const wrapper = getWrapper({ className: 'test-class' });
50
43
  expect(wrapper.hasClass('ffe-symbol')).toBe(true);
package/src/index.d.ts CHANGED
@@ -4,10 +4,9 @@ export interface SymbolProps {
4
4
  fill?: boolean;
5
5
  size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl';
6
6
  weight?: 300 | 400 | 500 | 600;
7
- color?: string;
8
7
  children: string;
9
8
  className?: string;
10
- ariaLabel: string;
9
+ ariaLabel: string | null;
11
10
  }
12
11
 
13
12
  declare class Symbol extends React.Component<SymbolProps, any> {}
package/types/index.d.ts CHANGED
@@ -4,10 +4,9 @@ export interface SymbolProps {
4
4
  fill?: boolean;
5
5
  size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl';
6
6
  weight?: 300 | 400 | 500 | 600;
7
- color?: string;
8
7
  children: string;
9
8
  className?: string;
10
- ariaLabel: string;
9
+ ariaLabel: string | null;
11
10
  }
12
11
 
13
12
  declare class Symbol extends React.Component<SymbolProps, any> {}