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

47 lines
1,018 B
TypeScript
Raw Normal View History

import {
Group,
Item,
DashDashedIcon,
DashDottedIcon,
DashSolidIcon,
2021-06-03 12:06:39 +00:00
} from '../shared'
import * as RadioGroup from '@radix-ui/react-radio-group'
2021-06-01 21:49:32 +00:00
import { DashStyle } from 'types'
import state from 'state'
function handleChange(dash: string) {
state.send('CHANGED_STYLE', { dash })
2021-06-01 21:49:32 +00:00
}
interface Props {
dash: DashStyle
}
2021-06-21 21:35:28 +00:00
export default function DashPicker({ dash }: Props): JSX.Element {
2021-06-01 21:49:32 +00:00
return (
<Group name="Dash" onValueChange={handleChange}>
<Item
as={RadioGroup.RadioGroupItem}
value={DashStyle.Solid}
isActive={dash === DashStyle.Solid}
>
2021-06-01 21:49:32 +00:00
<DashSolidIcon />
</Item>
<Item
as={RadioGroup.RadioGroupItem}
value={DashStyle.Dashed}
isActive={dash === DashStyle.Dashed}
>
2021-06-01 21:49:32 +00:00
<DashDashedIcon />
</Item>
<Item
as={RadioGroup.RadioGroupItem}
value={DashStyle.Dotted}
isActive={dash === DashStyle.Dotted}
>
2021-06-01 21:49:32 +00:00
<DashDottedIcon />
</Item>
2021-06-01 21:49:32 +00:00
</Group>
)
}