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.

polyline.tsx 840B

1234567891011121314151617181920212223242526272829303132333435
  1. import { useSelector } from "state"
  2. import { PolylineShape } from "types"
  3. import ShapeGroup from "./shape-g"
  4. interface BasePolylineProps extends Pick<PolylineShape, "points"> {
  5. fill?: string
  6. stroke?: string
  7. strokeWidth?: number
  8. }
  9. function BasePolyline({
  10. points,
  11. fill = "none",
  12. stroke = "#ccc",
  13. strokeWidth = 2,
  14. }: BasePolylineProps) {
  15. return (
  16. <polyline
  17. points={points.toString()}
  18. fill={fill}
  19. stroke={stroke}
  20. strokeWidth={strokeWidth}
  21. />
  22. )
  23. }
  24. export default function Polyline({ id, point, points }: PolylineShape) {
  25. const isSelected = useSelector((state) => state.values.selectedIds.has(id))
  26. return (
  27. <ShapeGroup id={id} point={point}>
  28. <BasePolyline points={points} />
  29. {isSelected && <BasePolyline points={points} fill="none" stroke="blue" />}
  30. </ShapeGroup>
  31. )
  32. }