Skip to content

Commit 569652e

Browse files
Make search bar more responsive
1 parent 997be0b commit 569652e

2 files changed

Lines changed: 23 additions & 5 deletions

File tree

src/components/Header.astro

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,20 @@ const localeLinks = SUPPORTED_LOCALES.map(locale => ({
105105
</nav>
106106
</div>
107107

108-
<!-- Search (Desktop) -->
109-
<div class="hidden lg:flex flex-1 max-w-sm mx-8">
108+
<!-- Search (Desktop, full bar) — only at xl+ where there's room; below xl the compact icon opens the overlay -->
109+
<div class="hidden xl:flex flex-1 max-w-sm mx-8">
110110
<Search currentLocale={currentLocale} />
111111
</div>
112112

113113
<!-- Auth Buttons & Theme Toggle -->
114114
<div class="hidden lg:flex items-center gap-3">
115+
<!-- Compact search trigger — shown only in the 1024–1280px band; opens the same overlay as mobile -->
116+
<button id="compact-search-btn" type="button" data-search-trigger aria-label="Search" class="flex xl:hidden items-center justify-center p-2 rounded-xl transition-colors">
117+
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
118+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"></path>
119+
</svg>
120+
</button>
121+
115122
<ThemeToggle />
116123

117124
<!-- Language Switcher -->
@@ -150,7 +157,7 @@ const localeLinks = SUPPORTED_LOCALES.map(locale => ({
150157

151158
<!-- Mobile Search, Theme & Menu Buttons -->
152159
<div class="lg:hidden flex items-center gap-1">
153-
<button id="mobile-search-btn" class="p-2 text-[#443f49] dark:text-slate-300">
160+
<button id="mobile-search-btn" data-search-trigger class="p-2 text-[#443f49] dark:text-slate-300">
154161
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
155162
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"></path>
156163
</svg>
@@ -371,6 +378,17 @@ const localeLinks = SUPPORTED_LOCALES.map(locale => ({
371378
font-size: 0.8125rem;
372379
min-width: 2.5rem;
373380
}
381+
382+
/* Compact search icon (1024–1280px band) — matches the desktop nav color scheme */
383+
#compact-search-btn {
384+
color: var(--text-secondary);
385+
cursor: pointer;
386+
}
387+
388+
#compact-search-btn:hover {
389+
color: var(--text-primary);
390+
background: var(--bg-hover);
391+
}
374392
</style>
375393

376394
<script>

src/layouts/DocsLayout.astro

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ if (canonicalURL.pathname.length > 1 && canonicalURL.pathname.endsWith('/')) {
428428
const target = e.target as HTMLElement;
429429

430430
// Open mobile search
431-
const searchBtn = target.closest('#mobile-search-btn');
431+
const searchBtn = target.closest('[data-search-trigger]');
432432
if (searchBtn) {
433433
e.preventDefault();
434434
const overlay = document.getElementById('mobile-search-overlay');
@@ -1516,7 +1516,7 @@ if (canonicalURL.pathname.length > 1 && canonicalURL.pathname.endsWith('/')) {
15161516
color: var(--accent-primary) !important;
15171517
}
15181518

1519-
@media (min-width: 1024px) {
1519+
@media (min-width: 1280px) {
15201520
.mobile-search-overlay {
15211521
display: none;
15221522
}

0 commit comments

Comments
 (0)