Skip to content

Commit 52fbedc

Browse files
committed
Mobile menu
1 parent 8237856 commit 52fbedc

File tree

1 file changed

+57
-2
lines changed

1 file changed

+57
-2
lines changed

homedocs/src/pages/index.astro

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,28 @@ import { ClientRouter } from 'astro:transitions';
113113
<!-- Header -->
114114
<header class="border-b border-border bg-background/80 backdrop-blur-sm sticky top-0 z-50">
115115
<div class="container mx-auto flex h-16 items-center px-4">
116+
<!-- Mobile menu button -->
117+
<button
118+
id="home-mobile-menu-btn"
119+
type="button"
120+
class="sm:hidden mr-2 p-2 rounded-md text-muted-foreground hover:text-foreground hover:bg-secondary transition-colors"
121+
aria-label="Toggle menu"
122+
>
123+
<svg class="menu-icon h-5 w-5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
124+
<path stroke-linecap="round" stroke-linejoin="round" d="M3.75 6.75h16.5M3.75 12h16.5m-16.5 5.25h16.5" />
125+
</svg>
126+
<svg class="close-icon h-5 w-5 hidden" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
127+
<path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12" />
128+
</svg>
129+
</button>
130+
116131
<a href="/" class="flex items-center gap-2 group">
117132
<img src="/favicon.svg" alt="CxJS" class="h-9 w-9 transition-transform group-hover:scale-110" />
118133
<span class="text-xl font-semibold text-foreground">CxJS</span>
119134
</a>
120-
<nav class="flex-1 flex items-center justify-center gap-6">
135+
136+
<!-- Desktop nav -->
137+
<nav class="hidden sm:flex flex-1 items-center justify-center gap-6">
121138
<a href="/docs/intro/what-is-cxjs" class="text-sm text-muted-foreground hover:text-foreground transition-colors">
122139
Docs
123140
</a>
@@ -128,7 +145,8 @@ import { ClientRouter } from 'astro:transitions';
128145
Changelog
129146
</a>
130147
</nav>
131-
<div class="flex items-center gap-4">
148+
149+
<div class="flex items-center gap-4 ml-auto">
132150
<a
133151
href="https://github.com/codaxy/cxjs"
134152
target="_blank"
@@ -161,6 +179,21 @@ import { ClientRouter } from 'astro:transitions';
161179
</button>
162180
</div>
163181
</div>
182+
183+
<!-- Mobile menu dropdown -->
184+
<nav id="home-mobile-menu" class="hidden sm:hidden border-t border-border bg-background">
185+
<div class="container mx-auto px-4 py-4 flex flex-col gap-3">
186+
<a href="/docs/intro/what-is-cxjs" class="text-sm text-muted-foreground hover:text-foreground transition-colors py-2">
187+
Docs
188+
</a>
189+
<a href="https://gallery.cxjs.io/" class="text-sm text-muted-foreground hover:text-foreground transition-colors py-2">
190+
Gallery
191+
</a>
192+
<a href="/docs/intro/changelog" class="text-sm text-muted-foreground hover:text-foreground transition-colors py-2">
193+
Changelog
194+
</a>
195+
</div>
196+
</nav>
164197
</header>
165198

166199
<!-- Hero -->
@@ -414,6 +447,28 @@ import { ClientRouter } from 'astro:transitions';
414447

415448
<script is:inline>
416449
function initHomePage() {
450+
// Mobile menu toggle
451+
const mobileMenuBtn = document.getElementById('home-mobile-menu-btn');
452+
const mobileMenu = document.getElementById('home-mobile-menu');
453+
const menuIcon = mobileMenuBtn?.querySelector('.menu-icon');
454+
const closeIcon = mobileMenuBtn?.querySelector('.close-icon');
455+
456+
if (mobileMenuBtn && mobileMenu) {
457+
mobileMenuBtn.onclick = () => {
458+
const isOpen = !mobileMenu.classList.contains('hidden');
459+
if (isOpen) {
460+
mobileMenu.classList.add('hidden');
461+
menuIcon?.classList.remove('hidden');
462+
closeIcon?.classList.add('hidden');
463+
} else {
464+
mobileMenu.classList.remove('hidden');
465+
menuIcon?.classList.add('hidden');
466+
closeIcon?.classList.remove('hidden');
467+
}
468+
};
469+
}
470+
471+
// Theme toggle
417472
const toggle = document.getElementById('theme-toggle');
418473
if (!toggle) {
419474
return;

0 commit comments

Comments
 (0)