1 | import _extends from 'babel-runtime/helpers/extends';
|
2 | import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
|
3 | import _createClass from 'babel-runtime/helpers/createClass';
|
4 | import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
|
5 | import _inherits from 'babel-runtime/helpers/inherits';
|
6 | var __rest = this && this.__rest || function (s, e) {
|
7 | var t = {};
|
8 | for (var p in s) {
|
9 | if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
10 | }if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
11 | if (e.indexOf(p[i]) < 0) t[p[i]] = s[p[i]];
|
12 | }return t;
|
13 | };
|
14 | import classnames from 'classnames';
|
15 | import React from 'react';
|
16 | import loadSprite from './loadSprite';
|
17 |
|
18 | var Icon = function (_React$Component) {
|
19 | _inherits(Icon, _React$Component);
|
20 |
|
21 | function Icon() {
|
22 | _classCallCheck(this, Icon);
|
23 |
|
24 | return _possibleConstructorReturn(this, (Icon.__proto__ || Object.getPrototypeOf(Icon)).apply(this, arguments));
|
25 | }
|
26 |
|
27 | _createClass(Icon, [{
|
28 | key: 'componentDidMount',
|
29 | value: function componentDidMount() {
|
30 | loadSprite();
|
31 | }
|
32 | }, {
|
33 | key: 'render',
|
34 | value: function render() {
|
35 | var _a = this.props,
|
36 | type = _a.type,
|
37 | className = _a.className,
|
38 | size = _a.size,
|
39 | restProps = __rest(_a, ["type", "className", "size"]);
|
40 | var cls = classnames(className, 'am-icon', 'am-icon-' + type, 'am-icon-' + size);
|
41 | return React.createElement(
|
42 | 'svg',
|
43 | _extends({ className: cls }, restProps),
|
44 | React.createElement('use', { xlinkHref: '#' + type })
|
45 | );
|
46 | }
|
47 | }]);
|
48 |
|
49 | return Icon;
|
50 | }(React.Component);
|
51 |
|
52 | export default Icon;
|
53 |
|
54 | Icon.defaultProps = {
|
55 | size: 'md'
|
56 | }; |
\ | No newline at end of file |