Skip to content

Commit c4a1157

Browse files
authored
Merge pull request #177 from phel-lang/adjust-search-results
Small search CSS improvements
2 parents 3e31939 + 65b9f7e commit c4a1157

File tree

2 files changed

+55
-3
lines changed

2 files changed

+55
-3
lines changed

css/components/search.css

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,9 @@
153153
align-items: center;
154154
gap: var(--space-sm);
155155
padding: var(--space-md) var(--space-lg);
156+
border-bottom: 2px solid transparent;
157+
border-radius: inherit;
158+
transition: border-color var(--duration-fast) var(--ease-out);
156159
}
157160

158161
.search-modal__icon {
@@ -234,15 +237,18 @@
234237

235238
.search-modal__results::-webkit-scrollbar-track {
236239
background: transparent;
240+
margin: 8px 0;
237241
}
238242

239243
.search-modal__results::-webkit-scrollbar-thumb {
240244
background: var(--color-light-border);
241245
border-radius: var(--radius-full);
246+
background-clip: padding-box;
242247
}
243248

244249
.search-modal__results::-webkit-scrollbar-thumb:hover {
245250
background: var(--color-gray-base);
251+
background-clip: padding-box;
246252
}
247253

248254
.search-modal__results-list {
@@ -375,22 +381,40 @@
375381

376382
.search-modal__container {
377383
max-width: 100%;
384+
width: 100%;
385+
height: auto;
386+
max-height: calc(100vh - 32px);
378387
}
379388

380389
.search-modal__content {
381390
border-radius: var(--radius-lg);
391+
height: auto;
392+
max-height: calc(100vh - 32px);
393+
}
394+
395+
/* When results are visible, expand to full height */
396+
.search-modal__content:has(.search-modal__results[style*="display: block"]) {
397+
height: calc(100vh - 32px);
382398
}
383399

384400
.search-modal__input-wrapper {
385401
padding: var(--space-md) var(--space-lg);
402+
flex-shrink: 0;
386403
}
387404

388405
.search-modal__input {
389406
font-size: var(--text-base);
390407
}
391408

392409
.search-modal__results {
393-
max-height: 50vh;
410+
flex: 1;
411+
max-height: none;
412+
overflow-y: auto;
413+
}
414+
415+
.search-modal__results[style*="display: none"] {
416+
flex: 0;
417+
display: none;
394418
}
395419

396420
.search-results__item {
@@ -473,10 +497,13 @@
473497

474498
.dark .search-modal__results::-webkit-scrollbar-thumb {
475499
background: var(--color-dark-border);
500+
border: 2px solid transparent;
501+
background-clip: padding-box;
476502
}
477503

478504
.dark .search-modal__results::-webkit-scrollbar-thumb:hover {
479-
background: var(--color-dark-border-subtle);
505+
background: var(--color-gray-base);
506+
background-clip: padding-box;
480507
}
481508

482509
.dark .search-modal__results-list li.selected .search-results__item {

static/search.js

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,22 @@ function openSearchModal() {
2323
document.body.style.overflow = "hidden";
2424

2525
// Focus the search input after a brief delay to ensure modal is visible
26+
// Longer delay for mobile devices to ensure proper focus
27+
const isMobile = window.innerWidth <= 768;
28+
const delay = isMobile ? 200 : 100;
29+
30+
// On mobile, hide results when input is empty (input stays visible)
31+
if (isMobile && searchResults) {
32+
searchResults.style.display = searchInput.value.trim() === "" ? "none" : "block";
33+
}
34+
2635
setTimeout(() => {
2736
searchInput.focus();
28-
}, 100);
37+
// For mobile, ensure keyboard shows up
38+
if (isMobile) {
39+
searchInput.click();
40+
}
41+
}, delay);
2942
}
3043

3144
function closeSearchModal() {
@@ -53,6 +66,17 @@ if (searchModalShortcut) {
5366
searchModalShortcut.addEventListener("click", closeSearchModal);
5467
}
5568

69+
// Focus input when clicking anywhere in the input wrapper (helpful on mobile)
70+
const searchInputWrapper = document.querySelector(".search-modal__input-wrapper");
71+
if (searchInputWrapper) {
72+
searchInputWrapper.addEventListener("click", (e) => {
73+
// Don't focus if clicking the ESC button
74+
if (!e.target.classList.contains("search-modal__shortcut")) {
75+
searchInput.focus();
76+
}
77+
});
78+
}
79+
5680
////////////////////////////////////
5781
// Keyboard shortcuts
5882
////////////////////////////////////
@@ -275,6 +299,7 @@ function debounce(func, wait) {
275299
function showResults(index) {
276300
return function () {
277301
const term = searchInput.value.trim();
302+
278303
searchResults.style.display = term === "" ? "none" : "block";
279304
searchResultsItems.innerHTML = "";
280305

0 commit comments

Comments
 (0)