mirror of
https://github.com/overleaf/overleaf.git
synced 2024-10-17 21:05:04 -04:00
a9436039b6
[web] Bootstrap class name helper GitOrigin-RevId: 9c2042aa2ea0e4d3828b32c321336e1c3a4a0ef8
49 lines
911 B
TypeScript
49 lines
911 B
TypeScript
import classNames from 'classnames'
|
|
import { bsClassName } from '@/features/utils/bootstrap-5'
|
|
|
|
type IconOwnProps = {
|
|
type: string
|
|
spin?: boolean
|
|
fw?: boolean
|
|
modifier?: string
|
|
accessibilityLabel?: string
|
|
}
|
|
|
|
export type IconProps = IconOwnProps &
|
|
Omit<React.ComponentProps<'i'>, keyof IconOwnProps>
|
|
|
|
function Icon({
|
|
type,
|
|
spin,
|
|
fw,
|
|
modifier,
|
|
className = '',
|
|
accessibilityLabel,
|
|
...rest
|
|
}: IconProps) {
|
|
const iconClassName = classNames(
|
|
'fa',
|
|
`fa-${type}`,
|
|
{
|
|
'fa-spin': spin,
|
|
'fa-fw': fw,
|
|
[`fa-${modifier}`]: modifier,
|
|
},
|
|
className
|
|
)
|
|
|
|
return (
|
|
<>
|
|
<i className={iconClassName} aria-hidden="true" {...rest} />
|
|
{accessibilityLabel && (
|
|
<span
|
|
className={bsClassName({ bs5: 'visually-hidden', bs3: 'sr-only' })}
|
|
>
|
|
{accessibilityLabel}
|
|
</span>
|
|
)}
|
|
</>
|
|
)
|
|
}
|
|
|
|
export default Icon
|