side-panel : refactor nav + toc into single side-panel with view switching
Rename nav.php to side-panel.php to host both navigation and table of contents views. The panel uses data-view attributes to switch between nav and toc content. Footer buttons updated to target the unified panel. TOC button now visible on desktop. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
798123a60a
commit
6c1a8c8850
16 changed files with 103 additions and 115 deletions
|
|
@ -69,11 +69,11 @@ function toggleLogoState() {
|
|||
}
|
||||
function toggleFooterState() {
|
||||
if (scrollY > 90) {
|
||||
document.querySelectorAll(".open-nav-wrapper").forEach(element => {
|
||||
document.querySelectorAll(".footer-btn-wrapper").forEach(element => {
|
||||
element.classList.remove("hidden");
|
||||
});
|
||||
} else {
|
||||
document.querySelectorAll(".open-nav-wrapper").forEach(element => {
|
||||
document.querySelectorAll(".footer-btn-wrapper").forEach(element => {
|
||||
element.classList.add("hidden");
|
||||
});
|
||||
}
|
||||
|
|
@ -138,9 +138,14 @@ function closeAllPanels() {
|
|||
document.body.classList.remove("no-scroll");
|
||||
}
|
||||
|
||||
function openPanel(name) {
|
||||
function openPanel(name, view) {
|
||||
const panel = document.querySelector(`.panel[data-panel="${name}"]`);
|
||||
if (panel) {
|
||||
if (view) {
|
||||
panel.querySelectorAll('[data-view]').forEach(v => v.classList.add('hidden'));
|
||||
const target = panel.querySelector(`[data-view="${view}"]`);
|
||||
if (target) target.classList.remove('hidden');
|
||||
}
|
||||
panel.classList.add("panel--visible");
|
||||
navOverlay.classList.add("nav-overlay--visible");
|
||||
document.body.classList.add("no-scroll");
|
||||
|
|
@ -179,7 +184,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
|||
});
|
||||
});
|
||||
|
||||
const navSortBtns = document.querySelectorAll("nav .sort-btn");
|
||||
const navSortBtns = document.querySelectorAll(".side-panel .sort-btn");
|
||||
const navSections = document.querySelectorAll(
|
||||
".panel__all-texts, .panel__collection"
|
||||
);
|
||||
|
|
@ -207,7 +212,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
|||
|
||||
document.querySelectorAll("[data-open-panel]").forEach((btn) => {
|
||||
btn.addEventListener("click", () => {
|
||||
openPanel(btn.dataset.openPanel);
|
||||
openPanel(btn.dataset.openPanel, btn.dataset.view);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -218,7 +223,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
|||
navOverlay.addEventListener("click", closeAllPanels);
|
||||
|
||||
// Fermer le panel TOC quand on clique sur un lien
|
||||
document.querySelectorAll(".panel-toc .toc a").forEach((link) => {
|
||||
document.querySelectorAll('[data-view="toc"] .toc a').forEach((link) => {
|
||||
link.addEventListener("click", closeAllPanels);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue