2024-04-16 11:06:42 -04:00
|
|
|
import classNames from 'classnames'
|
2024-03-06 06:31:25 -05:00
|
|
|
import MaterialIcon from '@/shared/components/material-icon'
|
|
|
|
import Button from './button'
|
|
|
|
import type { IconButtonProps } from '@/features/ui/components/types/icon-button-props'
|
|
|
|
|
|
|
|
export default function IconButton({
|
2024-03-27 06:53:54 -04:00
|
|
|
accessibilityLabel,
|
2024-03-06 06:31:25 -05:00
|
|
|
icon,
|
|
|
|
isLoading = false,
|
|
|
|
size = 'default',
|
|
|
|
...props
|
|
|
|
}: IconButtonProps) {
|
|
|
|
const iconButtonClassName = `icon-button-${size}`
|
2024-03-27 06:53:54 -04:00
|
|
|
const iconSizeClassName = size === 'large' ? 'icon-large' : 'icon-small'
|
2024-03-06 06:31:25 -05:00
|
|
|
const materialIconClassName = classNames(iconSizeClassName, {
|
|
|
|
'button-content-hidden': isLoading,
|
|
|
|
})
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Button className={iconButtonClassName} isLoading={isLoading} {...props}>
|
|
|
|
<MaterialIcon
|
2024-03-27 06:53:54 -04:00
|
|
|
accessibilityLabel={accessibilityLabel}
|
2024-03-06 06:31:25 -05:00
|
|
|
className={materialIconClassName}
|
|
|
|
type={icon}
|
|
|
|
/>
|
|
|
|
</Button>
|
|
|
|
)
|
|
|
|
}
|