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