Skip to content

feat(docs-portal): sticky nav bar with active section highlighting#143

Open
adepoju2006 wants to merge 1 commit into
Pidoko257:mainfrom
adepoju2006:feat/sticky-scroll-spy-nav
Open

feat(docs-portal): sticky nav bar with active section highlighting#143
adepoju2006 wants to merge 1 commit into
Pidoko257:mainfrom
adepoju2006:feat/sticky-scroll-spy-nav

Conversation

@adepoju2006

Copy link
Copy Markdown

Close #89

Summary

Adds a sticky in-page section navigation bar with scroll-spy active highlighting to the docs portal.

This also scaffolds the docs-portal/ Docusaurus site itself — the api-docs-portal.yml workflow already expected a docs-portal/ directory (it runs npm run build there), but the directory did not exist in the repo. This PR creates it and implements the feature inside it.

What's included

  • useScrollSpy.ts — an IntersectionObserver-based hook that returns the id of the section currently in view. SSR-safe (all DOM access inside useEffect); when multiple sections are visible at once, the topmost in document order wins.
  • ScrollSpyNav/index.tsx — the sticky <nav> component: active-link highlighting, click → smooth scroll, URL hash sync, and focus moved to the target section for keyboard / screen-reader users.
  • styles.module.cssposition: sticky pinned below the Docusaurus navbar at every breakpoint (horizontal scroll on mobile), with WCAG-AA color states.
  • src/pages/index.tsx — demo home page wiring the nav to six on-page sections so the behavior is visible and testable.
  • Minimal Docusaurus scaffold: docusaurus.config.ts, sidebars.ts, tsconfig.json, babel.config.js, src/css/custom.css, docs/intro.md, logo, README.

Acceptance criteria

Criterion Implementation
Fixed at top on all screen sizes position: sticky; top: var(--ifm-navbar-height); list scrolls horizontally below 600px
Active link highlighted on scroll useScrollSpy + IntersectionObserver apply .linkActive + aria-current
Smooth scroll on link click scrollIntoView({ behavior: 'smooth' }), honors prefers-reduced-motion
WCAG 2.1 AA contrast (active + inactive) Inactive #44474e / #d0d3d9 (~8.9–12:1), active white on #1d4ed8 (~6.6:1); active also signalled by weight + underline, not color alone

Accessibility notes

  • Active state is conveyed by color and weight and an underline bar — never color alone.
  • aria-current="true" on the active link; aria-label on the nav landmark.
  • Honors prefers-reduced-motion (both the JS smooth-scroll and CSS scroll-behavior).
  • Focus is moved to the target section on click for keyboard/SR users.

Verification

  • npm install
  • npm run build (clean, no warnings — generates build/index.html, matching what CI uploads)
  • npm run typecheck

How to test locally

cd docs-portal
npm install
npm start   # then scroll the home page and click the nav links

Scaffold the Docusaurus docs portal (expected by the api-docs-portal
workflow) and add a sticky in-page section navigation with scroll-spy:

- useScrollSpy: IntersectionObserver hook, SSR-safe, topmost-visible wins
- ScrollSpyNav: sticky nav, active highlight, smooth scroll (reduced-motion
  aware), aria-current, focus management
- WCAG 2.1 AA contrast for active/inactive states (light + dark), active also
  signalled by weight + underline (not color alone)
- Demo home page wiring the nav to on-page sections, intro doc

Verified: npm install, npm run build (clean), npm run typecheck all pass.
@drips-wave

drips-wave Bot commented Jun 30, 2026

Copy link
Copy Markdown

@adepoju2006 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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.

Implement Sticky Navigation Bar with Active Section Highlighting

1 participant