Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | 1x 44x 4x 4x 1x | import PropTypes from 'prop-types'
import {CLASS, ICON_POSITIONS, isAtomIcon, prepareAtomIcon, SIZES} from './config.js'
const ButtonIcon = ({children, position, size}) => {
if (!children) return null
// if the icon is an AtomIcon, we've to be sure the correct props are used
const iconToRender = isAtomIcon(children) ? prepareAtomIcon(children, {size}) : children
return <span className={`${CLASS}-${position}Icon`}>{iconToRender}</span>
}
ButtonIcon.propTypes = {
children: PropTypes.element,
position: PropTypes.oneOf(Object.values(ICON_POSITIONS)),
size: PropTypes.oneOf(Object.values(SIZES))
}
export default ButtonIcon
|