Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

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