Skip to content

Commit 2c63574

Browse files
groksrcclaude
andcommitted
Fix mobile header layout with proper menu
- Keep logo on the left at full size - Add search icon and vertical three-dots menu on the right - Move GitHub and Get Started links into dropdown menu - Add JavaScript for dropdown menu interaction - Hide desktop navigation elements on mobile - Maintain responsive padding 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent c3591b1 commit 2c63574

File tree

1 file changed

+89
-6
lines changed

1 file changed

+89
-6
lines changed

src/components/Header.astro

Lines changed: 89 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import { navConfig } from '@/config/navigation'
66

77
<header class="sticky top-0 z-50 w-full border-b border-gray-100 bg-background">
88
<div class="flex justify-center">
9-
<div class="flex h-14 w-full max-w-screen-2xl items-center">
10-
<!-- Logo aligned with left sidebar (w-72) -->
11-
<div class="w-72 flex items-center px-8">
9+
<div class="flex h-14 w-full max-w-screen-2xl items-center px-4 md:px-0">
10+
<!-- Logo -->
11+
<div class="flex-shrink-0 md:w-72 flex items-center md:px-8">
1212
<a href="/" class="flex items-center space-x-2">
1313
<img
1414
src="/logo-light.png"
@@ -23,8 +23,8 @@ import { navConfig } from '@/config/navigation'
2323
</a>
2424
</div>
2525

26-
<!-- Centered search and right navigation -->
27-
<div class="flex flex-1 items-center justify-between px-6">
26+
<!-- Desktop navigation -->
27+
<div class="hidden md:flex flex-1 items-center justify-between px-6">
2828
<div class="flex-1 max-w-md mx-auto">
2929
<button class="inline-flex items-center whitespace-nowrap rounded-md font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 border border-input bg-transparent shadow-sm hover:bg-accent hover:text-accent-foreground h-9 px-4 py-2 relative w-full justify-start text-sm text-muted-foreground">
3030
<svg class="mr-2 h-4 w-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
@@ -63,6 +63,89 @@ import { navConfig } from '@/config/navigation'
6363
<ThemeToggle client:load />
6464
</nav>
6565
</div>
66+
67+
<!-- Mobile right side buttons -->
68+
<div class="flex md:hidden items-center ml-auto space-x-4">
69+
<!-- Search icon -->
70+
<button class="p-2 text-muted-foreground hover:text-foreground transition-colors">
71+
<svg class="h-5 w-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
72+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m21 21-6-6m2-5a7 7 0 1 1-14 0 7 7 0 0 1 14 0z"></path>
73+
</svg>
74+
</button>
75+
76+
<!-- Three dots menu -->
77+
<div class="relative">
78+
<button
79+
id="mobile-menu-trigger"
80+
class="p-2 text-muted-foreground hover:text-foreground transition-colors"
81+
>
82+
<svg class="h-5 w-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
83+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 5v.01M12 12v.01M12 19v.01M12 6a1 1 0 110-2 1 1 0 010 2zm0 7a1 1 0 110-2 1 1 0 010 2zm0 7a1 1 0 110-2 1 1 0 010 2z"></path>
84+
</svg>
85+
</button>
86+
87+
<!-- Dropdown menu -->
88+
<div
89+
id="mobile-menu-dropdown"
90+
class="absolute right-0 mt-2 w-48 bg-background border border-border rounded-md shadow-lg opacity-0 invisible transition-all duration-200"
91+
>
92+
<div class="py-1">
93+
{navConfig.topNav.map((item) => (
94+
<a
95+
href={item.href}
96+
class="block px-4 py-2 text-sm text-muted-foreground hover:text-foreground hover:bg-accent transition-colors"
97+
target={item.external ? "_blank" : undefined}
98+
rel={item.external ? "noopener noreferrer" : undefined}
99+
style="text-decoration: none"
100+
>
101+
{item.title}
102+
</a>
103+
))}
104+
105+
<a
106+
href="/getting-started"
107+
class="block px-4 py-2 text-sm text-muted-foreground hover:text-foreground hover:bg-accent transition-colors"
108+
style="text-decoration: none"
109+
>
110+
Get Started
111+
</a>
112+
</div>
113+
</div>
114+
</div>
115+
</div>
66116
</div>
67117
</div>
68-
</header>
118+
</header>
119+
120+
<script>
121+
document.addEventListener('DOMContentLoaded', () => {
122+
const trigger = document.getElementById('mobile-menu-trigger');
123+
const dropdown = document.getElementById('mobile-menu-dropdown');
124+
125+
if (trigger && dropdown) {
126+
trigger.addEventListener('click', (e) => {
127+
e.stopPropagation();
128+
const isOpen = dropdown.classList.contains('opacity-100');
129+
130+
if (isOpen) {
131+
dropdown.classList.remove('opacity-100', 'visible');
132+
dropdown.classList.add('opacity-0', 'invisible');
133+
} else {
134+
dropdown.classList.remove('opacity-0', 'invisible');
135+
dropdown.classList.add('opacity-100', 'visible');
136+
}
137+
});
138+
139+
// Close dropdown when clicking outside
140+
document.addEventListener('click', () => {
141+
dropdown.classList.remove('opacity-100', 'visible');
142+
dropdown.classList.add('opacity-0', 'invisible');
143+
});
144+
145+
// Prevent dropdown from closing when clicking inside
146+
dropdown.addEventListener('click', (e) => {
147+
e.stopPropagation();
148+
});
149+
}
150+
});
151+
</script>

0 commit comments

Comments
 (0)