-
Notifications
You must be signed in to change notification settings - Fork 62
/
Copy pathIconButton.tsx
51 lines (45 loc) · 1.23 KB
/
IconButton.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { forwardRef, MouseEvent } from 'react'
import cn from 'classnames'
import { Button } from '@ariakit/react/button'
import { Box, Icon, IconMapIcon } from '@island.is/island-ui/core'
import * as styles from './IconButton.css'
interface Props {
icon: IconMapIcon
colorScheme: 'blue' | 'red' | 'transparent'
onClick?: (evt: MouseEvent) => void
disabled?: boolean
}
const IconButton = forwardRef<HTMLButtonElement, Props>(({ ...props }, ref) => {
const { icon, colorScheme, onClick, disabled } = props
return (
<Box
component={Button}
ref={ref}
className={cn(styles.iconButtonContainer, {
[styles.buttonDisabled]: disabled,
[styles.transparent]: colorScheme === 'transparent',
})}
background={
colorScheme === 'blue'
? 'blue200'
: colorScheme === 'red'
? 'red200'
: 'transparent'
}
onClick={(evt) => onClick && onClick(evt)}
disabled={disabled}
aria-label="Valmynd"
>
<Icon
icon={icon}
color={
colorScheme === 'blue' || colorScheme === 'transparent'
? 'blue400'
: 'red400'
}
size="small"
/>
</Box>
)
})
export default IconButton