UNPKG

dora-ui

Version:

A React.js Mobile UI Library

85 lines (75 loc) 2.71 kB
import _extends from "@babel/runtime/helpers/esm/extends"; import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties"; import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; import _createClass from "@babel/runtime/helpers/esm/createClass"; import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn"; import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf"; import _inherits from "@babel/runtime/helpers/esm/inherits"; import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; import cx from 'classnames'; import PropTypes from 'prop-types'; import React, { Component } from 'react'; var cacheScript = new Set(); var url = '//at.alicdn.com/t/font_1307286_wu10fg1zil.js'; function createScript() { if (!cacheScript.has(url)) { var script = document.createElement('script'); script.src = url; cacheScript.add(url); document.body.appendChild(script); } } var Icon = /*#__PURE__*/ function (_Component) { _inherits(Icon, _Component); function Icon() { _classCallCheck(this, Icon); return _possibleConstructorReturn(this, _getPrototypeOf(Icon).apply(this, arguments)); } _createClass(Icon, [{ key: "componentDidMount", value: function componentDidMount() { createScript(); } }, { key: "render", value: function render() { var _this$props = this.props, prefixCls = _this$props.prefixCls, size = _this$props.size, type = _this$props.type, spinning = _this$props.spinning, color = _this$props.color, className = _this$props.className, rest = _objectWithoutProperties(_this$props, ["prefixCls", "size", "type", "spinning", "color", "className"]); var cls = cx(prefixCls, className, "".concat(prefixCls, "-").concat(size), _defineProperty({}, "".concat(prefixCls, "-spinning"), spinning)); var style = { color: color }; return React.createElement("svg", _extends({}, rest, { className: cls, style: style }), React.createElement("use", { xlinkHref: "#icon-".concat(type) })); } }]); return Icon; }(Component); _defineProperty(Icon, "propTypes", { type: PropTypes.oneOf(['success', 'error', 'info', 'warning', 'loading']).isRequired, size: PropTypes.oneOf(['sm', 'md', 'lg']), color: PropTypes.string, spinning: PropTypes.bool, prefixCls: PropTypes.string, className: PropTypes.string, onClick: PropTypes.func }); _defineProperty(Icon, "defaultProps", { prefixCls: 'dora-icon', size: 'md', color: '#000', onClick: function onClick() {} }); export default Icon;