2021-05-28 20:30:27 +00:00
|
|
|
import * as DropdownMenu from '@radix-ui/react-dropdown-menu'
|
2021-06-21 21:35:28 +00:00
|
|
|
import { strokes } from 'state/shape-styles'
|
2021-06-02 11:50:34 +00:00
|
|
|
import { ColorStyle } from 'types'
|
2021-06-03 12:06:39 +00:00
|
|
|
import { RowButton, IconWrapper } from '../shared'
|
2021-05-28 20:30:27 +00:00
|
|
|
import { Square } from 'react-feather'
|
2021-06-02 11:50:34 +00:00
|
|
|
import ColorContent from './color-content'
|
2021-05-26 10:34:10 +00:00
|
|
|
|
|
|
|
interface Props {
|
2021-06-02 11:50:34 +00:00
|
|
|
color: ColorStyle
|
|
|
|
onChange: (color: ColorStyle) => void
|
2021-05-26 10:34:10 +00:00
|
|
|
}
|
|
|
|
|
2021-06-21 21:35:28 +00:00
|
|
|
export default function ColorPicker({ color, onChange }: Props): JSX.Element {
|
2021-05-26 10:34:10 +00:00
|
|
|
return (
|
|
|
|
<DropdownMenu.Root>
|
2021-06-03 16:13:23 +00:00
|
|
|
<DropdownMenu.Trigger
|
|
|
|
as={RowButton}
|
|
|
|
bp={{ '@initial': 'mobile', '@sm': 'small' }}
|
|
|
|
>
|
2021-06-02 11:50:34 +00:00
|
|
|
<label htmlFor="color">Color</label>
|
|
|
|
<IconWrapper>
|
|
|
|
<Square fill={strokes[color]} />
|
|
|
|
</IconWrapper>
|
|
|
|
</DropdownMenu.Trigger>
|
|
|
|
<ColorContent onChange={onChange} />
|
2021-05-26 10:34:10 +00:00
|
|
|
</DropdownMenu.Root>
|
|
|
|
)
|
|
|
|
}
|