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

29 lines
821 B
TypeScript
Raw Normal View History

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'
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
}
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>
<DropdownMenu.Trigger
as={RowButton}
bp={{ '@initial': 'mobile', '@sm': 'small' }}
>
<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>
)
}