You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

dash-picker.tsx 1003B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import {
  2. Group,
  3. Item,
  4. DashDashedIcon,
  5. DashDottedIcon,
  6. DashSolidIcon,
  7. } from '../shared'
  8. import * as RadioGroup from '@radix-ui/react-radio-group'
  9. import { DashStyle } from 'types'
  10. import state, { useSelector } from 'state'
  11. import { memo } from 'react'
  12. function handleChange(dash: string) {
  13. state.send('CHANGED_STYLE', { dash })
  14. }
  15. const dashes = {
  16. [DashStyle.Solid]: <DashSolidIcon />,
  17. [DashStyle.Dashed]: <DashDashedIcon />,
  18. [DashStyle.Dotted]: <DashDottedIcon />,
  19. }
  20. function DashPicker(): JSX.Element {
  21. const dash = useSelector((s) => s.values.selectedStyle.dash)
  22. return (
  23. <Group name="Dash" onValueChange={handleChange}>
  24. {Object.keys(DashStyle).map((dashStyle: DashStyle) => (
  25. <RadioGroup.RadioGroupItem
  26. as={Item}
  27. key={dashStyle}
  28. isActive={dash === dashStyle}
  29. value={dashStyle}
  30. >
  31. {dashes[dashStyle]}
  32. </RadioGroup.RadioGroupItem>
  33. ))}
  34. </Group>
  35. )
  36. }
  37. export default memo(DashPicker)