@sb1/ffe-icons-react 7.3.6 → 9.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/es/Icon.js +37 -0
- package/es/index.js +2 -0
- package/lib/Icon.js +44 -0
- package/lib/index.js +13 -1
- package/package.json +7 -10
- package/src/Icon.js +35 -0
- package/src/Icon.spec.js +28 -0
- package/src/index.d.ts +12 -0
- package/src/index.js +3 -0
- package/types/index.d.ts +8 -4
package/es/Icon.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
var _excluded = ["fileUrl", "className", "ariaLabel", "size"];
|
|
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
|
+
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 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; }
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import classNames from 'classnames';
|
|
7
|
+
import { string, oneOf } from 'prop-types';
|
|
8
|
+
var Icon = function Icon(props) {
|
|
9
|
+
var fileUrl = props.fileUrl,
|
|
10
|
+
className = props.className,
|
|
11
|
+
ariaLabel = props.ariaLabel,
|
|
12
|
+
size = props.size,
|
|
13
|
+
rest = _objectWithoutProperties(props, _excluded);
|
|
14
|
+
return /*#__PURE__*/React.createElement("span", _extends({
|
|
15
|
+
role: "img",
|
|
16
|
+
"aria-label": ariaLabel,
|
|
17
|
+
"aria-hidden": !ariaLabel,
|
|
18
|
+
className: classNames('ffe-icons', "ffe-icons--".concat(size), className),
|
|
19
|
+
style: {
|
|
20
|
+
maskImage: "url(".concat(fileUrl, ")")
|
|
21
|
+
}
|
|
22
|
+
}, rest));
|
|
23
|
+
};
|
|
24
|
+
Icon.defaultProps = {
|
|
25
|
+
size: 'md'
|
|
26
|
+
};
|
|
27
|
+
Icon.propTypes = {
|
|
28
|
+
/** The path to the svg-file og base64 string */
|
|
29
|
+
fileUrl: string.isRequired,
|
|
30
|
+
/** Additional classnames */
|
|
31
|
+
className: string,
|
|
32
|
+
/** Aria label, if ariaLabel is hull it'll sett aria-hidden to true */
|
|
33
|
+
ariaLabel: string,
|
|
34
|
+
/** Size of the container around the icon */
|
|
35
|
+
size: oneOf(['sm', 'md', 'lg', 'xl'])
|
|
36
|
+
};
|
|
37
|
+
export default Icon;
|
package/es/index.js
CHANGED
package/lib/Icon.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
9
|
+
var _propTypes = require("prop-types");
|
|
10
|
+
var _excluded = ["fileUrl", "className", "ariaLabel", "size"];
|
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
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
|
+
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 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 Icon = function Icon(props) {
|
|
16
|
+
var fileUrl = props.fileUrl,
|
|
17
|
+
className = props.className,
|
|
18
|
+
ariaLabel = props.ariaLabel,
|
|
19
|
+
size = props.size,
|
|
20
|
+
rest = _objectWithoutProperties(props, _excluded);
|
|
21
|
+
return /*#__PURE__*/_react.default.createElement("span", _extends({
|
|
22
|
+
role: "img",
|
|
23
|
+
"aria-label": ariaLabel,
|
|
24
|
+
"aria-hidden": !ariaLabel,
|
|
25
|
+
className: (0, _classnames.default)('ffe-icons', "ffe-icons--".concat(size), className),
|
|
26
|
+
style: {
|
|
27
|
+
maskImage: "url(".concat(fileUrl, ")")
|
|
28
|
+
}
|
|
29
|
+
}, rest));
|
|
30
|
+
};
|
|
31
|
+
Icon.defaultProps = {
|
|
32
|
+
size: 'md'
|
|
33
|
+
};
|
|
34
|
+
Icon.propTypes = {
|
|
35
|
+
/** The path to the svg-file og base64 string */
|
|
36
|
+
fileUrl: _propTypes.string.isRequired,
|
|
37
|
+
/** Additional classnames */
|
|
38
|
+
className: _propTypes.string,
|
|
39
|
+
/** Aria label, if ariaLabel is hull it'll sett aria-hidden to true */
|
|
40
|
+
ariaLabel: _propTypes.string,
|
|
41
|
+
/** Size of the container around the icon */
|
|
42
|
+
size: (0, _propTypes.oneOf)(['sm', 'md', 'lg', 'xl'])
|
|
43
|
+
};
|
|
44
|
+
var _default = exports.default = Icon;
|
package/lib/index.js
CHANGED
|
@@ -1 +1,13 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "Icon", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _Icon.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _Icon = _interopRequireDefault(require("./Icon"));
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sb1/ffe-icons-react",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.0",
|
|
4
4
|
"description": "React-komponenter for ffe-icons",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "SpareBank 1",
|
|
7
7
|
"files": [
|
|
8
8
|
"lib",
|
|
9
9
|
"types",
|
|
10
|
-
"es"
|
|
10
|
+
"es",
|
|
11
|
+
"src"
|
|
11
12
|
],
|
|
12
13
|
"main": "lib/index.js",
|
|
13
14
|
"types": "types/index.d.ts",
|
|
@@ -18,22 +19,18 @@
|
|
|
18
19
|
"url": "ssh://git@github.com:SpareBank1/designsystem.git"
|
|
19
20
|
},
|
|
20
21
|
"scripts": {
|
|
21
|
-
"build": "
|
|
22
|
+
"build": "ffe-buildtool babel",
|
|
22
23
|
"clean": "rimraf gen-src lib es types",
|
|
23
|
-
"lint": "eslint
|
|
24
|
-
"test": "
|
|
24
|
+
"lint": "eslint src",
|
|
25
|
+
"test": "ffe-buildtool jest"
|
|
25
26
|
},
|
|
26
27
|
"dependencies": {
|
|
27
28
|
"prop-types": "^15.7.2"
|
|
28
29
|
},
|
|
29
30
|
"devDependencies": {
|
|
30
31
|
"@sb1/ffe-buildtool": "^0.5.0",
|
|
31
|
-
"@sb1/ffe-icons": "^13.0.0",
|
|
32
|
-
"cheerio": "^1.0.0-rc.10",
|
|
33
32
|
"eslint": "^5.9.0",
|
|
34
33
|
"eslint-loader": "^2.1.0",
|
|
35
|
-
"glob": "^7.2.0",
|
|
36
|
-
"mkdirp": "^1.0.4",
|
|
37
34
|
"react": "^16.9.0",
|
|
38
35
|
"react-dom": "^16.9.0",
|
|
39
36
|
"rimraf": "^3.0.2"
|
|
@@ -44,5 +41,5 @@
|
|
|
44
41
|
"publishConfig": {
|
|
45
42
|
"access": "public"
|
|
46
43
|
},
|
|
47
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "45867fae897ca8ed48357de490a99ef6147e71f8"
|
|
48
45
|
}
|
package/src/Icon.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import { string, oneOf } from 'prop-types';
|
|
4
|
+
|
|
5
|
+
const Icon = props => {
|
|
6
|
+
const { fileUrl, className, ariaLabel, size, ...rest } = props;
|
|
7
|
+
|
|
8
|
+
return (
|
|
9
|
+
<span
|
|
10
|
+
role="img"
|
|
11
|
+
aria-label={ariaLabel}
|
|
12
|
+
aria-hidden={!ariaLabel}
|
|
13
|
+
className={classNames('ffe-icons', `ffe-icons--${size}`, className)}
|
|
14
|
+
style={{ maskImage: `url(${fileUrl})` }}
|
|
15
|
+
{...rest}
|
|
16
|
+
/>
|
|
17
|
+
);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
Icon.defaultProps = {
|
|
21
|
+
size: 'md',
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
Icon.propTypes = {
|
|
25
|
+
/** The path to the svg-file og base64 string */
|
|
26
|
+
fileUrl: string.isRequired,
|
|
27
|
+
/** Additional classnames */
|
|
28
|
+
className: string,
|
|
29
|
+
/** Aria label, if ariaLabel is hull it'll sett aria-hidden to true */
|
|
30
|
+
ariaLabel: string,
|
|
31
|
+
/** Size of the container around the icon */
|
|
32
|
+
size: oneOf(['sm', 'md', 'lg', 'xl']),
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export default Icon;
|
package/src/Icon.spec.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Icon from './Icon';
|
|
3
|
+
|
|
4
|
+
const getWrapper = props => shallow(<Icon {...props} />);
|
|
5
|
+
|
|
6
|
+
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
|
+
it('renders with role="img', () => {
|
|
13
|
+
const wrapper = getWrapper({ filePath: '<svg></svg>' });
|
|
14
|
+
expect(wrapper.props()).toHaveProperty('role', 'img');
|
|
15
|
+
});
|
|
16
|
+
it('renders correct classname based on size-prop', () => {
|
|
17
|
+
const wrapper = getWrapper({ filePath: '<svg></svg>', size: 'sm' });
|
|
18
|
+
expect(wrapper.hasClass('ffe-icons--sm')).toBe(true);
|
|
19
|
+
});
|
|
20
|
+
it('applies additional CSS classes when provided', () => {
|
|
21
|
+
const wrapper = getWrapper({
|
|
22
|
+
fileUrl: '<svg></svg>',
|
|
23
|
+
size: 'md',
|
|
24
|
+
className: 'my-class',
|
|
25
|
+
});
|
|
26
|
+
expect(wrapper.hasClass('ffe-icons ffe-icons--md my-class')).toBe(true);
|
|
27
|
+
});
|
|
28
|
+
});
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
export interface IconProps {
|
|
4
|
+
fileUrl: string;
|
|
5
|
+
className?: string;
|
|
6
|
+
ariaLabel?: string;
|
|
7
|
+
size: 'sm' | 'md' | 'lg' | 'xl';
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
declare class Icon extends React.Component<IconProps, any> {}
|
|
11
|
+
|
|
12
|
+
export default Icon;
|
package/src/index.js
ADDED
package/types/index.d.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
|
|
3
|
-
export interface
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
export interface IconProps {
|
|
4
|
+
fileUrl: string;
|
|
5
|
+
className?: string;
|
|
6
|
+
ariaLabel?: string;
|
|
7
|
+
size: 'sm' | 'md' | 'lg' | 'xl';
|
|
7
8
|
}
|
|
8
9
|
|
|
10
|
+
declare class Icon extends React.Component<IconProps, any> {}
|
|
11
|
+
|
|
12
|
+
export default Icon;
|