Make mobile menu full height and fix transition

This commit is contained in:
prototypa
2022-08-28 18:07:47 -04:00
parent e1c271441b
commit f496dd0ccd
2 changed files with 15 additions and 16 deletions

View File

@ -17,13 +17,7 @@ const { } = Astro.props;
const matches = document.querySelectorAll(selector); const matches = document.querySelectorAll(selector);
if (matches && matches.length) { if (matches && matches.length) {
matches.forEach((elem) => { matches.forEach((elem) => {
elem.addEventListener( elem.addEventListener(event, () => fn(elem), false);
event,
function () {
fn(elem);
},
false
);
}); });
} }
} }
@ -31,6 +25,7 @@ const { } = Astro.props;
window.onload = function () { window.onload = function () {
attachEvent("[data-aw-toggle-menu]", "click", function (elem) { attachEvent("[data-aw-toggle-menu]", "click", function (elem) {
elem.classList.toggle("expanded"); elem.classList.toggle("expanded");
document.documentElement.classList.toggle("overflow-hidden");
document.getElementById("menu")?.classList.toggle("hidden"); document.getElementById("menu")?.classList.toggle("hidden");
}); });

View File

@ -6,7 +6,7 @@ const { } = Astro.props;
--- ---
<header <header
class="sticky top-0 z-40 flex-none mx-auto w-full bg-white/90 dark:bg-slate-900/90 backdrop-blur-sm border-b dark:border-b-0"> class="sticky top-0 z-40 flex-none mx-auto w-full bg-white md:bg-white/90 dark:bg-slate-900 dark:md:bg-slate-900/90 md:backdrop-blur-sm border-b dark:border-b-0">
<div class="py-3 px-3 mx-auto w-full md:flex md:justify-between max-w-6xl md:px-4"> <div class="py-3 px-3 mx-auto w-full md:flex md:justify-between max-w-6xl md:px-4">
<div class="flex justify-between"> <div class="flex justify-between">
<a class="flex items-center" href="/"> <a class="flex items-center" href="/">
@ -21,11 +21,11 @@ const { } = Astro.props;
<button <button
class="ml-1.5 text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800 focus:outline-none focus:ring-4 focus:ring-gray-200 dark:focus:ring-gray-700 rounded-lg text-sm p-2.5 inline-flex items-center transition" class="ml-1.5 text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800 focus:outline-none focus:ring-4 focus:ring-gray-200 dark:focus:ring-gray-700 rounded-lg text-sm p-2.5 inline-flex items-center transition"
aria-label="Toggle Menu" data-aw-toggle-menu> aria-label="Toggle Menu" data-aw-toggle-menu>
<Icon name="tabler:menu" class="w-6 h-6" /> <Icon name="tabler:menu" class="w-6 h-6" optimize={false} />
</button> </button>
</div> </div>
</div> </div>
<nav class="items-center w-full md:w-auto hidden md:flex text-gray-600 dark:text-slate-200" <nav class="items-center w-full md:w-auto hidden md:flex text-gray-600 dark:text-slate-200 h-screen md:h-auto"
aria-label="Main navigation" id="menu"> aria-label="Main navigation" id="menu">
<ul <ul
class="flex flex-col pt-8 md:pt-0 md:flex-row md:self-center collapse w-full md:w-auto collapsed text-xl md:text-base"> class="flex flex-col pt-8 md:pt-0 md:flex-row md:self-center collapse w-full md:w-auto collapsed text-xl md:text-base">
@ -74,11 +74,15 @@ const { } = Astro.props;
</header> </header>
<style is:global> <style is:global>
[data-aw-toggle-menu].expanded .line1 { [data-aw-toggle-menu] path {
transform: rotate(-45deg) translate(-12px, 8px); @apply transition;
}
[data-aw-toggle-menu].expanded g > path:first-child {
@apply -rotate-45 translate-y-[14px] translate-x-[-3px];
/* transform: rotate(-45deg) translate(-12px, 8px); */
} }
[data-aw-toggle-menu].expanded .line2 { [data-aw-toggle-menu].expanded g > path:last-child {
transform: rotate(45deg) translate(4px, -16px); @apply rotate-45 translate-y-[-9px] translate-x-[14px];
} }
</style> </style>