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.

width-picker.tsx 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. import { DotsHorizontalIcon } from '@radix-ui/react-icons'
  2. import * as RadioGroup from '@radix-ui/react-radio-group'
  3. import { IconButton } from 'components/shared'
  4. import { ChangeEvent } from 'react'
  5. import { Circle } from 'react-feather'
  6. import state from 'state'
  7. import styled from 'styles'
  8. function setWidth(e: ChangeEvent<HTMLInputElement>) {
  9. state.send('CHANGED_STYLE', {
  10. strokeWidth: Number(e.currentTarget.value),
  11. })
  12. }
  13. export default function WidthPicker({
  14. strokeWidth = 2,
  15. }: {
  16. strokeWidth?: number
  17. }) {
  18. return (
  19. <Group name="width" onValueChange={setWidth}>
  20. <RadioItem value="2" isActive={strokeWidth === 2}>
  21. <Circle size={6} />
  22. </RadioItem>
  23. <RadioItem value="4" isActive={strokeWidth === 4}>
  24. <Circle size={12} />
  25. </RadioItem>
  26. <RadioItem value="8" isActive={strokeWidth === 8}>
  27. <Circle size={18} />
  28. </RadioItem>
  29. </Group>
  30. )
  31. }
  32. const Group = styled(RadioGroup.Root, {
  33. display: 'flex',
  34. })
  35. const RadioItem = styled(RadioGroup.Item, {
  36. height: '32px',
  37. width: '32px',
  38. backgroundColor: '$panel',
  39. borderRadius: '4px',
  40. padding: '0',
  41. margin: '0',
  42. display: 'flex',
  43. alignItems: 'center',
  44. justifyContent: 'center',
  45. outline: 'none',
  46. border: 'none',
  47. pointerEvents: 'all',
  48. cursor: 'pointer',
  49. '&:hover:not(:disabled)': {
  50. backgroundColor: '$hover',
  51. '& svg': {
  52. fill: '$text',
  53. strokeWidth: '0',
  54. },
  55. },
  56. '&:disabled': {
  57. opacity: '0.5',
  58. },
  59. variants: {
  60. isActive: {
  61. true: {
  62. '& svg': {
  63. fill: '$text',
  64. strokeWidth: '0',
  65. },
  66. },
  67. false: {
  68. '& svg': {
  69. fill: '$inactive',
  70. strokeWidth: '0',
  71. },
  72. },
  73. },
  74. },
  75. })