2021-06-02 11:50:34 +00:00
|
|
|
import * as DropdownMenu from '@radix-ui/react-dropdown-menu'
|
2021-07-14 13:45:24 +00:00
|
|
|
import { DropdownMenuIconTriggerButton } from 'components/shared'
|
2021-07-13 21:13:31 +00:00
|
|
|
import { strokes } from 'state/shape-styles'
|
2021-07-13 21:20:16 +00:00
|
|
|
import state, { useSelector } from 'state'
|
2021-07-14 13:45:24 +00:00
|
|
|
import { BoxIcon, StyleDropdownItem, StyleDropdownContent } from './shared'
|
2021-07-14 08:04:07 +00:00
|
|
|
import { useTheme } from 'next-themes'
|
2021-07-13 21:20:16 +00:00
|
|
|
import { ColorStyle } from 'types'
|
|
|
|
|
|
|
|
function handleColorChange(color: ColorStyle): void {
|
|
|
|
state.send('CHANGED_STYLE', { color })
|
|
|
|
}
|
2021-06-02 11:50:34 +00:00
|
|
|
|
2021-06-21 21:35:28 +00:00
|
|
|
export default function QuickColorSelect(): JSX.Element {
|
2021-06-02 11:50:34 +00:00
|
|
|
const color = useSelector((s) => s.values.selectedStyle.color)
|
2021-07-10 20:39:29 +00:00
|
|
|
const { theme } = useTheme()
|
2021-06-02 11:50:34 +00:00
|
|
|
|
|
|
|
return (
|
2021-06-27 19:19:57 +00:00
|
|
|
<DropdownMenu.Root dir="ltr">
|
2021-07-14 13:45:24 +00:00
|
|
|
<DropdownMenuIconTriggerButton label="Color">
|
|
|
|
<BoxIcon fill={strokes[theme][color]} stroke={strokes[theme][color]} />
|
|
|
|
</DropdownMenuIconTriggerButton>
|
2021-07-14 15:46:00 +00:00
|
|
|
<DropdownMenu.Content sideOffset={8}>
|
2021-07-14 13:45:24 +00:00
|
|
|
<DropdownMenu.DropdownMenuRadioGroup
|
|
|
|
value={color}
|
|
|
|
onValueChange={handleColorChange}
|
2021-07-14 15:46:00 +00:00
|
|
|
as={StyleDropdownContent}
|
2021-07-14 13:45:24 +00:00
|
|
|
>
|
|
|
|
{Object.keys(strokes[theme]).map((colorStyle: ColorStyle) => (
|
|
|
|
<DropdownMenu.DropdownMenuRadioItem
|
|
|
|
as={StyleDropdownItem}
|
|
|
|
key={colorStyle}
|
|
|
|
title={colorStyle}
|
|
|
|
value={colorStyle}
|
|
|
|
>
|
|
|
|
<BoxIcon
|
|
|
|
fill={strokes[theme][colorStyle]}
|
|
|
|
stroke={strokes[theme][colorStyle]}
|
|
|
|
/>
|
|
|
|
</DropdownMenu.DropdownMenuRadioItem>
|
|
|
|
))}
|
|
|
|
</DropdownMenu.DropdownMenuRadioGroup>
|
|
|
|
</DropdownMenu.Content>
|
2021-06-02 11:50:34 +00:00
|
|
|
</DropdownMenu.Root>
|
|
|
|
)
|
|
|
|
}
|