Enhance search functionality with loading indicators, dark mode support, and improved UI; implement event handling for search results and refine park filter tests for better coverage

This commit is contained in:
pacnpal
2025-02-13 09:42:58 -05:00
parent 1fe299fb4b
commit c197051b25
8 changed files with 292 additions and 134 deletions

View File

@@ -0,0 +1,32 @@
/* Loading indicator */
.htmx-indicator {
opacity: 0;
}
.htmx-request .htmx-indicator {
opacity: 1;
}
/* Search results spacing */
#search-results {
margin-top: 0.5rem;
}
/* Dark mode adjustments */
@media (prefers-color-scheme: dark) {
#search-results .bg-white {
background-color: #1f2937;
}
#search-results .text-gray-900 {
color: #f3f4f6;
}
#search-results .text-gray-500 {
color: #9ca3af;
}
#search-results .hover\:bg-gray-50:hover {
background-color: #374151;
}
}

View File

@@ -0,0 +1,28 @@
document.addEventListener('DOMContentLoaded', function() {
const searchInput = document.getElementById('search');
const searchResults = document.getElementById('search-results');
if (!searchInput || !searchResults) return;
// Clear search results when clicking outside
document.addEventListener('click', function(e) {
if (!searchResults.contains(e.target) && e.target !== searchInput) {
searchResults.innerHTML = '';
}
});
// Clear results on escape key
searchInput.addEventListener('keydown', function(e) {
if (e.key === 'Escape') {
searchResults.innerHTML = '';
searchInput.value = '';
searchInput.blur();
}
});
// Handle back button
window.addEventListener('popstate', function() {
searchResults.innerHTML = '';
searchInput.value = '';
});
});