diff --git a/static/js/nav.js b/static/js/nav.js index 29e2622..59bc0d7 100644 --- a/static/js/nav.js +++ b/static/js/nav.js @@ -34,6 +34,26 @@ if (window.innerWidth > 900) closeDrawer(); }); + /* Bascule Dark/Light (#52) : le choix est mémorisé et + l'amorce de _header.html l'a déjà appliqué avant le rendu. + Ici, on ne fait que synchroniser le libellé et le clic. */ + var themeBtn = document.getElementById('theme-toggle'); + function syncThemeBtn(theme) { + if (!themeBtn) return; + var light = theme === 'light'; + themeBtn.textContent = light ? '🌙 Mode sombre' : '☀️ Mode clair'; + themeBtn.setAttribute('aria-pressed', light ? 'true' : 'false'); + } + if (themeBtn) { + syncThemeBtn(document.documentElement.getAttribute('data-theme') || 'dark'); + themeBtn.addEventListener('click', function () { + var next = document.documentElement.getAttribute('data-theme') === 'light' ? 'dark' : 'light'; + document.documentElement.setAttribute('data-theme', next); + try { localStorage.setItem('kanbante-theme', next); } catch (e) { /* non-fatal */ } + syncThemeBtn(next); + }); + } + if (collapseBtn) { collapseBtn.addEventListener('click', function () { var collapsed = document.body.classList.toggle('sidebar-collapsed');