Skip to content

add hover color highlighting for schematic traces#174

Open
lyfher wants to merge 1 commit intotscircuit:mainfrom
lyfher:feat/trace-hover-highlight
Open

add hover color highlighting for schematic traces#174
lyfher wants to merge 1 commit intotscircuit:mainfrom
lyfher:feat/trace-hover-highlight

Conversation

@lyfher
Copy link
Copy Markdown

@lyfher lyfher commented Apr 15, 2026

Fixes tscircuit/tscircuit#1130

Hovering over a schematic trace now changes its stroke color to #3399ff and highlights junction dots to match.

How it works

  • New hook useTraceHoverHighlighting attaches mouseenter/mouseleave listeners to every g[data-schematic-trace-id] element in the SVG
  • On hover, adds the trace-hover CSS class to both the base and overlay <g> groups that share the same data-schematic-trace-id
  • CSS .trace-hover rule changes the stroke color and junction fill to #3399ff
  • A MutationObserver re-attaches listeners after every SVG re-render (e.g. window resize)

Changes

  • lib/hooks/useTraceHoverHighlighting.ts — new hook (80 lines)
  • lib/components/SchematicViewer.tsx — import hook + add CSS style tag

When the pointer enters a schematic trace the matching <g> elements
(base layer and overlay layer) receive the `trace-hover` CSS class,
which changes the stroke to #3399ff and updates junction fill to match.

A MutationObserver re-attaches listeners after every SVG re-render
(e.g. triggered by window resize) so highlighting stays functional
across layout changes.

Closes tscircuit/tscircuit#1130

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 15, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
schematic-viewer Ready Ready Preview, Comment Apr 15, 2026 1:47pm

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Change of color on hover for traces are missing

2 participants