Skip to content

Commit 4a6d32e

Browse files
Fix the mobile menu's transparent backdrop
Same root cause as the .pub-navbar background fix: public-layout.css applies var(--bg-primary) to the panel but the var falls through to transparent on the Astro pages, so the open menu let page text bleed into the links. Use the same cosmic-blue + backdrop-blur the navbar already does, plus a fade and slide entry, staggered item reveal, a hamburger that morphs to a close icon, and a reduced-motion fallback. Also lock body scroll while open, close on Esc and return focus to the burger, close on tap of any link inside the panel, and close on resize past the mobile breakpoint.
1 parent 6fca677 commit 4a6d32e

2 files changed

Lines changed: 96 additions & 2 deletions

File tree

marketing/public/agc-public.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,26 @@
9999
var burger = document.querySelector('[data-agc-burger]');
100100
var nav = document.querySelector('.pub-navbar__nav');
101101
if (burger && nav) {
102+
var setOpen = function (open) {
103+
nav.classList.toggle('pub-navbar__nav--open', open);
104+
burger.setAttribute('aria-expanded', String(open));
105+
document.body.style.overflow = open ? 'hidden' : '';
106+
};
102107
burger.addEventListener('click', function () {
103-
var isOpen = nav.classList.toggle('pub-navbar__nav--open');
104-
burger.setAttribute('aria-expanded', String(isOpen));
108+
setOpen(!nav.classList.contains('pub-navbar__nav--open'));
105109
});
110+
nav.addEventListener('click', function (e) {
111+
if (e.target instanceof Element && e.target.closest('a')) setOpen(false);
112+
});
113+
document.addEventListener('keydown', function (e) {
114+
if (e.key === 'Escape' && nav.classList.contains('pub-navbar__nav--open')) {
115+
setOpen(false);
116+
burger.focus();
117+
}
118+
});
119+
var mq = window.matchMedia('(min-width: 641px)');
120+
var onMq = function (e) { if (e.matches) setOpen(false); };
121+
if (mq.addEventListener) mq.addEventListener('change', onMq);
122+
else if (mq.addListener) mq.addListener(onMq);
106123
}
107124
})();

marketing/src/components/Navbar.astro

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,81 @@ const isActive = (path: string) => currentPath === path || currentPath === path.
8282
-webkit-backdrop-filter: blur(12px);
8383
border-bottom: 1px solid color-mix(in srgb, var(--gold-primary) 16%, transparent);
8484
}
85+
86+
/* Same root-cause as the navbar fix above: public-layout.css applies
87+
var(--bg-primary) to the mobile menu panel but the var falls through
88+
to transparent on the Astro pages, so the open menu lets page content
89+
bleed through and the links become illegible. Replace with an opaque
90+
cosmic-blue + backdrop blur, animate the entry/exit, stagger the
91+
items, and morph the burger into a close icon. */
92+
@media (max-width: 640px) {
93+
.pub-navbar .pub-navbar__nav {
94+
display: flex;
95+
visibility: hidden;
96+
opacity: 0;
97+
transform: translateY(-8px);
98+
pointer-events: none;
99+
transition:
100+
opacity 0.24s ease,
101+
transform 0.24s ease,
102+
visibility 0s linear 0.24s;
103+
padding: 2rem 1.5rem max(2rem, env(safe-area-inset-bottom));
104+
background: color-mix(in srgb, var(--bg-deep-space, #0C1133) 94%, transparent);
105+
backdrop-filter: blur(24px) saturate(140%);
106+
-webkit-backdrop-filter: blur(24px) saturate(140%);
107+
border-top: 1px solid color-mix(in srgb, var(--gold-primary, #E6BC5C) 16%, transparent);
108+
box-shadow: 0 16px 40px color-mix(in srgb, #000 45%, transparent);
109+
overflow-y: auto;
110+
}
111+
112+
.pub-navbar .pub-navbar__nav--open {
113+
visibility: visible;
114+
opacity: 1;
115+
transform: translateY(0);
116+
pointer-events: auto;
117+
transition:
118+
opacity 0.24s ease,
119+
transform 0.24s ease;
120+
}
121+
122+
.pub-navbar__nav > * {
123+
opacity: 0;
124+
transform: translateY(10px);
125+
transition: opacity 0.3s ease, transform 0.3s ease;
126+
}
127+
128+
.pub-navbar__nav--open > * {
129+
opacity: 1;
130+
transform: translateY(0);
131+
}
132+
133+
.pub-navbar__nav--open > *:nth-child(1) { transition-delay: 0.08s; }
134+
.pub-navbar__nav--open > *:nth-child(2) { transition-delay: 0.13s; }
135+
.pub-navbar__nav--open > *:nth-child(3) { transition-delay: 0.18s; }
136+
.pub-navbar__nav--open > *:nth-child(4) { transition-delay: 0.23s; }
137+
.pub-navbar__nav--open > *:nth-child(5) { transition-delay: 0.28s; }
138+
.pub-navbar__nav--open > *:nth-child(6) { transition-delay: 0.33s; }
139+
140+
.pub-navbar__burger-line {
141+
transform-origin: center;
142+
transition: transform 0.22s ease, opacity 0.18s ease;
143+
}
144+
.pub-navbar__burger[aria-expanded="true"] .pub-navbar__burger-line:nth-child(1) {
145+
transform: translateY(7px) rotate(45deg);
146+
}
147+
.pub-navbar__burger[aria-expanded="true"] .pub-navbar__burger-line:nth-child(2) {
148+
opacity: 0;
149+
}
150+
.pub-navbar__burger[aria-expanded="true"] .pub-navbar__burger-line:nth-child(3) {
151+
transform: translateY(-7px) rotate(-45deg);
152+
}
153+
}
154+
155+
@media (prefers-reduced-motion: reduce) {
156+
.pub-navbar .pub-navbar__nav,
157+
.pub-navbar__nav > *,
158+
.pub-navbar__burger-line {
159+
transition: none !important;
160+
}
161+
}
85162
</style>

0 commit comments

Comments
 (0)