parser and editor use same code for figuring out what is connected to what

This commit is contained in:
Joeri Exelmans 2025-10-17 14:37:26 +02:00
parent 6dc7a2e9a7
commit b55cba198e
6 changed files with 228 additions and 149 deletions

View file

@ -1,11 +1,10 @@
import { Vec2D } from "./geometry";
import { HISTORY_RADIUS } from "./parameters";
export function HistorySVG(props: {uid: string, topLeft: Vec2D, kind: "shallow"|"deep", selected: boolean}) {
export function HistorySVG(props: {uid: string, topLeft: Vec2D, kind: "shallow"|"deep", selected: boolean, highlight: boolean}) {
const text = props.kind === "shallow" ? "H" : "H*";
return <>
<circle
className={props.selected ? "selected":""}
cx={props.topLeft.x+HISTORY_RADIUS}
cy={props.topLeft.y+HISTORY_RADIUS}
r={HISTORY_RADIUS}
@ -17,7 +16,7 @@ export function HistorySVG(props: {uid: string, topLeft: Vec2D, kind: "shallow"|
/>
<text
x={props.topLeft.x+HISTORY_RADIUS}
y={props.topLeft.y+HISTORY_RADIUS+4}
y={props.topLeft.y+HISTORY_RADIUS+5}
textAnchor="middle"
fontWeight={500}
>{text}</text>
@ -29,5 +28,14 @@ export function HistorySVG(props: {uid: string, topLeft: Vec2D, kind: "shallow"|
data-uid={props.uid}
data-parts="history"
/>
{(props.selected || props.highlight) &&
<circle
className={props.selected ? "selected" : props.highlight ? "highlight" : ""}
cx={props.topLeft.x+HISTORY_RADIUS}
cy={props.topLeft.y+HISTORY_RADIUS}
r={HISTORY_RADIUS}
data-uid={props.uid}
data-parts="history"
/>}
</>;
}
}