Skip to content

Commit

Permalink
DF-855 fix missing mobile filters (#1502)
Browse files Browse the repository at this point in the history
Co-authored-by: jamesbiggs <james.biggs@nationalarchives.gov.uk>
  • Loading branch information
JohnHeeryTNA and jamesbiggs authored Jan 11, 2024
1 parent bbed3ee commit badd316
Show file tree
Hide file tree
Showing 14 changed files with 277 additions and 148 deletions.
2 changes: 1 addition & 1 deletion etna/search/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ class EndToEndSearchTestCase(TestCase):
bucket_links_html = (
'<ul class="search-buckets__list" data-id="search-buckets-list">'
)
search_within_option_html = '<label for="id_filter_keyword" class="search-filters__label--block">Search within results:</label>'
search_within_option_html = '<label for="id_filter_keyword" class="search-filters__label--block example-text">Search within results:</label>'
sort_by_desktop_options_html = '<label for="id_sort_by_desktop">Sort by</label>'
sort_by_mobile_options_html = '<label for="id_sort_by_mobile">Sort by</label>'
filter_options_html = '<form method="GET" data-id="filters-form"'
Expand Down
66 changes: 65 additions & 1 deletion sass/includes/search/_search-filters.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
padding: 1rem;

&__heading {
font-size: 1.3em;
// font-size: 1.3em;
display: none;
}

&__widget-list {
Expand Down Expand Up @@ -116,6 +117,19 @@
color: #fff;
margin-bottom: 2rem;
}

button {
border: 0;
background: #f4f4f4;
border-bottom: 1px solid grey;
margin-bottom: 10px;
padding-bottom: 10px;
width: 100%;
text-align: left;
font-weight: 400;
font-size: 1.12rem;
cursor: pointer;
}
}

/* date filters via GDS pattern */
Expand Down Expand Up @@ -150,3 +164,53 @@
.example-text {
color: $color__grey-600;
}

// gov uk overrides

.govuk-accordion__section-toggle-text,
.govuk-accordion__section-heading-divider {
display: none;
}

// GDS chevrons

.govuk-accordion__show-all-text {
margin-left: 0.5rem;
margin-bottom: 0.5rem;
display: inline-block;
}

.govuk-accordion__section-heading-text-focus {
margin-right: 0.25rem;
}

.govuk-accordion-nav__chevron--down {
-webkit-transform: rotate(180deg);
transform: rotate(180deg);
}

.govuk-accordion-nav__chevron {
box-sizing: border-box;
display: inline-block;
position: relative;
width: 1.25rem;
height: 1.25rem;
border: 0.0625rem solid;
border-radius: 50%;
vertical-align: middle;
}

.govuk-accordion-nav__chevron::after {
content: "";
box-sizing: border-box;
display: block;
position: absolute;
bottom: 0.3125rem;
left: 0.375rem;
width: 0.375rem;
height: 0.375rem;
-webkit-transform: rotate(-45deg);
transform: rotate(-45deg);
border-top: 0.125rem solid;
border-right: 0.125rem solid;
}
8 changes: 4 additions & 4 deletions sass/includes/search/_search-results.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
}
}
@media only screen and (max-width: $screen__sm) {
padding-left: 1rem;
padding-left: 0.5rem;
}
}

Expand Down Expand Up @@ -110,7 +110,7 @@
border: 0;
padding: 0;
cursor: pointer;
margin-top: 2rem;
margin-top: 0;
margin-left: 4rem;
position: relative;
font-weight: bold;
Expand All @@ -122,8 +122,8 @@
@media only screen and (max-width: $screen__xl) {
background: $color__black;
color: $color__white;
margin-left: 1.5rem;
width: 90%;
margin-left: 0.5rem;
width: 96%;
padding: 0.8rem;
}

Expand Down
2 changes: 1 addition & 1 deletion sass/includes/search/_search-results__list-card.scss
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@
.search-results__list-card-details {
flex: 1 1 auto;
@media only screen and (max-width: 480px) {
padding-left: 1rem;
padding-left: 0.5rem;
}
}

Expand Down
3 changes: 2 additions & 1 deletion sass/includes/search/_search-sort-view.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
@media only screen and (max-width: $screen__md) {
margin-left: 1rem;
margin-right: 1rem;
margin-bottom: -0.5rem;
}

&__heading {
Expand Down Expand Up @@ -146,6 +147,6 @@
background: #eeedf3;
min-height: 44px;
width: 100%;
margin-bottom: 1rem;
margin-bottom: 1.6rem;
}
}
16 changes: 11 additions & 5 deletions scripts/src/modules/search/mobile-filter-expander-enhanced.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ export default function () {
let $searchFilterContainer = document.querySelector(
'div[data-id="catalogue-search-sidebar"]',
);

let $main = document.querySelector("main");

if (!$searchFilterContainer || !$searchGrid || !$main) {
return;
}

//need case where validation warning is invoked
let $showHideButton = document.createElement("button");
//check the query string to populate the number of selected filters
Expand All @@ -22,17 +24,21 @@ export default function () {
} else {
// no filters selected (always display number of active filters)
$showHideButton.innerHTML =
'Show filters<span class="filter-indicator">' +
$noOfFilters +
'<span class="sr-only"> active</span></span><img src="/static/images/fontawesome-svgs/chevron-down-white.svg" width="20" height="20" style="display:inline-block;margin-left:10px;">';
"Add filters" +
'<span class="sr-only"> active</span><img src="/static/images/fontawesome-svgs/chevron-down-white.svg" width="20" height="20" style="display:inline-block;margin-left:10px;">';
}
$showHideButton.classList.add("search-results__filter-button");
$showHideButton.setAttribute("aria-expanded", false);
$showHideButton.setAttribute("aria-controls", "searchFilterContainer");
$showHideButton.setAttribute("data-link-type", "Mobile Button");
$showHideButton.setAttribute("data-link", "Show search filters");
$showHideButton.hidden = true;
$main.insertBefore($showHideButton, $searchGrid);

//console.log($showHideButton);
//console.log($searchGrid);

//$main.insertBefore($showHideButton, $searchGrid);
$searchGrid.after($showHideButton, $searchGrid);

$searchFilterContainer.id = "searchFilterContainer";

Expand All @@ -50,7 +56,7 @@ export default function () {
'Hide filters <img src="/static/images/fontawesome-svgs/chevron-up-white.svg" width="20px" height="20px" style=\'display: inline-block;margin-left: 10px;\'>';
} else {
$showHideButton.innerHTML =
'Show filters<span class="filter-indicator">' +
'Add filters<span class="filter-indicator">' +
$noOfFilters +
'<span class="sr-only"> active</span></span><img src="/static/images/fontawesome-svgs/chevron-down-white.svg" width="20" height="20" style=\'display: inline-block;margin-left: 10px;\'>';
}
Expand Down
5 changes: 3 additions & 2 deletions templates/search/blocks/catalogue_search_buckets.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ <h2 class="tna-heading-l search-sort-view__heading">
</form>
</div>
<!-- end new form element-->

<nav class="tna-container search-buckets" aria-label="Record categories">
<div class="tna-container">
<nav class="search-buckets" aria-label="Record categories">
<ul class="search-buckets__list" data-id="search-buckets-list">
{% for bucket in buckets %}
{% if bucket.result_count != None %}
Expand All @@ -39,3 +39,4 @@ <h2 class="tna-heading-l search-sort-view__heading">
{% endfor %}
</ul>
</nav>
</div>
Loading

0 comments on commit badd316

Please sign in to comment.