Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const renderIcon = props => {
if (!props.icon) return null
const css = {
cursor: props.icon.props.onClick ? 'pointer' : 'default'
}
const onClick = evt => {
evt.stopPropagation()
if (props.icon.props.onClick) props.icon.props.onClick(evt)
}
const size =
props.size === vars.sizes.small ? iconSizes.small : iconSizes.medium
return React.cloneElement(props.icon, { css, onClick, size })
}
const mapIconSize = props => {
const btnToIconSizes = {
[vars.sizes.xSmall]: iconSizes.small,
[vars.sizes.small]: iconSizes.medium,
[vars.sizes.medium]: iconSizes.medium,
[vars.sizes.large]: iconSizes.medium
}
return btnToIconSizes[props.size]
? btnToIconSizes[props.size]
: iconSizes.medium
}
const Tag = ({ children, icon, ...props }) => (
<div>
{icon && (
{React.cloneElement(icon, { size: iconSizes.small })}
)}
{children}
</div>
)
Tag.displayName = 'Card.Tag'