diff --git a/assets/css/compiled/main.css b/assets/css/compiled/main.css index d82a51b5..5ebb8957 100644 --- a/assets/css/compiled/main.css +++ b/assets/css/compiled/main.css @@ -3182,21 +3182,6 @@ body button { display:none } -/* Hamburger menu */ - -body:has(#menu-controller:checked) { - overflow-y:hidden -} - -#menu-button:has(#menu-controller:checked) { - visibility:hidden -} - -#menu-controller:checked~#menu-wrapper { - visibility:visible; - opacity:1 -} - /* RTL support */ .prose blockquote:where([dir="rtl"], [dir="rtl"] *) { diff --git a/assets/css/main.css b/assets/css/main.css index 6db69609..0dd36a13 100644 --- a/assets/css/main.css +++ b/assets/css/main.css @@ -29,19 +29,6 @@ body button { @apply hidden; } -/* Hamburger menu */ -body:has(#menu-controller:checked) { - @apply overflow-y-hidden; -} - -#menu-button:has(#menu-controller:checked) { - @apply invisible; -} - -#menu-controller:checked~#menu-wrapper { - @apply visible opacity-100; -} - /* RTL support */ .prose blockquote { @apply rtl:pr-4 rtl:border-l-0 rtl:border-r-4; diff --git a/assets/js/mobilemenu.js b/assets/js/mobilemenu.js new file mode 100644 index 00000000..b5d0dd04 --- /dev/null +++ b/assets/js/mobilemenu.js @@ -0,0 +1,27 @@ +var menuButton = document.getElementById("menu-button"); +var menuCloseButton = document.getElementById("menu-close-button"); + +var menuOpen = false; + +menuButton.addEventListener("click", function () { + if (!menuOpen) { + menuOpen = true; + var menuWrapper = document.getElementById("menu-wrapper"); + document.body.style.overflowY = "hidden"; + menuButton.style.visibility = "hidden"; + menuWrapper.style.visibility = "visible"; + menuWrapper.style.opacity = "1"; + } +}); + +menuCloseButton.addEventListener("click", function (e) { + if (menuOpen) { + menuOpen = false; + var menuWrapper = document.getElementById("menu-wrapper"); + document.body.style.overflowY = "auto"; + menuButton.style.visibility = "visible"; + menuWrapper.style.visibility = "hidden"; + menuWrapper.style.opacity = "0"; + e.stopPropagation(); + } +}); \ No newline at end of file diff --git a/layouts/partials/head.html b/layouts/partials/head.html index a1c4b300..87255a22 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -66,6 +66,8 @@ {{ $jsRTL := resources.Get "js/rtl.js" }} {{ $assets.Add "js" (slice $jsRTL) }} {{ end }} + {{ $jsMobileMenu := resources.Get "js/mobilemenu.js" }} + {{ $assets.Add "js" (slice $jsMobileMenu) }} {{ if $assets.Get "js" }} {{ $bundleJS := $assets.Get "js" | resources.Concat "js/main.bundle.js" | resources.Minify | resources.Fingerprint "sha512" }} diff --git a/layouts/partials/header/basic.html b/layouts/partials/header/basic.html index caf69fa7..c1eb4641 100644 --- a/layouts/partials/header/basic.html +++ b/layouts/partials/header/basic.html @@ -93,8 +93,7 @@