UNPKG

hiromi

Version:

React components for Bulma. http://bulma.io/

37 lines (29 loc) 765 B
import React from 'react'; import PropTypes from 'prop-types'; import classnames from 'classnames'; import { modifierClassList, defaultReactProps, defaultReactPropsValues } from '../utils'; const Icon = ({tag, hasSpan, className, ...props}) => { const iconElement = <i className={tag}></i>; if (!hasSpan) { return iconElement; } let {classList, ...finalProps} = modifierClassList(props); classList = classnames('icon', className, classList); return ( <span className={classList} {...finalProps}> {iconElement} </span> ); }; Icon.propTypes = { tag: PropTypes.string.isRequired, hasSpan: PropTypes.bool, ...defaultReactProps }; Icon.defaultProps = { hasSpan: true, ...defaultReactPropsValues }; export default Icon;