From 523cfc9df7cbaae17e4c0197a490a5f813dc5a45 Mon Sep 17 00:00:00 2001 From: Duarte Santos Date: Mon, 31 Aug 2026 14:32:32 +0200 Subject: [PATCH] website: one header on every page, one contents drawer that starts closed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The docs page used to swap the site's links for its own three and unfold the chapter rail on arrival, so half the navigation vanished the moment you opened the documentation and a sidebar you never asked for was already there. Both are gone. Every page — home, about, docs, API — now serves a byte-identical nav bar and navigation sheet; which page you are on is marked with aria-current at runtime, so nothing is ever added or dropped from the markup to say it. The rail is now separate from the header and the same object everywhere: closed in CSS at every width, opened by one Contents pill, closed by the ✕ in its own sticky header, by Escape, or by a tap on the dimmed page. No preference is remembered any more and the stale og_rail key is cleared on sight. One panel controller in site.js drives both the sheet and the drawer, traps focus while either is open and hands it back to the button that opened it. api.html no longer carries a private copy of any of this. Also: visibility is switched at one instant instead of being transitioned — interpolating it left both panels hidden through their own opening animation, so they popped in at the end and nothing inside could take focus until then. Long inline code breaks instead of widening the page (docs ran 21px wide of a 320px screen), the header folds at one breakpoint rather than three, and every control in the rail clears 44px. 246 headless assertions across four pages and five widths: nav and sheet markup identical, drawer shut on first paint, no horizontal overflow, focus returned, reduced motion honoured, no console errors. --- scripts/build-api-docs.mjs | 140 ++---- website/about.html | 58 ++- website/api.html | 140 ++---- website/docs.html | 856 +++++++++++++++++++++++++++++++++---- website/index.html | 67 ++- website/site.js | 170 ++++++-- website/styles.css | 253 ++++++++--- 7 files changed, 1275 insertions(+), 409 deletions(-) diff --git a/scripts/build-api-docs.mjs b/scripts/build-api-docs.mjs index 3f3e9bf..fefd3e8 100644 --- a/scripts/build-api-docs.mjs +++ b/scripts/build-api-docs.mjs @@ -420,89 +420,14 @@ main.api-main .lead { color: var(--fg-2); max-width: 58ch; margin: 14px 0 0; fon .sch > summary { grid-template-columns: minmax(0, 1fr) auto; } .sch .ep-sum { grid-column: 1 / -1; } -/* --------------------------------------------------- contents drawer (rail) - The chapter rail is closed by default. Below 980px it is the hamburger sheet - the whole site uses; from 980px up a quiet "Contents" pill opens it as a - drawer over the left edge, with a close button inside. The .toc-btn / - .rail-close / body.contents-open classes are the reusable pattern. */ -.toc-btn { display: none; } -@media (min-width: 980px) { - .toc-btn { - position: fixed; left: 18px; bottom: max(20px, env(safe-area-inset-bottom)); z-index: 62; - display: inline-flex; align-items: center; gap: 8px; - padding: 10px 17px 10px 15px; border-radius: 999px; cursor: pointer; - background: rgba(23, 24, 27, .85); - backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); - border: 1px solid var(--hair); color: var(--fg-2); - font-size: 13.5px; font-weight: 500; letter-spacing: -.01em; - transition: color .2s var(--ease), border-color .2s var(--ease), background-color .2s var(--ease); - } - .toc-btn:hover { color: var(--fg); border-color: rgba(255, 255, 255, .25); background: rgba(32, 33, 37, .92); } - .toc-btn svg { width: 15px; height: 15px; } - - body.topnav .side { - display: block; position: fixed; left: 0; right: auto; top: 0; bottom: 0; z-index: 80; - width: min(320px, 86vw); max-height: none; - padding: 58px 24px calc(34px + env(safe-area-inset-bottom)) calc(26px + env(safe-area-inset-left)); - background: #0a0b0c; border-right: 1px solid var(--hair-soft); border-bottom: 0; - overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; - box-shadow: 40px 0 80px rgba(0, 0, 0, .5); - transform: translateX(-102%); visibility: hidden; opacity: 1; pointer-events: auto; - transition: transform .32s var(--ease), visibility .32s; - } - body.topnav.contents-open .side { transform: none; visibility: visible; } - body.contents-open::after { - content: ""; position: fixed; inset: 0; z-index: 75; - background: rgba(0, 0, 0, .55); - backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); - opacity: 1; pointer-events: auto; - } - .rail-close { - position: absolute; top: 14px; right: 12px; width: 34px; height: 34px; - display: flex; align-items: center; justify-content: center; - border-radius: 9px; color: var(--fg-3); cursor: pointer; - transition: color .2s var(--ease), background-color .2s var(--ease); - } - .rail-close:hover { color: var(--fg); background: rgba(255, 255, 255, .06); } - .rail-close svg { width: 15px; height: 15px; } -} -@media (max-width: 979.98px) { .rail-close { display: none; } } -/* Self-sufficiency: with the rail closed the page never reserves rail space. */ -@media (min-width: 1300px) { body.topnav { padding-left: 0; } } -@media (prefers-reduced-motion: reduce) { body.topnav .side { transition-duration: .01ms; } } +/* The header, the navigation sheet and the contents drawer belong to the site, not + to this page: .navsheet, .toc-btn, .side and .rail-close live in styles.css and + site.js and behave identically here, on the docs page and on the home page. This + file deliberately adds nothing of its own to them — one implementation is the + only way the two rail pages can feel like the same rail. */ ` const js = ` -/* Contents drawer (>=980px; below that the hamburger sheet in site.js owns the rail). */ -;(() => { - const body = document.body - const btn = document.querySelector('.toc-btn') - const menu = document.getElementById('menu') - if (!btn || !menu) return - const set = open => { - body.classList.toggle('contents-open', open) - btn.setAttribute('aria-expanded', String(open)) - body.style.overflow = open ? 'hidden' : '' - } - btn.addEventListener('click', e => { e.stopPropagation(); set(!body.classList.contains('contents-open')) }) - menu.querySelector('.rail-close')?.addEventListener('click', () => set(false)) - document.addEventListener('click', e => { - if (!body.classList.contains('contents-open')) return - if (e.target.closest('#menu') || e.target.closest('.toc-btn')) return - set(false) - }) - menu.addEventListener('click', e => { if (e.target.closest('a')) set(false) }) - document.addEventListener('keydown', e => { if (e.key === 'Escape') set(false) }) - addEventListener('resize', () => { - if (innerWidth < 980) set(false) - else { - // crossing up: make sure a hamburger-opened sheet doesn't linger - body.classList.remove('menu-open'); menu.classList.remove('open') - if (!body.classList.contains('contents-open')) body.style.overflow = '' - } - }) -})() - /* Jumping to an anchor inside a collapsed card opens the card — and re-aligns, since the browser scrolled to where the target was while it was still collapsed. */ ;(() => { @@ -555,7 +480,7 @@ const html = ` - + @@ -572,37 +497,58 @@ const html = ` Features Screenshots Demo - Docs - API - About + Docs + API + About GitLab Discord Download - - -