@swrve/core
Version:
Core set of Swrve UI Components
45 lines (34 loc) • 891 B
JSX
import React from 'react'
import classNames from 'classnames'
import { string, bool, object, array, oneOfType } from 'prop-types'
import { Link } from 'react-router-dom'
import { Icon } from '@swrve/icons'
const IconLink = props => {
const { className, iconName, toggle, label, link } = props
const partial = toggle ? <span>{label}</span> : null
return (
<Link to={link} className={classNames(className)}>
<Icon name={iconName} />
{partial}
</Link>
)
}
IconLink.displayName = 'IconLink'
IconLink.propTypes = {
/** Class name */
className: oneOfType([string, object, array]),
/** Icon name */
iconName: string.isRequired,
/** Icon Link Label */
label: string,
/** Link Url*/
link: string.isRequired,
/** Label Toggle State */
toggle: bool
}
IconLink.defaultProps = {
link: '/',
label: '',
toggle: true
}
export default IconLink