feat(ui): harmoniser navigation pages d’entrée et recherche
This commit is contained in:
@@ -28,6 +28,7 @@ const tocId = `toc-global-${collection}-${String(basePath).replace(/[^\w-]+/g, "
|
||||
|
||||
<nav
|
||||
class="toc-global"
|
||||
data-mobile-default="closed"
|
||||
aria-label={label}
|
||||
data-toc-global
|
||||
data-toc-key={`global:${collection}:${basePath}`}
|
||||
@@ -35,14 +36,14 @@ const tocId = `toc-global-${collection}-${String(basePath).replace(/[^\w-]+/g, "
|
||||
<button
|
||||
class="toc-global__head toc-global__toggle"
|
||||
type="button"
|
||||
aria-expanded="true"
|
||||
aria-expanded="false"
|
||||
aria-controls={tocId}
|
||||
>
|
||||
<span class="toc-global__title">{label}</span>
|
||||
<span class="toc-global__chevron" aria-hidden="true">▾</span>
|
||||
</button>
|
||||
|
||||
<div class="toc-global__body-clip" id={tocId}>
|
||||
<div class="toc-global__body-clip" id={tocId} hidden>
|
||||
<div class="toc-global__body">
|
||||
<ol class="toc-global__list">
|
||||
{entries.map((e) => {
|
||||
@@ -291,6 +292,10 @@ const tocId = `toc-global-${collection}-${String(basePath).replace(/[^\w-]+/g, "
|
||||
max-height: min(42vh, 360px);
|
||||
padding-right: 4px;
|
||||
}
|
||||
|
||||
.toc-global__body-clip[hidden]{
|
||||
display: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark){
|
||||
@@ -332,9 +337,16 @@ const tocId = `toc-global-${collection}-${String(basePath).replace(/[^\w-]+/g, "
|
||||
|
||||
const setOpen = (open, { persist = true } = {}) => {
|
||||
const isMobile = mq.matches;
|
||||
nav.classList.toggle("is-collapsed", isMobile && !open);
|
||||
toggle.setAttribute("aria-expanded", open ? "true" : "false");
|
||||
if (persist && isMobile) write(open);
|
||||
const effectiveOpen = isMobile ? open : true;
|
||||
|
||||
nav.classList.toggle("is-collapsed", isMobile && !effectiveOpen);
|
||||
toggle.setAttribute("aria-expanded", effectiveOpen ? "true" : "false");
|
||||
|
||||
if (bodyClip) {
|
||||
bodyClip.hidden = isMobile && !effectiveOpen;
|
||||
}
|
||||
|
||||
if (persist && isMobile) write(effectiveOpen);
|
||||
};
|
||||
|
||||
const initState = () => {
|
||||
|
||||
Reference in New Issue
Block a user