@@ -102,6 +102,7 @@ const App = () => {
102102 const [ manualPositions , setManualPositions ] = useState <
103103 Record < string , { x : number ; y : number } >
104104 > ( { } ) ;
105+ const [ draggedNodeId , setDraggedNodeId ] = useState < string | null > ( null ) ;
105106 const [ nodes , setNodes ] = useNodesState ( [ ] ) ;
106107 const [ edges , setEdges , onEdgesChange ] = useEdgesState ( [ ] ) ;
107108 const flowInstance = useRef < ReactFlowInstance | null > ( null ) ;
@@ -427,6 +428,34 @@ const App = () => {
427428 return layoutGraph ( flowNodes , flowEdges ) ;
428429 } , [ graph , selectedNodeId , layoutVersion , effectiveColorScheme , theme ] ) ;
429430
431+ useEffect ( ( ) => {
432+ const isDark = effectiveColorScheme === "dark" ;
433+ const defaultStroke = isDark ? theme . colors . dark [ 3 ] : theme . colors . gray [ 5 ] ;
434+ const highlightStroke = theme . colors . blue [ 6 ] ;
435+ setEdges ( ( current ) =>
436+ current . map ( ( edge ) => {
437+ const isConnected =
438+ draggedNodeId !== null &&
439+ ( edge . source === draggedNodeId || edge . target === draggedNodeId ) ;
440+ const stroke = isConnected ? highlightStroke : defaultStroke ;
441+ return {
442+ ...edge ,
443+ style : {
444+ ...edge . style ,
445+ stroke,
446+ strokeWidth : isConnected ? 2 : 1 ,
447+ } ,
448+ markerStart : edge . markerStart
449+ ? {
450+ ...edge . markerStart ,
451+ color : stroke ,
452+ }
453+ : edge . markerStart ,
454+ } ;
455+ } )
456+ ) ;
457+ } , [ draggedNodeId , effectiveColorScheme , theme , setEdges ] ) ;
458+
430459 const nodeCount = graph ? Object . keys ( graph . nodes ) . length : 0 ;
431460 const rootNodeCount = graph ?. rootNodes ?. length ?? 0 ;
432461 const formatLabel = ( value : string ) =>
@@ -876,6 +905,8 @@ const App = () => {
876905 onNodeClick = { ( _ , node ) =>
877906 loadProjectResults ( node . data . meta as ProjectNode )
878907 }
908+ onNodeDragStart = { ( _ , node ) => setDraggedNodeId ( node . id ) }
909+ onNodeDragStop = { ( ) => setDraggedNodeId ( null ) }
879910 onReflow = { ( ) => {
880911 setManualPositions ( { } ) ;
881912 setLayoutVersion ( ( value ) => value + 1 ) ;
0 commit comments