Files
deploy 785b3c5b43
Déploiement Hugo Staging / deploy-staging (push) Waiting to run
Site vitrine 2.0 — modernisation UI (nav, home, typo, shortcodes).
Intègre feature/modernisation-vitrine en squash. Workflows : staging sur
site/v3 uniquement ; production en workflow_dispatch (jamais sur push).
2026-10-08 12:24:52 +02:00

48 lines
1.4 KiB
JavaScript

(function () {
var nav = document.getElementById("site-nav");
if (!nav) return;
var toggle = nav.querySelector(".nav-toggle");
var mq = window.matchMedia("(max-width: 51.99rem)");
function setOpen(open) {
nav.classList.toggle("is-open", open);
if (toggle) {
toggle.setAttribute("aria-expanded", open ? "true" : "false");
toggle.setAttribute("aria-label", open ? "Fermer le menu" : "Ouvrir le menu");
}
}
if (toggle) {
toggle.addEventListener("click", function () {
var next = !nav.classList.contains("is-open");
setOpen(next);
if (next) {
var first = nav.querySelector(".site-nav__list a");
if (first) {
window.requestAnimationFrame(function () {
first.focus();
});
}
}
});
}
document.addEventListener("keydown", function (e) {
if (e.key === "Escape" && nav.classList.contains("is-open")) {
setOpen(false);
if (toggle) toggle.focus();
}
});
nav.querySelectorAll(".site-nav__list a").forEach(function (a) {
a.addEventListener("click", function () {
if (mq.matches) setOpen(false);
});
});
mq.addEventListener("change", function (e) {
if (!e.matches) setOpen(false);
});
})();