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.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import { Group, RadioItem } from './shared'
  2. import { DashStyle } from 'types'
  3. import state from 'state'
  4. import { ChangeEvent } from 'react'
  5. function handleChange(e: ChangeEvent<HTMLInputElement>) {
  6. state.send('CHANGED_STYLE', {
  7. dash: e.currentTarget.value,
  8. })
  9. }
  10. interface Props {
  11. dash: DashStyle
  12. }
  13. export default function DashPicker({ dash }: Props) {
  14. return (
  15. <Group name="Dash" onValueChange={handleChange}>
  16. <RadioItem value={DashStyle.Solid} isActive={dash === DashStyle.Solid}>
  17. <DashSolidIcon />
  18. </RadioItem>
  19. <RadioItem value={DashStyle.Dashed} isActive={dash === DashStyle.Dashed}>
  20. <DashDashedIcon />
  21. </RadioItem>
  22. <RadioItem value={DashStyle.Dotted} isActive={dash === DashStyle.Dotted}>
  23. <DashDottedIcon />
  24. </RadioItem>
  25. </Group>
  26. )
  27. }
  28. function DashSolidIcon() {
  29. return (
  30. <svg width="16" height="16">
  31. <path d="M 3,8 L 13,8" strokeWidth={3} strokeLinecap="round" />
  32. </svg>
  33. )
  34. }
  35. function DashDashedIcon() {
  36. return (
  37. <svg width="16" height="16">
  38. <path
  39. d="M 2,8 L 14,8"
  40. strokeWidth={3}
  41. strokeLinecap="round"
  42. strokeDasharray="4 4"
  43. />
  44. </svg>
  45. )
  46. }
  47. function DashDottedIcon() {
  48. return (
  49. <svg width="16" height="16">
  50. <path
  51. d="M 3,8 L 14,8"
  52. strokeWidth={3}
  53. strokeLinecap="round"
  54. strokeDasharray="1 4"
  55. />
  56. </svg>
  57. )
  58. }