From 11b4931d27465339926dc6e3882cb0588c241ffe Mon Sep 17 00:00:00 2001 From: Zarino Zappia Date: Mon, 1 Apr 2024 11:53:25 +0100 Subject: [PATCH] Location search now handles all area types MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #504. AreaSearchView no longer artificially limits results to WMC area_types, and area_search.html presents matching areas grouped by area_type. I’ve gone with a custom `grid` layout on the area_search.html (rather than Bootstrap columns) to more gracefully handle a variable number of columns – there might be 1, 2, or 3, depending on the search input. I also fixed a bug in the `highlight` filter, which raised a TypeError when passed a None `search` parameter. `search` is None when the user has used geolocation rather than submitting a search term. --- hub/static/css/_search-results.scss | 17 +++++ hub/static/css/main.scss | 1 + hub/templates/hub/area_search.html | 48 +++++++++---- .../search-results-area-type-intro.html | 25 +++++++ hub/templatetags/hub_filters.py | 10 ++- hub/views/area.py | 71 ++++++++++++++----- 6 files changed, 138 insertions(+), 34 deletions(-) create mode 100644 hub/static/css/_search-results.scss create mode 100644 hub/templates/hub/includes/search-results-area-type-intro.html diff --git a/hub/static/css/_search-results.scss b/hub/static/css/_search-results.scss new file mode 100644 index 000000000..6fb132bef --- /dev/null +++ b/hub/static/css/_search-results.scss @@ -0,0 +1,17 @@ +.search-results { + h2 { + margin-top: 3rem; + } + + @include media-breakpoint-up(lg) { + display: grid; + grid-auto-flow: column; + grid-template-rows: repeat(3, auto); + grid-auto-columns: minmax(auto, 30rem); // constrain col width when less than three in grid + grid-column-gap: 2rem; + } + + @include media-breakpoint-up(xl) { + grid-column-gap: 3rem; + } +} diff --git a/hub/static/css/main.scss b/hub/static/css/main.scss index 82f97b15c..50c61a43c 100644 --- a/hub/static/css/main.scss +++ b/hub/static/css/main.scss @@ -51,6 +51,7 @@ @import "site-footer"; @import "site-feedback"; @import "search-input"; +@import "search-results"; @import "explore"; @import "homepage"; @import "area"; diff --git a/hub/templates/hub/area_search.html b/hub/templates/hub/area_search.html index 896a06ffb..00378e77d 100644 --- a/hub/templates/hub/area_search.html +++ b/hub/templates/hub/area_search.html @@ -7,13 +7,13 @@
-

Search by location

- +

Search for a location

+