Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import { useSelector } from "state"
  2. import { DotShape } from "types"
  3. import ShapeGroup from "./shape-group"
  4. interface BaseCircleProps {
  5. point: number[]
  6. fill?: string
  7. stroke?: string
  8. strokeWidth?: number
  9. }
  10. function BaseDot({
  11. point,
  12. fill = "#ccc",
  13. stroke = "none",
  14. strokeWidth = 0,
  15. }: BaseCircleProps) {
  16. return (
  17. <g>
  18. <circle
  19. cx={point[0] + strokeWidth}
  20. cy={point[1] + strokeWidth}
  21. r={8}
  22. fill="transparent"
  23. stroke="none"
  24. strokeWidth="0"
  25. />
  26. <circle
  27. cx={point[0] + strokeWidth}
  28. cy={point[1] + strokeWidth}
  29. r={Math.max(1, 4 - strokeWidth)}
  30. fill={fill}
  31. stroke={stroke}
  32. strokeWidth={strokeWidth}
  33. />
  34. </g>
  35. )
  36. }
  37. export default function Dot({ id, point }: DotShape) {
  38. const isSelected = useSelector((state) => state.values.selectedIds.has(id))
  39. return (
  40. <ShapeGroup id={id}>
  41. <BaseDot point={point} />
  42. {isSelected && (
  43. <BaseDot point={point} fill="none" stroke="blue" strokeWidth={1} />
  44. )}
  45. </ShapeGroup>
  46. )
  47. }