diff --git a/src/components/svg-canvas-graph.tsx b/src/components/svg-canvas-graph.tsx index 76202044..57091c34 100644 --- a/src/components/svg-canvas-graph.tsx +++ b/src/components/svg-canvas-graph.tsx @@ -444,6 +444,7 @@ const SvgCanvas = () => { <> ; handlePointerDown: (node: StnId | MiscNodeId, e: React.PointerEvent) => void; handlePointerMove: (node: StnId | MiscNodeId, e: React.PointerEvent) => void; handlePointerUp: (node: StnId | MiscNodeId, e: React.PointerEvent) => void; @@ -24,7 +25,8 @@ type StyleComponent = React.FC< const SvgLayer = React.memo( (props: SvgLayerProps) => { - const { elements, handlePointerDown, handlePointerMove, handlePointerUp, handleEdgePointerDown } = props; + const { elements, selected, handlePointerDown, handlePointerMove, handlePointerUp, handleEdgePointerDown } = + props; const layers = Object.fromEntries( Array.from({ length: 21 }, (_, i) => [ @@ -42,7 +44,8 @@ const SvgLayer = React.memo( const PreStyleComponent = lineStyles[style]?.preComponent as StyleComponent | undefined; if (PreStyleComponent) { - layers[element.line!.attr.zIndex].pre.push( + const isSelected = selected.has(element.id); + const preComponent = ( ); + layers[element.line!.attr.zIndex].pre.push( + + {preComponent} + + ); } const StyleComponent = (lineStyles[style]?.component ?? UnknownLineStyle) as StyleComponent; - layers[element.line!.attr.zIndex].main.push( + const isSelected = selected.has(element.id); + const component = ( ); + layers[element.line!.attr.zIndex].main.push( + + {component} + + ); + const PostStyleComponent = lineStyles[style]?.postComponent as StyleComponent | undefined; if (PostStyleComponent) { - layers[element.line!.attr.zIndex].post.push( + const isSelected = selected.has(element.id); + const postComponent = ( ); + layers[element.line!.attr.zIndex].post.push( + + {postComponent} + + ); } } else if (element.type === 'station') { const attr = element.station!; @@ -88,7 +109,8 @@ const SvgLayer = React.memo( const PreStationComponent = allStations[type]?.preComponent; if (PreStationComponent) { - layers[element.station!.zIndex].pre.push( + const isSelected = selected.has(element.id); + const preComponent = ( ); + layers[element.station!.zIndex].pre.push( + + {preComponent} + + ); } const StationComponent = allStations[type]?.component ?? UnknownNode; - layers[element.station!.zIndex].main.push( + const isSelected = selected.has(element.id); + const component = ( ); + layers[element.station!.zIndex].main.push( + + {component} + + ); + const PostStationComponent = allStations[type]?.postComponent; if (PostStationComponent) { - layers[element.station!.zIndex].post.push( + const isSelected = selected.has(element.id); + const postComponent = ( ); + layers[element.station!.zIndex].post.push( + + {postComponent} + + ); } } else if (element.type === 'misc-node') { const attr = element.miscNode!; @@ -137,7 +177,8 @@ const SvgLayer = React.memo( const PreMiscNodeComponent = miscNodes[type]?.preComponent; if (PreMiscNodeComponent) { - layers[element.miscNode!.zIndex].pre.push( + const isSelected = selected.has(element.id); + const preComponent = ( ); + layers[element.miscNode!.zIndex].pre.push( + + {preComponent} + + ); } const MiscNodeComponent = miscNodes[type]?.component ?? UnknownNode; - layers[element.miscNode!.zIndex].main.push( + const isSelected = selected.has(element.id); + const component = ( ); + layers[element.miscNode!.zIndex].main.push( + + {component} + + ); + const PostMiscNodeComponent = miscNodes[type]?.postComponent; if (PostMiscNodeComponent) { - layers[element.miscNode!.zIndex].post.push( + const isSelected = selected.has(element.id); + const postComponent = ( ); + layers[element.miscNode!.zIndex].post.push( + + {postComponent} + + ); } } } @@ -192,7 +251,7 @@ const SvgLayer = React.memo( return jsxElements; }, - (prevProps, nextProps) => prevProps.elements === nextProps.elements + (prevProps, nextProps) => prevProps.elements === nextProps.elements && prevProps.selected === nextProps.selected ); export default SvgLayer; diff --git a/src/components/svg-wrapper.tsx b/src/components/svg-wrapper.tsx index 2366a69e..b1d097b7 100644 --- a/src/components/svg-wrapper.tsx +++ b/src/components/svg-wrapper.tsx @@ -476,6 +476,18 @@ const SvgWrapper = () => { + + + + + + + + + + + + {gridLines && (