mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
0e71084600
[web] BS5 project tools GitOrigin-RevId: 3181c62985b6db4051292b484f53178a0736fa75
33 lines
1,013 B
TypeScript
33 lines
1,013 B
TypeScript
import { forwardRef } from 'react'
|
|
import classNames from 'classnames'
|
|
import MaterialIcon from '@/shared/components/material-icon'
|
|
import Button from './button'
|
|
import type { IconButtonProps } from '@/features/ui/components/types/icon-button-props'
|
|
|
|
const IconButton = forwardRef<HTMLButtonElement, IconButtonProps>(
|
|
(
|
|
{ accessibilityLabel, icon, isLoading = false, size = 'default', ...props },
|
|
ref
|
|
) => {
|
|
const iconButtonClassName = `icon-button-${size}`
|
|
const iconSizeClassName = size === 'large' ? 'icon-large' : 'icon-small'
|
|
const materialIconClassName = classNames(iconSizeClassName, {
|
|
'button-content-hidden': isLoading,
|
|
})
|
|
|
|
return (
|
|
<Button
|
|
className={iconButtonClassName}
|
|
isLoading={isLoading}
|
|
aria-label={accessibilityLabel}
|
|
{...props}
|
|
ref={ref}
|
|
>
|
|
<MaterialIcon className={materialIconClassName} type={icon} />
|
|
</Button>
|
|
)
|
|
}
|
|
)
|
|
IconButton.displayName = 'IconButton'
|
|
|
|
export default IconButton
|