UNPKG

@alifd/next

Version:

A configurable component library for web built on React.

67 lines (54 loc) 2.21 kB
import _extends from 'babel-runtime/helpers/extends'; import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties'; import _classCallCheck from 'babel-runtime/helpers/classCallCheck'; import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn'; import _inherits from 'babel-runtime/helpers/inherits'; var _class, _temp; import React, { Component } from 'react'; import PropTypes from 'prop-types'; import cx from 'classnames'; import ConfigProvider from '../config-provider'; /** * Icon */ var Icon = (_temp = _class = function (_Component) { _inherits(Icon, _Component); function Icon() { _classCallCheck(this, Icon); return _possibleConstructorReturn(this, _Component.apply(this, arguments)); } Icon.prototype.render = function render() { var _cx; /* eslint-disable no-unused-vars*/ var _props = this.props, prefix = _props.prefix, type = _props.type, size = _props.size, className = _props.className, rtl = _props.rtl, other = _objectWithoutProperties(_props, ['prefix', 'type', 'size', 'className', 'rtl']); var classes = cx((_cx = {}, _cx[prefix + 'icon'] = true, _cx[prefix + 'icon-' + type] = !!type, _cx['' + prefix + size] = !!size, _cx[className] = !!className, _cx)); if (rtl && ['arrow-left', 'arrow-right', 'arrow-double-left', 'arrow-double-right', 'switch', 'sorting', 'descending', 'ascending'].indexOf(type) !== -1) { other.dir = 'rtl'; } return React.createElement('i', _extends({}, other, { className: classes })); }; return Icon; }(Component), _class.propTypes = { prefix: PropTypes.string, rtl: PropTypes.bool, /** * 指定显示哪种图标 */ type: PropTypes.string, /** * 指定图标大小 */ size: PropTypes.oneOf(['xxs', 'xs', 'small', 'medium', 'large', 'xl', 'xxl', 'xxxl', 'inherit']), className: PropTypes.string }, _class.defaultProps = { prefix: 'next-', size: 'medium' }, _class._typeMark = 'icon', _temp); Icon.displayName = 'Icon'; export default ConfigProvider.config(Icon);