Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions docs/src/components/Topbar.astro
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,41 @@ const ENTERPRISE = `${SITE_MAIN}/enterprise`;
.catch(() => { /* offline / rate-limited — leave the em-dash. */ });
})();

// On touch / no-hover devices the `:hover` rule that reveals .nav-dd-menu
// never fires, so the first tap on the trigger anchor navigates away
// before the user can pick v1 vs v0. Intercept that first tap to open
// the menu; the second tap (or selecting an item) navigates as normal.
(() => {
if (!window.matchMedia('(hover: none)').matches) return;
const dds = Array.from(document.querySelectorAll<HTMLElement>('.nav-dd'));
if (!dds.length) return;

const closeAll = (except?: HTMLElement) => {
for (const dd of dds) if (dd !== except) dd.classList.remove('open');
};

for (const dd of dds) {
const trigger = dd.querySelector<HTMLAnchorElement>('.nav-dd-trigger');
if (!trigger) continue;
trigger.addEventListener('click', (ev) => {
if (!dd.classList.contains('open')) {
ev.preventDefault();
closeAll(dd);
dd.classList.add('open');
}
});
}

document.addEventListener('click', (ev) => {
const target = ev.target as Node | null;
if (target && dds.some((dd) => dd.contains(target))) return;
closeAll();
});
document.addEventListener('keydown', (ev) => {
if (ev.key === 'Escape') closeAll();
});
})();

// Copy-to-clipboard for every .code-figure .copy button — one delegated
// listener per document. Emitted markup lives in scripts/remark-code-titles.mjs.
(() => {
Expand Down
6 changes: 4 additions & 2 deletions docs/src/styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ nav.top {
transition: transform .15s ease;
}
.nav-dd:hover .nav-dd-trigger svg,
.nav-dd:focus-within .nav-dd-trigger svg {
.nav-dd:focus-within .nav-dd-trigger svg,
.nav-dd.open .nav-dd-trigger svg {
color: var(--coral);
transform: rotate(180deg);
}
Expand All @@ -169,7 +170,8 @@ nav.top {
z-index: 60;
}
.nav-dd:hover .nav-dd-menu,
.nav-dd:focus-within .nav-dd-menu {
.nav-dd:focus-within .nav-dd-menu,
.nav-dd.open .nav-dd-menu {
opacity: 1;
visibility: visible;
transform: translateY(0);
Expand Down