2020-09-21 10:14:36 -04:00
|
|
|
import classNames from 'classnames'
|
|
|
|
|
2022-09-13 09:57:47 -04:00
|
|
|
type IconOwnProps = {
|
2022-04-08 07:00:46 -04:00
|
|
|
type: string
|
|
|
|
spin?: boolean
|
|
|
|
fw?: boolean
|
|
|
|
modifier?: string
|
|
|
|
accessibilityLabel?: string
|
|
|
|
}
|
|
|
|
|
2022-09-13 09:57:47 -04:00
|
|
|
type IconProps = IconOwnProps &
|
|
|
|
Omit<React.ComponentProps<'i'>, keyof IconOwnProps>
|
|
|
|
|
2020-11-26 09:22:30 -05:00
|
|
|
function Icon({
|
|
|
|
type,
|
|
|
|
spin,
|
2022-01-19 06:56:57 -05:00
|
|
|
fw,
|
2020-11-26 09:22:30 -05:00
|
|
|
modifier,
|
2022-01-19 06:56:57 -05:00
|
|
|
className = '',
|
2020-11-26 09:22:30 -05:00
|
|
|
accessibilityLabel,
|
2022-09-13 09:57:47 -04:00
|
|
|
...rest
|
2022-04-08 07:00:46 -04:00
|
|
|
}: IconProps) {
|
2020-09-21 10:14:36 -04:00
|
|
|
const iconClassName = classNames(
|
|
|
|
'fa',
|
|
|
|
`fa-${type}`,
|
|
|
|
{
|
|
|
|
'fa-spin': spin,
|
2022-01-19 06:56:57 -05:00
|
|
|
'fa-fw': fw,
|
2021-04-27 03:52:58 -04:00
|
|
|
[`fa-${modifier}`]: modifier,
|
2020-09-21 10:14:36 -04:00
|
|
|
},
|
2022-01-19 06:56:57 -05:00
|
|
|
className
|
2020-09-21 10:14:36 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
2022-09-13 09:57:47 -04:00
|
|
|
<i className={iconClassName} aria-hidden="true" {...rest} />
|
2022-01-19 06:56:57 -05:00
|
|
|
{accessibilityLabel && (
|
2020-09-21 10:14:36 -04:00
|
|
|
<span className="sr-only">{accessibilityLabel}</span>
|
2022-01-19 06:56:57 -05:00
|
|
|
)}
|
2020-09-21 10:14:36 -04:00
|
|
|
</>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Icon
|