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.

bounds-bg.tsx 796B

123456789101112131415161718192021222324252627282930313233
  1. import { useRef } from "react"
  2. import state, { useSelector } from "state"
  3. import inputs from "state/inputs"
  4. import styled from "styles"
  5. export default function BoundsBg() {
  6. const rBounds = useRef<SVGRectElement>(null)
  7. const bounds = useSelector((state) => state.values.selectedBounds)
  8. if (!bounds) return null
  9. const { minX, minY, width, height } = bounds
  10. return (
  11. <StyledBoundsBg
  12. ref={rBounds}
  13. x={minX}
  14. y={minY}
  15. width={width}
  16. height={height}
  17. onPointerDown={(e) => {
  18. if (e.buttons !== 1) return
  19. e.stopPropagation()
  20. rBounds.current.setPointerCapture(e.pointerId)
  21. state.send("POINTED_BOUNDS", inputs.pointerDown(e, "bounds"))
  22. }}
  23. />
  24. )
  25. }
  26. const StyledBoundsBg = styled("rect", {
  27. fill: "$boundsBg",
  28. })