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.

size-picker.tsx 930B

12345678910111213141516171819202122232425262728293031323334353637
  1. import { Group, Item } from '../shared'
  2. import * as RadioGroup from '@radix-ui/react-radio-group'
  3. import { Circle } from 'react-feather'
  4. import state, { useSelector } from 'state'
  5. import { SizeStyle } from 'types'
  6. import { memo } from 'react'
  7. const sizes = {
  8. [SizeStyle.Small]: 6,
  9. [SizeStyle.Medium]: 12,
  10. [SizeStyle.Large]: 22,
  11. }
  12. function handleChange(size: string) {
  13. state.send('CHANGED_STYLE', { size })
  14. }
  15. function SizePicker(): JSX.Element {
  16. const size = useSelector((s) => s.values.selectedStyle.size)
  17. return (
  18. <Group name="width" onValueChange={handleChange}>
  19. {Object.keys(SizeStyle).map((sizeStyle: SizeStyle) => (
  20. <RadioGroup.Item
  21. key={sizeStyle}
  22. as={Item}
  23. isActive={size === sizeStyle}
  24. value={sizeStyle}
  25. >
  26. <Circle size={sizes[sizeStyle]} />
  27. </RadioGroup.Item>
  28. ))}
  29. </Group>
  30. )
  31. }
  32. export default memo(SizePicker)