2021-05-28 20:30:27 +00:00
|
|
|
import * as DropdownMenu from '@radix-ui/react-dropdown-menu'
|
2021-06-02 11:50:34 +00:00
|
|
|
import { strokes } from 'lib/shape-styles'
|
|
|
|
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-02 11:50:34 +00:00
|
|
|
export default function ColorPicker({ color, onChange }: Props) {
|
2021-05-26 10:34:10 +00:00
|
|
|
return (
|
|
|
|
<DropdownMenu.Root>
|
2021-06-02 11:50:34 +00:00
|
|
|
<DropdownMenu.Trigger as={RowButton}>
|
|
|
|
<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>
|
|
|
|
)
|
|
|
|
}
|