Skip to content

The agent that turns websites into APIs!

fix(website): keep navigation pinned during rapid scrolling

kalil032139faf7adbaaa
diff --git a/website/src/components/site-nav.tsx b/website/src/components/site-nav.tsx
index 6224a95..1f7c0ce 100644
--- a/website/src/components/site-nav.tsx
+++ b/website/src/components/site-nav.tsx
@@ -13,61 +13,63 @@ function GithubIcon({ className }: { className?: string }) {
export function SiteNav() {
return (
- <header
- className="sticky top-0 z-50 backdrop-blur-xl backdrop-saturate-150"
- style={{ backgroundColor: 'color-mix(in oklch, var(--color-cream) 58%, transparent)' }}
- >
- <div className="mx-auto flex h-14 max-w-7xl items-center justify-between px-4 sm:px-6 lg:px-10">
- <Link href="/" className="flex items-baseline gap-1.5 group">
- <span
- className="font-display select-none leading-none inline-block italic transition-transform group-hover:rotate-12"
- style={{
- fontSize: 22,
- color: 'var(--color-fd-primary)',
- fontVariationSettings: "'opsz' 144, 'SOFT' 100, 'WONK' 1",
- }}
- aria-hidden="true"
- >
- *
- </span>
- <span
- className="font-display text-2xl tracking-[-0.04em] italic text-ink"
- style={{ fontVariationSettings: "'opsz' 144, 'SOFT' 100, 'WONK' 1" }}
- >
- rae
- </span>
- <span className="sr-only">reverse-api-engineer</span>
- </Link>
- <nav className="flex items-center gap-1 md:gap-6">
- <Link
- href="/docs"
- className="inline-flex items-center gap-1.5 px-3 py-1.5 text-sm text-ink-soft hover:text-ink transition-colors"
- aria-label="Docs"
- >
- <BookOpenIcon className="size-4" />
- <span className="hidden sm:inline">Docs</span>
+ <div className="h-14 shrink-0">
+ <header
+ className="fixed inset-x-0 top-0 z-50 backdrop-blur-xl backdrop-saturate-150"
+ style={{ backgroundColor: 'color-mix(in oklch, var(--color-cream) 58%, transparent)' }}
+ >
+ <div className="mx-auto flex h-14 max-w-7xl items-center justify-between px-4 sm:px-6 lg:px-10">
+ <Link href="/" className="flex items-baseline gap-1.5 group">
+ <span
+ className="font-display select-none leading-none inline-block italic transition-transform group-hover:rotate-12"
+ style={{
+ fontSize: 22,
+ color: 'var(--color-fd-primary)',
+ fontVariationSettings: "'opsz' 144, 'SOFT' 100, 'WONK' 1",
+ }}
+ aria-hidden="true"
+ >
+ *
+ </span>
+ <span
+ className="font-display text-2xl tracking-[-0.04em] italic text-ink"
+ style={{ fontVariationSettings: "'opsz' 144, 'SOFT' 100, 'WONK' 1" }}
+ >
+ rae
+ </span>
+ <span className="sr-only">reverse-api-engineer</span>
</Link>
- <Link
- href={pypiUrl}
- target="_blank"
- className="inline-flex items-center gap-1.5 px-3 py-1.5 text-sm text-ink-soft hover:text-ink transition-colors"
- aria-label="PyPI"
- >
- <PackageIcon className="size-4" />
- <span className="hidden sm:inline">PyPI</span>
- </Link>
- <Link
- href={githubUrl}
- target="_blank"
- className="inline-flex items-center gap-1.5 px-3 py-1.5 text-sm text-ink-soft hover:text-ink transition-colors"
- aria-label="GitHub"
- >
- <GithubIcon className="size-4" />
- <span className="hidden sm:inline">GitHub</span>
- </Link>
- <ThemeToggle />
- </nav>
- </div>
- </header>
+ <nav className="flex items-center gap-1 md:gap-6">
+ <Link
+ href="/docs"
+ className="inline-flex items-center gap-1.5 px-3 py-1.5 text-sm text-ink-soft hover:text-ink transition-colors"
+ aria-label="Docs"
+ >
+ <BookOpenIcon className="size-4" />
+ <span className="hidden sm:inline">Docs</span>
+ </Link>
+ <Link
+ href={pypiUrl}
+ target="_blank"
+ className="inline-flex items-center gap-1.5 px-3 py-1.5 text-sm text-ink-soft hover:text-ink transition-colors"
+ aria-label="PyPI"
+ >
+ <PackageIcon className="size-4" />
+ <span className="hidden sm:inline">PyPI</span>
+ </Link>
+ <Link
+ href={githubUrl}
+ target="_blank"
+ className="inline-flex items-center gap-1.5 px-3 py-1.5 text-sm text-ink-soft hover:text-ink transition-colors"
+ aria-label="GitHub"
+ >
+ <GithubIcon className="size-4" />
+ <span className="hidden sm:inline">GitHub</span>
+ </Link>
+ <ThemeToggle />
+ </nav>
+ </div>
+ </header>
+ </div>
);
}
diff --git a/website/tests/scroll_e2e.py b/website/tests/scroll_e2e.py
new file mode 100644
index 0000000..813e434
--- /dev/null
+++ b/website/tests/scroll_e2e.py
@@ -0,0 +1,62 @@
+"""Real-browser regression checks against a served production export.
+
+Run: uv run --extra manual python website/tests/scroll_e2e.py URL EXPORT_DIR
+Install browsers first: uv run --extra manual playwright install chromium firefox webkit
+"""
+import json
+import sys
+from pathlib import Path
+
+from playwright.sync_api import sync_playwright
+
+base_url, export_dir = sys.argv[1:]
+routes = ['/'] + sorted('/' + str(p.parent.relative_to(export_dir)) + '/' for p in Path(export_dir, 'docs').rglob('index.html'))
+results = []
+with sync_playwright() as playwright:
+ for engine in ['chromium', 'firefox', 'webkit']:
+ browser = getattr(playwright, engine).launch()
+ for width, height in [(1280, 800), (390, 844)]:
+ context = browser.new_context(viewport={'width': width, 'height': height})
+ page = context.new_page()
+ errors = []
+ page.on('pageerror', lambda error: errors.append(str(error)))
+ for route in routes:
+ print(engine, width, route, file=sys.stderr, flush=True)
+ response = page.goto(base_url + route, wait_until='domcontentloaded')
+ assert response.status == 200, (engine, route, response.status)
+ assert page.locator('h1').first.inner_text().strip(), route
+ header = page.locator('header').first
+ for delta in [3000, -1800, 8000, -9000]:
+ page.mouse.wheel(0, delta)
+ # Sample frames during the scroll, not just after it settles.
+ positions = page.evaluate('''async () => {
+ const samples = [];
+ for (let i = 0; i < 12; i++) {
+ await new Promise(requestAnimationFrame);
+ const r = document.querySelector('header').getBoundingClientRect();
+ samples.push({top:r.top, bottom:r.bottom, left:r.left, right:r.right, y:scrollY});
+ }
+ return samples;
+ }''')
+ assert all(abs(p['top']) < 1 and p['bottom'] > 40 and p['left'] >= -1 and p['right'] <= width + 1 for p in positions), (engine, route, positions)
+ # End of document and immediate reversal must not push the nav away.
+ for y in [100000, 0]:
+ page.evaluate('(y) => scrollTo(0, y)', y)
+ assert abs(header.bounding_box()['y']) < 1, (engine, route, y)
+ assert not errors, (engine, route, errors)
+ results.append({'engine': engine, 'width': width, 'route': route, 'status': 'pass'})
+ # Exercise real mobile navigation and theme switching after scroll.
+ page.goto(base_url + '/docs/', wait_until='domcontentloaded')
+ if width < 1024:
+ page.locator('summary').click()
+ page.get_by_role('link', name='Installation', exact=True).click()
+ page.wait_for_url('**/docs/installation/')
+ theme = page.get_by_role('button', name='Switch to', exact=False)
+ previous = page.locator('html').get_attribute('class')
+ theme.click()
+ page.wait_for_function('(previous) => document.documentElement.className !== previous', arg=previous)
+ page.screenshot(path=f'/tmp/rae-header-{engine}-{width}.png')
+ assert not errors, (engine, errors)
+ context.close()
+ browser.close()
+print(json.dumps({'passed': len(results), 'results': results}, indent=2))