This commit is contained in:
Thomas Chartron 2021-11-14 15:44:16 +01:00
parent ab4958734a
commit ba014486a0
3 changed files with 7 additions and 7 deletions

View file

@ -66,11 +66,11 @@ function toggleMobileMenu() {
let menu = document.querySelector('#mobile-menu div.nav-links');
if ([...menu.classList].includes('translate-y-0')) {
document.body.style.removeProperty("overflow")
menu.classList.remove('translate-y-0')
menu.classList.add('-translate-y-full')
menu.classList.remove('h-screen')
menu.classList.add('h-0', hidden)
} else {
document.body.style.setProperty("overflow", "hidden")
menu.classList.remove('-translate-y-full')
menu.classList.add('translate-y-0')
menu.classList.remove('h-0', 'hidden')
menu.classList.add('h-screen')
}
}

View file

@ -1 +1 @@
function switchTheme(){"dark"==([...document.documentElement.classList].includes("dark")?"dark":"light")?(localStorage.theme="light",document.documentElement.classList.remove("dark"),document.getElementById("light").classList.add("hidden"),document.getElementById("dark").classList.remove("hidden")):(localStorage.theme="dark",document.documentElement.classList.add("dark"),document.getElementById("dark").classList.add("hidden"),document.getElementById("light").classList.remove("hidden"))}function toggleSidebar(){let e=document.getElementById("sidebar");[...e.classList].includes("translate-x-0")?(document.body.style.removeProperty("overflow"),e.classList.remove("translate-x-0"),e.classList.add("-translate-x-full")):(document.body.style.setProperty("overflow","hidden"),e.classList.remove("-translate-x-full"),e.classList.add("translate-x-0"))}function toggleMobileMenu(){let e=document.querySelector("#mobile-menu div.nav-links");[...e.classList].includes("translate-y-0")?(document.body.style.removeProperty("overflow"),e.classList.remove("translate-y-0"),e.classList.add("-translate-y-full")):(document.body.style.setProperty("overflow","hidden"),e.classList.remove("-translate-y-full"),e.classList.add("translate-y-0"))}document.addEventListener("DOMContentLoaded",function(){var e=document.querySelectorAll(".nav-links a");let t=window.location.href,d=[...e].filter(e=>e.href===t);if(void 0!==d)if(Array.isArray(d))for(var l of d)l.className="bg-gray-900 text-white px-3 py-2 rounded-md text-sm font-medium";else d.className="bg-gray-900 text-white px-3 py-2 rounded-md text-sm font-medium";"dark"===localStorage.theme||!("theme"in localStorage)&&window.matchMedia("(prefers-color-scheme: dark)").matches?(document.documentElement.classList.add("dark"),document.getElementById("dark").classList.add("hidden")):(document.documentElement.classList.remove("dark"),document.getElementById("light").classList.add("hidden")),document.getElementById("switch-theme").addEventListener("click",switchTheme),document.getElementById("toggle-sidebar").addEventListener("click",toggleSidebar),document.getElementById("toggle-mobile-menu").addEventListener("click",toggleMobileMenu)});
function switchTheme(){"dark"==([...document.documentElement.classList].includes("dark")?"dark":"light")?(localStorage.theme="light",document.documentElement.classList.remove("dark"),document.getElementById("light").classList.add("hidden"),document.getElementById("dark").classList.remove("hidden")):(localStorage.theme="dark",document.documentElement.classList.add("dark"),document.getElementById("dark").classList.add("hidden"),document.getElementById("light").classList.remove("hidden"))}function toggleSidebar(){let e=document.getElementById("sidebar");[...e.classList].includes("translate-x-0")?(document.body.style.removeProperty("overflow"),e.classList.remove("translate-x-0"),e.classList.add("-translate-x-full")):(document.body.style.setProperty("overflow","hidden"),e.classList.remove("-translate-x-full"),e.classList.add("translate-x-0"))}function toggleMobileMenu(){let e=document.querySelector("#mobile-menu div.nav-links");[...e.classList].includes("translate-y-0")?(document.body.style.removeProperty("overflow"),e.classList.remove("h-screen"),e.classList.add("h-0",hidden)):(document.body.style.setProperty("overflow","hidden"),e.classList.remove("h-0","hidden"),e.classList.add("h-screen"))}document.addEventListener("DOMContentLoaded",function(){var e=document.querySelectorAll(".nav-links a");let t=window.location.href,d=[...e].filter(e=>e.href===t);if(void 0!==d)if(Array.isArray(d))for(var s of d)s.className="bg-gray-900 text-white px-3 py-2 rounded-md text-sm font-medium";else d.className="bg-gray-900 text-white px-3 py-2 rounded-md text-sm font-medium";"dark"===localStorage.theme||!("theme"in localStorage)&&window.matchMedia("(prefers-color-scheme: dark)").matches?(document.documentElement.classList.add("dark"),document.getElementById("dark").classList.add("hidden")):(document.documentElement.classList.remove("dark"),document.getElementById("light").classList.add("hidden")),document.getElementById("switch-theme").addEventListener("click",switchTheme),document.getElementById("toggle-sidebar").addEventListener("click",toggleSidebar),document.getElementById("toggle-mobile-menu").addEventListener("click",toggleMobileMenu)});

View file

@ -204,8 +204,8 @@
</div>
<!----------------------------- Mobile menu ----------------------------->
<div id="mobile-menu" class="sm:hidden">
<div class="nav-links flex flex-col space-y-4 items-center -translate-y-full transition-all duration-500 ease-in-out transform top-0 fixed z-10 w-screen dark:bg-gray-800">
<div id="mobile-menu" class="sm:hidden relative">
<div class="nav-links flex flex-col space-y-4 items-center transition-all duration-500 ease-in-out transform absolute top-0 z-10 w-screen dark:bg-gray-800 h-0 hidden">
<!-- Current: "bg-gray-900 text-white", Default: "text-gray-300 hover:bg-gray-700 hover:text-white" -->
{% for item in config.extra.navbar.items %}
{% if lang == item.lang %}