Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 23, 2026

Progressive Navigation Implementation for TOC

Goal: Implement animated SVG marker in the TOC that highlights currently visible sections as user scrolls

Implementation Complete ✅

  • Analyze current TOC component structure and styling
  • Add SVG marker element to Toc component
  • Implement intersection observer to track visible sections
  • Add logic to calculate and draw SVG path based on TOC item positions
  • Update path animation based on scroll position
  • Style the marker to match the site theme
  • Test the progressive navigation with different page content
  • Verify responsive behavior
  • Run linting and build tests
  • Address code review feedback
  • Pass security checks (CodeQL)

Changes Made:

  • Updated /src/components/mdx/Toc/Toc.tsx to add:
    • Intersection Observer to track visible heading sections
    • SVG path element that follows the TOC structure
    • Dynamic stroke-dasharray animation showing active sections
    • Refs to track TOC item positions for accurate path drawing
    • Smooth transitions with CSS animations
    • Accurate path length calculation accounting for horizontal movement
    • Named constant for max dash length

Technical Details:

  • Uses IntersectionObserver API to detect when heading elements enter/exit viewport
  • Dynamically generates an SVG path that follows the TOC item structure
  • Animates the visible portion of the path using stroke-dasharray and stroke-dashoffset
  • Path automatically redraws on window resize
  • Uses theme's primary color for the marker
  • 300ms ease-out transition for smooth animations
  • Proper path length calculation includes both horizontal and vertical segments

Security:

  • ✅ No security vulnerabilities detected by CodeQL
  • ✅ All lint checks passing
Original prompt

can you implement this "progressive nav" for our toc ? https://gist.github.com/abernier/ead9725196255b2d8df7b7de6ce0170b


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits January 23, 2026 11:10
Co-authored-by: abernier <76580+abernier@users.noreply.github.com>
… named constant

Co-authored-by: abernier <76580+abernier@users.noreply.github.com>
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.

2 participants