@sb1/ffe-icons-react 9.0.7 → 9.0.9
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/es/Icon.js +3 -5
- package/lib/Icon.js +3 -5
- package/package.json +6 -6
- package/src/Icon.js +1 -5
- package/src/Icon.spec.js +21 -17
package/es/Icon.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var _excluded = ["fileUrl", "className", "ariaLabel", "size"];
|
|
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
|
-
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var
|
|
4
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } } return target; }
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import classNames from 'classnames';
|
|
7
7
|
import { string, oneOf } from 'prop-types';
|
|
@@ -9,7 +9,8 @@ var Icon = function Icon(props) {
|
|
|
9
9
|
var fileUrl = props.fileUrl,
|
|
10
10
|
className = props.className,
|
|
11
11
|
ariaLabel = props.ariaLabel,
|
|
12
|
-
size = props.size,
|
|
12
|
+
_props$size = props.size,
|
|
13
|
+
size = _props$size === void 0 ? 'md' : _props$size,
|
|
13
14
|
rest = _objectWithoutProperties(props, _excluded);
|
|
14
15
|
return /*#__PURE__*/React.createElement("span", _extends({
|
|
15
16
|
role: "img",
|
|
@@ -22,9 +23,6 @@ var Icon = function Icon(props) {
|
|
|
22
23
|
}
|
|
23
24
|
}, rest));
|
|
24
25
|
};
|
|
25
|
-
Icon.defaultProps = {
|
|
26
|
-
size: 'md'
|
|
27
|
-
};
|
|
28
26
|
Icon.propTypes = {
|
|
29
27
|
/** The path to the svg-file og base64 string */
|
|
30
28
|
fileUrl: string.isRequired,
|
package/lib/Icon.js
CHANGED
|
@@ -11,12 +11,13 @@ var _excluded = ["fileUrl", "className", "ariaLabel", "size"];
|
|
|
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
|
-
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var
|
|
14
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } } return target; }
|
|
15
15
|
var Icon = function Icon(props) {
|
|
16
16
|
var fileUrl = props.fileUrl,
|
|
17
17
|
className = props.className,
|
|
18
18
|
ariaLabel = props.ariaLabel,
|
|
19
|
-
size = props.size,
|
|
19
|
+
_props$size = props.size,
|
|
20
|
+
size = _props$size === void 0 ? 'md' : _props$size,
|
|
20
21
|
rest = _objectWithoutProperties(props, _excluded);
|
|
21
22
|
return /*#__PURE__*/_react.default.createElement("span", _extends({
|
|
22
23
|
role: "img",
|
|
@@ -29,9 +30,6 @@ var Icon = function Icon(props) {
|
|
|
29
30
|
}
|
|
30
31
|
}, rest));
|
|
31
32
|
};
|
|
32
|
-
Icon.defaultProps = {
|
|
33
|
-
size: 'md'
|
|
34
|
-
};
|
|
35
33
|
Icon.propTypes = {
|
|
36
34
|
/** The path to the svg-file og base64 string */
|
|
37
35
|
fileUrl: _propTypes.string.isRequired,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sb1/ffe-icons-react",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.9",
|
|
4
4
|
"description": "React-komponenter for ffe-icons",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "SpareBank 1",
|
|
@@ -22,16 +22,16 @@
|
|
|
22
22
|
"build": "ffe-buildtool babel",
|
|
23
23
|
"clean": "rimraf gen-src lib es types",
|
|
24
24
|
"lint": "eslint src",
|
|
25
|
+
"lint:fix": "eslint src --fix",
|
|
25
26
|
"test": "ffe-buildtool jest"
|
|
26
27
|
},
|
|
27
28
|
"dependencies": {
|
|
28
|
-
"@sb1/ffe-icons": "^14.0.
|
|
29
|
+
"@sb1/ffe-icons": "^14.0.1",
|
|
29
30
|
"prop-types": "^15.7.2"
|
|
30
31
|
},
|
|
31
32
|
"devDependencies": {
|
|
32
|
-
"@sb1/ffe-buildtool": "^0.5.
|
|
33
|
-
"eslint": "^
|
|
34
|
-
"eslint-loader": "^2.1.0",
|
|
33
|
+
"@sb1/ffe-buildtool": "^0.5.2",
|
|
34
|
+
"eslint": "^8.57.0",
|
|
35
35
|
"react": "^16.9.0",
|
|
36
36
|
"react-dom": "^16.9.0",
|
|
37
37
|
"rimraf": "^3.0.2"
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"publishConfig": {
|
|
43
43
|
"access": "public"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "c2e7c509b580bc205ca92d91b7e2e2c0503a0087"
|
|
46
46
|
}
|
package/src/Icon.js
CHANGED
|
@@ -3,7 +3,7 @@ import classNames from 'classnames';
|
|
|
3
3
|
import { string, oneOf } from 'prop-types';
|
|
4
4
|
|
|
5
5
|
const Icon = props => {
|
|
6
|
-
const { fileUrl, className, ariaLabel, size, ...rest } = props;
|
|
6
|
+
const { fileUrl, className, ariaLabel, size = 'md', ...rest } = props;
|
|
7
7
|
|
|
8
8
|
return (
|
|
9
9
|
<span
|
|
@@ -20,10 +20,6 @@ const Icon = props => {
|
|
|
20
20
|
);
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
-
Icon.defaultProps = {
|
|
24
|
-
size: 'md',
|
|
25
|
-
};
|
|
26
|
-
|
|
27
23
|
Icon.propTypes = {
|
|
28
24
|
/** The path to the svg-file og base64 string */
|
|
29
25
|
fileUrl: string.isRequired,
|
package/src/Icon.spec.js
CHANGED
|
@@ -1,28 +1,32 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import Icon from './Icon';
|
|
3
|
-
|
|
4
|
-
const getWrapper = props => shallow(<Icon {...props} />);
|
|
3
|
+
import { render, screen } from '@testing-library/react';
|
|
5
4
|
|
|
6
5
|
describe('Icon', () => {
|
|
7
|
-
it('renders without crashing and with right class', () => {
|
|
8
|
-
const wrapper = getWrapper({ fileUrl: '<svg></svg>' });
|
|
9
|
-
expect(wrapper.exists()).toBe(true);
|
|
10
|
-
expect(wrapper.hasClass('ffe-icons')).toBe(true);
|
|
11
|
-
});
|
|
12
6
|
it('renders with role="img', () => {
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
render(<Icon fileUrl="fileUrl" ariaLabel="ariaLabel" />);
|
|
8
|
+
const icon = screen.getByRole('img');
|
|
9
|
+
expect(icon.classList.contains('ffe-icons')).toBeTruthy();
|
|
15
10
|
});
|
|
11
|
+
|
|
16
12
|
it('renders correct classname based on size-prop', () => {
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
render(<Icon fileUrl="fileUrl" ariaLabel="ariaLabel" size="sm" />);
|
|
14
|
+
const icon = screen.getByRole('img');
|
|
15
|
+
expect(icon.classList.contains('ffe-icons--sm')).toBeTruthy();
|
|
19
16
|
});
|
|
17
|
+
|
|
20
18
|
it('applies additional CSS classes when provided', () => {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
render(
|
|
20
|
+
<Icon
|
|
21
|
+
fileUrl="fileUrl"
|
|
22
|
+
ariaLabel="ariaLabel"
|
|
23
|
+
size="md"
|
|
24
|
+
className="my-class"
|
|
25
|
+
/>,
|
|
26
|
+
);
|
|
27
|
+
const icon = screen.getByRole('img');
|
|
28
|
+
expect(icon.classList.contains('ffe-icons')).toBeTruthy();
|
|
29
|
+
expect(icon.classList.contains('ffe-icons--md')).toBeTruthy();
|
|
30
|
+
expect(icon.classList.contains('my-class')).toBeTruthy();
|
|
27
31
|
});
|
|
28
32
|
});
|