2021-06-02 11:50:34 +00:00
|
|
|
import {
|
|
|
|
Group,
|
|
|
|
Item,
|
|
|
|
DashDashedIcon,
|
|
|
|
DashDottedIcon,
|
|
|
|
DashSolidIcon,
|
2021-06-03 12:06:39 +00:00
|
|
|
} from '../shared'
|
2021-06-02 11:50:34 +00:00
|
|
|
import * as RadioGroup from '@radix-ui/react-radio-group'
|
2021-06-01 21:49:32 +00:00
|
|
|
import { DashStyle } from 'types'
|
2021-06-28 12:13:34 +00:00
|
|
|
import state, { useSelector } from 'state'
|
|
|
|
import { memo } from 'react'
|
2021-06-01 21:49:32 +00:00
|
|
|
|
2021-06-16 12:09:45 +00:00
|
|
|
function handleChange(dash: string) {
|
|
|
|
state.send('CHANGED_STYLE', { dash })
|
2021-06-01 21:49:32 +00:00
|
|
|
}
|
|
|
|
|
2021-06-28 12:13:34 +00:00
|
|
|
const dashes = {
|
|
|
|
[DashStyle.Solid]: <DashSolidIcon />,
|
|
|
|
[DashStyle.Dashed]: <DashDashedIcon />,
|
|
|
|
[DashStyle.Dotted]: <DashDottedIcon />,
|
2021-06-01 21:49:32 +00:00
|
|
|
}
|
|
|
|
|
2021-06-28 12:13:34 +00:00
|
|
|
function DashPicker(): JSX.Element {
|
|
|
|
const dash = useSelector((s) => s.values.selectedStyle.dash)
|
|
|
|
|
2021-06-01 21:49:32 +00:00
|
|
|
return (
|
|
|
|
<Group name="Dash" onValueChange={handleChange}>
|
2021-06-28 12:13:34 +00:00
|
|
|
{Object.keys(DashStyle).map((dashStyle: DashStyle) => (
|
|
|
|
<RadioGroup.RadioGroupItem
|
|
|
|
as={Item}
|
|
|
|
key={dashStyle}
|
|
|
|
isActive={dash === dashStyle}
|
|
|
|
value={dashStyle}
|
|
|
|
>
|
|
|
|
{dashes[dashStyle]}
|
|
|
|
</RadioGroup.RadioGroupItem>
|
|
|
|
))}
|
2021-06-01 21:49:32 +00:00
|
|
|
</Group>
|
|
|
|
)
|
|
|
|
}
|
2021-06-28 12:13:34 +00:00
|
|
|
|
|
|
|
export default memo(DashPicker)
|