2020-09-21 10:14:36 -04:00
|
|
|
import classNames from 'classnames'
|
2024-04-16 11:06:42 -04:00
|
|
|
import { bsVersion } from '@/features/utils/bootstrap-5'
|
2020-09-21 10:14:36 -04:00
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2023-02-21 09:34:35 -05:00
|
|
|
export type IconProps = IconOwnProps &
|
2022-09-13 09:57:47 -04:00
|
|
|
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 && (
|
2024-04-16 11:06:42 -04:00
|
|
|
<span className={bsVersion({ bs5: 'visually-hidden', bs3: 'sr-only' })}>
|
2024-04-03 07:01:56 -04:00
|
|
|
{accessibilityLabel}
|
|
|
|
</span>
|
2022-01-19 06:56:57 -05:00
|
|
|
)}
|
2020-09-21 10:14:36 -04:00
|
|
|
</>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Icon
|