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.

page.tsx 1008B

123456789101112131415161718192021222324252627282930313233343536
  1. import { useSelector } from 'state'
  2. import { GroupShape } from 'types'
  3. import { deepCompareArrays, getPage } from 'utils/utils'
  4. import Shape from './shape'
  5. /*
  6. On each state change, compare node ids of all shapes
  7. on the current page. Kind of expensive but only happens
  8. here; and still cheaper than any other pattern I've found.
  9. */
  10. const noOffset = [0, 0]
  11. export default function Page() {
  12. const currentPageShapeIds = useSelector(({ data }) => {
  13. return Object.values(getPage(data).shapes)
  14. .filter((shape) => shape.parentId === data.currentPageId)
  15. .sort((a, b) => a.childIndex - b.childIndex)
  16. .map((shape) => shape.id)
  17. }, deepCompareArrays)
  18. const isSelecting = useSelector((s) => s.isIn('selecting'))
  19. return (
  20. <g pointerEvents={isSelecting ? 'all' : 'none'}>
  21. {currentPageShapeIds.map((shapeId) => (
  22. <Shape
  23. key={shapeId}
  24. id={shapeId}
  25. isSelecting={isSelecting}
  26. parentPoint={noOffset}
  27. />
  28. ))}
  29. </g>
  30. )
  31. }