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

50 lines
1.1 KiB
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'
import { ChangeEvent } from 'react'
function handleChange(e: ChangeEvent<HTMLInputElement>) {
state.send('CHANGED_STYLE', {
dash: e.currentTarget.value,
})
}
interface Props {
dash: DashStyle
}
export default function DashPicker({ dash }: Props) {
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>
)
}