feat: highlight upstream/downstream edges when node selected

This commit is contained in:
2026-06-08 13:09:47 +08:00
parent a16f34acd9
commit a0749261bf

View File

@@ -47,12 +47,22 @@ function makeNodes() {
}
function makeEdges() {
return props.sceneEdges.map((e) => ({
id: e.id,
source: e.source,
target: e.target,
label: e.label ?? '',
}))
return props.sceneEdges.map((e) => {
const isUp = props.selectedNodeId != null && e.target === props.selectedNodeId
const isDown = props.selectedNodeId != null && e.source === props.selectedNodeId
return {
id: e.id,
source: e.source,
target: e.target,
label: e.label ?? '',
animated: isUp || isDown,
style: isUp
? { stroke: '#ff9800', strokeWidth: 2 }
: isDown
? { stroke: '#4fc3f7', strokeWidth: 2 }
: undefined,
}
})
}
let prevNodeCount = -1