fix(BOOK-293): changed variants and props on IconButton component * fix(BOOK-293): changed variants and props on IconButton component * fix(BOOK-293): inherit color for icon Approved-by: Bianca Widstam Approved-by: Christel Westerberg
46 lines
818 B
TypeScript
46 lines
818 B
TypeScript
import { Button as ButtonRAC } from 'react-aria-components'
|
|
|
|
import { MaterialIcon } from '../Icons/MaterialIcon'
|
|
import { IconButtonProps } from './types'
|
|
import { variants } from './variants'
|
|
|
|
export function IconButton({
|
|
variant,
|
|
emphasis,
|
|
size,
|
|
iconName,
|
|
className,
|
|
...props
|
|
}: IconButtonProps) {
|
|
const classNames = variants({
|
|
variant,
|
|
emphasis,
|
|
size,
|
|
className,
|
|
})
|
|
|
|
return (
|
|
<ButtonRAC {...props} className={classNames}>
|
|
<MaterialIcon
|
|
icon={iconName}
|
|
size={getIconSize(size)}
|
|
color="CurrentColor"
|
|
/>
|
|
</ButtonRAC>
|
|
)
|
|
}
|
|
|
|
function getIconSize(size: IconButtonProps['size']) {
|
|
switch (size) {
|
|
case 'sm':
|
|
return 16
|
|
case 'md':
|
|
return 20
|
|
case 'xl':
|
|
return 28
|
|
case 'lg':
|
|
default:
|
|
return 24
|
|
}
|
|
}
|