mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-22 15:11:09 -05:00
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:
32
parks/static/parks/css/search.css
Normal file
32
parks/static/parks/css/search.css
Normal 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;
|
||||
}
|
||||
}
|
||||
28
parks/static/parks/js/search.js
Normal file
28
parks/static/parks/js/search.js
Normal 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 = '';
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user