diff --git a/src/components/Relationship.jsx b/src/components/Relationship.jsx index 38be3b4..77cf012 100644 --- a/src/components/Relationship.jsx +++ b/src/components/Relationship.jsx @@ -1,17 +1,16 @@ -import { useRef, useState } from "react"; +import { useRef } from "react"; import { calcPath } from "../utils"; import { Cardinality } from "../data/data"; import useSettings from "../hooks/useSettings"; -export default function Relationship(props) { - const [hovered, setHovered] = useState(false); +export default function Relationship({ data }) { const { settings } = useSettings(); const pathRef = useRef(); let cardinalityStart = "1"; let cardinalityEnd = "1"; - switch (props.data.cardinality) { + switch (data.cardinality) { case Cardinality.MANY_TO_ONE: cardinalityStart = "n"; cardinalityEnd = "1"; @@ -33,48 +32,37 @@ export default function Relationship(props) { let cardinalityStartY = 0; let cardinalityEndY = 0; - const length = 32; + const cardinalityOffset = 28; if (pathRef.current) { const pathLength = pathRef.current.getTotalLength(); - const point1 = pathRef.current.getPointAtLength(length); + const point1 = pathRef.current.getPointAtLength(cardinalityOffset); cardinalityStartX = point1.x; cardinalityStartY = point1.y; - const point2 = pathRef.current.getPointAtLength(pathLength - length); + const point2 = pathRef.current.getPointAtLength( + pathLength - cardinalityOffset + ); cardinalityEndX = point2.x; cardinalityEndY = point2.y; } return ( - - - - - - + setHovered(true)} - onMouseLeave={() => setHovered(false)} /> {pathRef.current && settings.showCardinality && ( <> @@ -83,6 +71,7 @@ export default function Relationship(props) { cy={cardinalityStartY} r="12" fill="grey" + className="group-hover:fill-sky-700" >