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.

quick-fill-select.tsx 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import * as Checkbox from '@radix-ui/react-checkbox'
  2. import tld from 'utils/tld'
  3. import { breakpoints, IconButton, IconWrapper } from '../shared'
  4. import { BoxIcon, IsFilledFillIcon } from './shared'
  5. import state, { useSelector } from 'state'
  6. import { getShapeUtils } from 'state/shape-utils'
  7. import Tooltip from 'components/tooltip'
  8. function handleIsFilledChange(isFilled: boolean) {
  9. state.send('CHANGED_STYLE', { isFilled })
  10. }
  11. export default function IsFilledPicker(): JSX.Element {
  12. const isFilled = useSelector((s) => s.values.selectedStyle.isFilled)
  13. const canFill = useSelector((s) => {
  14. const selectedShapes = tld.getSelectedShapes(s.data)
  15. return (
  16. selectedShapes.length === 0 ||
  17. selectedShapes.some((shape) => getShapeUtils(shape).canStyleFill)
  18. )
  19. })
  20. return (
  21. <Checkbox.Root
  22. dir="ltr"
  23. as={IconButton}
  24. bp={breakpoints}
  25. checked={isFilled}
  26. disabled={!canFill}
  27. onCheckedChange={handleIsFilledChange}
  28. >
  29. <Tooltip label="Fill">
  30. <IconWrapper>
  31. <BoxIcon />
  32. <Checkbox.Indicator>
  33. <IsFilledFillIcon />
  34. </Checkbox.Indicator>
  35. </IconWrapper>
  36. </Tooltip>
  37. </Checkbox.Root>
  38. )
  39. }