2021-06-02 11:50:34 +00:00
|
|
|
import * as DropdownMenu from '@radix-ui/react-dropdown-menu'
|
|
|
|
import { IconButton } from 'components/shared'
|
2021-06-02 21:17:38 +00:00
|
|
|
import Tooltip from 'components/tooltip'
|
2021-06-02 11:50:34 +00:00
|
|
|
import state, { useSelector } from 'state'
|
|
|
|
import { DashStyle } from 'types'
|
|
|
|
import {
|
|
|
|
DropdownContent,
|
|
|
|
Item,
|
|
|
|
DashDottedIcon,
|
|
|
|
DashSolidIcon,
|
|
|
|
DashDashedIcon,
|
2021-06-03 12:06:39 +00:00
|
|
|
} from '../shared'
|
2021-06-02 11:50:34 +00:00
|
|
|
|
|
|
|
const dashes = {
|
|
|
|
[DashStyle.Solid]: <DashSolidIcon />,
|
|
|
|
[DashStyle.Dashed]: <DashDashedIcon />,
|
|
|
|
[DashStyle.Dotted]: <DashDottedIcon />,
|
|
|
|
}
|
|
|
|
|
2021-06-21 21:35:28 +00:00
|
|
|
export default function QuickdashSelect(): JSX.Element {
|
2021-06-02 11:50:34 +00:00
|
|
|
const dash = useSelector((s) => s.values.selectedStyle.dash)
|
|
|
|
|
|
|
|
return (
|
2021-06-27 19:19:57 +00:00
|
|
|
<DropdownMenu.Root dir="ltr">
|
2021-06-03 16:13:23 +00:00
|
|
|
<DropdownMenu.Trigger
|
|
|
|
as={IconButton}
|
|
|
|
bp={{ '@initial': 'mobile', '@sm': 'small' }}
|
|
|
|
>
|
2021-06-02 21:17:38 +00:00
|
|
|
<Tooltip label="Dash">{dashes[dash]}</Tooltip>
|
2021-06-02 11:50:34 +00:00
|
|
|
</DropdownMenu.Trigger>
|
2021-06-03 16:13:23 +00:00
|
|
|
<DropdownContent sideOffset={8} direction="vertical">
|
2021-06-02 11:50:34 +00:00
|
|
|
<DashItem isActive={dash === DashStyle.Solid} dash={DashStyle.Solid} />
|
|
|
|
<DashItem
|
|
|
|
isActive={dash === DashStyle.Dashed}
|
|
|
|
dash={DashStyle.Dashed}
|
|
|
|
/>
|
|
|
|
<DashItem
|
|
|
|
isActive={dash === DashStyle.Dotted}
|
|
|
|
dash={DashStyle.Dotted}
|
|
|
|
/>
|
|
|
|
</DropdownContent>
|
|
|
|
</DropdownMenu.Root>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
function DashItem({ dash, isActive }: { isActive: boolean; dash: DashStyle }) {
|
|
|
|
return (
|
|
|
|
<Item
|
|
|
|
as={DropdownMenu.DropdownMenuItem}
|
|
|
|
isActive={isActive}
|
|
|
|
onSelect={() => state.send('CHANGED_STYLE', { dash })}
|
|
|
|
>
|
|
|
|
{dashes[dash]}
|
|
|
|
</Item>
|
|
|
|
)
|
|
|
|
}
|