feat(glossary): add step 21 smart navigation
All checks were successful
SMOKE / smoke (push) Successful in 13s
CI / build-and-anchors (push) Successful in 1m4s
CI / build-and-anchors (pull_request) Successful in 35s

This commit is contained in:
2026-04-26 13:03:45 +02:00
parent 689619d14d
commit 9f88112aca
45 changed files with 1020 additions and 112 deletions

View File

@@ -100,7 +100,15 @@ const WHOAMI_FORCE_LOCALHOST = (import.meta.env.PUBLIC_WHOAMI_FORCE_LOCALHOST ??
var __WHOAMI_PATH__ = String(WHOAMI_PATH || "/_auth/whoami");
var __WHOAMI_IN_DEV__ = Boolean(WHOAMI_IN_DEV);
var __WHOAMI_FORCE_LOCALHOST__ = Boolean(WHOAMI_FORCE_LOCALHOST);
var SHOULD_FETCH_WHOAMI = (!__DEV__) || __WHOAMI_IN_DEV__;
var IS_LOCAL_HOST =
location.hostname === "localhost" ||
location.hostname === "127.0.0.1" ||
location.hostname === "::1";
var SHOULD_FETCH_WHOAMI =
((!__DEV__) && !IS_LOCAL_HOST) ||
__WHOAMI_IN_DEV__ ||
__WHOAMI_FORCE_LOCALHOST__;
window.__archiFlags = Object.assign({}, window.__archiFlags, {
dev: __DEV__,
@@ -950,6 +958,23 @@ const WHOAMI_FORCE_LOCALHOST = (import.meta.env.PUBLIC_WHOAMI_FORCE_LOCALHOST ??
}
}
@media (min-width: 761px) and (max-width: 980px){
:global(body[data-edition-key="glossaire"][data-sticky-mode="glossary-entry"]) .page,
:global(body[data-edition-key="glossaire"][data-sticky-mode="glossary-portal"]) .page{
padding-top: 0 !important;
}
:global(body[data-edition-key="glossaire"][data-sticky-mode="glossary-entry"]) .page-aside,
:global(body[data-edition-key="glossaire"][data-sticky-mode="glossary-portal"]) .page-aside{
margin-top: 0 !important;
}
:global(body[data-edition-key="glossaire"][data-sticky-mode="glossary-entry"]) .reading,
:global(body[data-edition-key="glossaire"][data-sticky-mode="glossary-portal"]) .reading{
padding-top: 0 !important;
}
}
@media (max-width: 430px){
.page{
padding: var(--page-gap) 10px 12px 16px;
@@ -1073,7 +1098,7 @@ const WHOAMI_FORCE_LOCALHOST = (import.meta.env.PUBLIC_WHOAMI_FORCE_LOCALHOST ??
}
}
@media (min-width: 981px){
@media (min-width: 981px) and (hover: hover) and (pointer: fine){
.mobile-para-menu{
display: none !important;
}
@@ -1173,14 +1198,23 @@ const WHOAMI_FORCE_LOCALHOST = (import.meta.env.PUBLIC_WHOAMI_FORCE_LOCALHOST ??
return 0;
}
function glossaryEntryHeroBottom() {
const head = document.querySelector(".glossary-entry-head");
if (!head) return headerH();
const bottom = head.getBoundingClientRect().bottom;
return Math.max(headerH(), Math.round(bottom));
}
function syncFollowTop() {
if (!followEl) return;
const localH =
(isGlossaryEntryMode || isGlossaryPortalMode)
? getLocalStickyHeight()
: 0;
if (isGlossaryEntryMode) {
followEl.style.top = px(glossaryEntryHeroBottom());
return;
}
const localH = isGlossaryPortalMode ? getLocalStickyHeight() : 0;
followEl.style.top = px(headerH() + stickyGap() + localH);
}
@@ -2715,6 +2749,12 @@ const WHOAMI_FORCE_LOCALHOST = (import.meta.env.PUBLIC_WHOAMI_FORCE_LOCALHOST ??
return;
}
if (isGlossaryEntryMode) {
reading.querySelectorAll("details.details-section").forEach((details) => {
details.open = true;
});
}
const h1 = reading.querySelector("h1");
const topChapterLabel =
@@ -2802,15 +2842,17 @@ const WHOAMI_FORCE_LOCALHOST = (import.meta.env.PUBLIC_WHOAMI_FORCE_LOCALHOST ??
let curH2 = null;
let curH3 = null;
let lastVisibleH2 = null;
let lastVisibleH3 = null;
let lastY = window.scrollY || 0;
let lastOpenedH2 = "";
function computeLineY(followH) {
const localH =
(isGlossaryEntryMode || isGlossaryPortalMode)
? getLocalStickyHeight()
: 0;
if (isGlossaryEntryMode) {
return glossaryEntryHeroBottom() + (followH || 0);
}
const localH = isGlossaryPortalMode ? getLocalStickyHeight() : 0;
return headerH() + stickyGap() + localH + (followH || 0) + HYST;
}
@@ -2839,13 +2881,17 @@ const WHOAMI_FORCE_LOCALHOST = (import.meta.env.PUBLIC_WHOAMI_FORCE_LOCALHOST ??
const box = getH2DisplayEl(t);
if (!box) continue;
if (box.getBoundingClientRect().top <= lineY + HYST) {
if (box.getBoundingClientRect().top <= lineY) {
cand = t;
} else {
break;
}
}
if (isGlossaryEntryMode) {
return cand;
}
return cand || H2[0] || null;
}
@@ -2897,6 +2943,7 @@ const WHOAMI_FORCE_LOCALHOST = (import.meta.env.PUBLIC_WHOAMI_FORCE_LOCALHOST ??
}
function maybeOpenActiveSection(activeH2, lineY) {
if (isGlossaryEntryMode) return;
if (!activeH2 || !activeH2.id) return;
const triggerEl = activeH2.triggerEl || activeH2.anchor || null;
@@ -2914,6 +2961,7 @@ const WHOAMI_FORCE_LOCALHOST = (import.meta.env.PUBLIC_WHOAMI_FORCE_LOCALHOST ??
}
function maybePreopenNextSection(activeH2) {
if (isGlossaryEntryMode) return;
if (!activeH2) return;
const i = H2.findIndex((t) => t.id === activeH2.id);
@@ -2954,15 +3002,19 @@ const WHOAMI_FORCE_LOCALHOST = (import.meta.env.PUBLIC_WHOAMI_FORCE_LOCALHOST ??
curH3 = nextH3;
if (rfH2) {
const show = Boolean(curH2 && hasCrossedBottom(getH2DisplayEl(curH2), lineY));
rfH2.hidden = !show;
if (show) rfH2.textContent = curH2.title;
rfH2.hidden = !curH2;
if (curH2) {
rfH2.textContent = curH2.title;
}
}
if (rfH3) {
const show = Boolean(curH3 && hasCrossedBottom(getH3DisplayEl(curH3), lineY));
rfH3.hidden = !show;
if (show) rfH3.textContent = curH3.title;
rfH3.hidden = !curH3;
if (curH3) {
rfH3.textContent = curH3.title;
}
}
const any =
@@ -3011,12 +3063,9 @@ const WHOAMI_FORCE_LOCALHOST = (import.meta.env.PUBLIC_WHOAMI_FORCE_LOCALHOST ??
? inner2.getBoundingClientRect().height
: 0;
const localH =
(isGlossaryEntryMode || isGlossaryPortalMode)
? getLocalStickyHeight()
: 0;
const occupiedTop = headerH() + stickyGap() + localH + followH;
const occupiedTop = isGlossaryEntryMode
? glossaryEntryHeroBottom() + followH
: headerH() + stickyGap() + (isGlossaryPortalMode ? getLocalStickyHeight() : 0) + followH;
setRootVar("--followbar-h", px(followH));
setRootVar("--sticky-offset-px", String(Math.round(occupiedTop)));