From aa85703d69938652e4e7dbd38fcc1bec4beb819d Mon Sep 17 00:00:00 2001 From: nvaldez Date: Mon, 28 Sep 2026 16:36:56 +0200 Subject: [PATCH] fix: change highlight color to light blue and add node hover effects - Changed search highlight color from yellow to light blue (#add8e6) - On node hover: node becomes light blue with 1.3x larger size - On node hover: connected edges change to blue (if they were gray) - Restores original colors/sizes when mouse leaves or search is cleared - Updated SPEC.md to document the light blue color Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe --- SPEC.md | 4 +- src/wiki/templates/graph_template.html | 68 ++++++++++++++++++++------ 2 files changed, 56 insertions(+), 16 deletions(-) diff --git a/SPEC.md b/SPEC.md index 5141a23..a55d559 100644 --- a/SPEC.md +++ b/SPEC.md @@ -421,7 +421,7 @@ relationships and navigate their wiki structure. - *3.1.4.3.4.* Support hierarchical layout option. - *3.1.4.3.5.* Node hover shows: filename, number of incoming/outgoing links. - *3.1.4.3.6.* Edge hover shows: link count between files. - - *3.1.4.3.7.* On node hover, highlight all edges connected to that node. + - *3.1.4.3.7.* On node hover, highlight the node in light blue with slightly larger size, and highlight all connected edges in blue (if they are gray). - *3.1.4.3.8.* Click on node opens the markdown file in default editor or browser. - *3.1.4.3.9.* Color coding: nodes use a spectrum from green (no links/gray) to yellow to red (high connectivity) based on in-degree. @@ -504,7 +504,7 @@ relationships and navigate their wiki structure. - *3.1.4.6.1.* Self-contained HTML file with embedded visualization. - *3.1.4.6.2.* Responsive design (adapts to viewport size). - *3.1.4.6.3.* Search/filter nodes by name with degree-based visibility: - - Matching nodes highlighted in yellow and enlarged (1.5x radius) + - Matching nodes highlighted in light blue and enlarged (1.5x radius) - All neighbor nodes (any degree) shown in gray - Non-reachable nodes hidden - *3.1.4.6.4.* Toggle button (not checkbox) to show/hide orphan nodes. diff --git a/src/wiki/templates/graph_template.html b/src/wiki/templates/graph_template.html index 5f59536..d39594f 100644 --- a/src/wiki/templates/graph_template.html +++ b/src/wiki/templates/graph_template.html @@ -476,11 +476,26 @@ .style('top', (pos[1] + 10) + 'px') .style('display', 'block'); - // Highlight all edges connected to this node by dimming others + // Store current state of this node + const currentFill = d3.select(this).attr('fill'); + const currentRadius = parseFloat(d3.select(this).attr('r')); + + // Highlight the hovered node + d3.select(this) + .attr('fill', '#add8e6') // Light blue + .attr('r', currentRadius * 1.3); // Slightly larger + + // Highlight all edges connected to this node link + .attr('stroke', function(linkD) { + // Check if this edge is connected to the hovered node + if (linkD.source.id === d.id || linkD.target.id === d.id) { + return '#0000ff'; // Blue for connected edges + } + return getEdgeColor(linkD.weight); // Original color for others + }) .attr('opacity', function(linkD) { // Check if this edge is connected to the hovered node - // linkD.source and linkD.target are node objects with .id property if (linkD.source.id === d.id || linkD.target.id === d.id) { return 1; // Full opacity for connected edges } @@ -490,10 +505,33 @@ .on('mouseout', function() { d3.select('.node-info').style('display', 'none'); - // Reset all edges to normal appearance + // Restore all edges to normal appearance link + .attr('stroke', function(linkD) { + return getEdgeColor(linkD.weight); + }) .attr('opacity', 0); + // Restore node appearance + d3.select(this) + .attr('fill', function(d) { + if (searchActive && filteredNodeIds !== null && lastSearchDistances) { + const dist = lastSearchDistances[d.id]; + if (dist === 0) return '#add8e6'; // Matching nodes in search + if (dist !== undefined) return '#808080'; // Neighbors in search + return originalColors.get(d.id); + } + return originalColors.get(d.id); + }) + .attr('r', function(d) { + if (searchActive && filteredNodeIds !== null && lastSearchDistances) { + const dist = lastSearchDistances[d.id]; + if (dist === 0) return originalRadii.get(d.id) * 1.5; // Matching nodes in search + return originalRadii.get(d.id); + } + return originalRadii.get(d.id); + }); + // Restore opacity for visible edges link .filter((d, i) => visibleEdges.has(i)) @@ -705,6 +743,7 @@ let originalColors = new Map(); let originalRadii = new Map(); let searchActive = false; + let lastSearchDistances = null; // Store original colors and radii for all nodes nodeData.forEach(n => { @@ -719,6 +758,7 @@ // Clear search - restore all filteredNodeIds = null; searchActive = false; + lastSearchDistances = null; node .style('opacity', function(d) { return visibleNodes.has(d.id) ? 1 : 0; @@ -765,12 +805,12 @@ }); // Calculate distances from matching nodes using BFS - const distances = {}; + lastSearchDistances = {}; const queue = []; // Initialize: all matching nodes have distance 0 matchingNodeIds.forEach(nodeId => { - distances[nodeId] = 0; + lastSearchDistances[nodeId] = 0; queue.push(nodeId); }); @@ -778,7 +818,7 @@ let idx = 0; while (idx < queue.length) { const currentId = queue[idx++]; - const currentDistance = distances[currentId]; + const currentDistance = lastSearchDistances[currentId]; // Stop at 3rd degree (distance 3) if (currentDistance >= 3) continue; @@ -786,8 +826,8 @@ // Visit neighbors const neighbors = adjacency[currentId] || new Set(); neighbors.forEach(neighborId => { - if (distances[neighborId] === undefined) { - distances[neighborId] = currentDistance + 1; + if (lastSearchDistances[neighborId] === undefined) { + lastSearchDistances[neighborId] = currentDistance + 1; queue.push(neighborId); } }); @@ -797,20 +837,20 @@ node .style('opacity', function(d) { if (!visibleNodes.has(d.id)) return 0; - const dist = distances[d.id]; + const dist = lastSearchDistances[d.id]; if (dist === undefined) return 0; // Not reachable from matching nodes return 1; // All reachable nodes are visible }) .style('fill', function(d) { if (!visibleNodes.has(d.id)) return originalColors.get(d.id); - const dist = distances[d.id]; + const dist = lastSearchDistances[d.id]; if (dist === undefined) return '#ffffff'; // Not reachable - white (hidden) - if (dist === 0) return '#ffff00'; // Matching nodes - yellow highlight + if (dist === 0) return '#add8e6'; // Matching nodes - light blue highlight return '#808080'; // All neighbors - gray }) .attr('r', function(d) { if (!visibleNodes.has(d.id)) return originalRadii.get(d.id); - const dist = distances[d.id]; + const dist = lastSearchDistances[d.id]; if (dist === undefined) return originalRadii.get(d.id); if (dist === 0) return originalRadii.get(d.id) * 1.5; // Matching nodes - 1.5x bigger return originalRadii.get(d.id); // All neighbors - normal size @@ -819,8 +859,8 @@ link.style('opacity', function(d) { if (!visibleEdges.has(d.index)) return 0; // Show edge if both ends are visible - const sourceVisible = distances[d.source.id] !== undefined; - const targetVisible = distances[d.target.id] !== undefined; + const sourceVisible = lastSearchDistances[d.source.id] !== undefined; + const targetVisible = lastSearchDistances[d.target.id] !== undefined; if (sourceVisible && targetVisible) { return 1; // Full opacity for edges between visible nodes }