tldraw/components/style-panel/color-picker.tsx

26 lines
737 B
TypeScript
Raw Normal View History

2021-05-28 20:30:27 +00:00
import * as DropdownMenu from '@radix-ui/react-dropdown-menu'
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'
import ColorContent from './color-content'
2021-05-26 10:34:10 +00:00
interface Props {
color: ColorStyle
onChange: (color: ColorStyle) => void
2021-05-26 10:34:10 +00:00
}
export default function ColorPicker({ color, onChange }: Props) {
2021-05-26 10:34:10 +00:00
return (
<DropdownMenu.Root>
<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>
)
}