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.

1234567891011121314151617181920212223242526272829
  1. import { memo } from "react"
  2. import { useSelector } from "state"
  3. import { ShapeType } from "types"
  4. import Circle from "./shapes/circle"
  5. import Rectangle from "./shapes/rectangle"
  6. /*
  7. Gets the shape from the current page's shapes, using the
  8. provided ID. Depending on the shape's type, return the
  9. component for that type.
  10. */
  11. function Shape({ id }: { id: string }) {
  12. const shape = useSelector((state) => {
  13. const { currentPageId, document } = state.data
  14. return document.pages[currentPageId].shapes[id]
  15. })
  16. switch (shape.type) {
  17. case ShapeType.Circle:
  18. return <Circle {...shape} />
  19. case ShapeType.Rectangle:
  20. return <Rectangle {...shape} />
  21. default:
  22. return null
  23. }
  24. }
  25. export default memo(Shape)