5 changed files with 177 additions and 134 deletions
@ -0,0 +1,16 @@
|
||||
import { Controller } from "@hotwired/stimulus"; |
||||
|
||||
export default class extends Controller { |
||||
toggleFilter() { |
||||
let filter_panel = document.getElementById("filter-panel"); |
||||
let toggle_filter_button = document.getElementById("toggle-filter-button"); |
||||
|
||||
if (filter_panel.style.display === "none" || !filter_panel.style.display) { |
||||
filter_panel.style.display = "block"; |
||||
toggle_filter_button.innerText = "Hide filters"; |
||||
} else { |
||||
filter_panel.style.display = "none"; |
||||
toggle_filter_button.innerText = "Show filters"; |
||||
} |
||||
} |
||||
} |
@ -1,109 +1,123 @@
|
||||
.app-filter { |
||||
background-color: govuk-colour("light-grey"); |
||||
margin-bottom: govuk-spacing(2); |
||||
background-color: govuk-colour("light-grey"); |
||||
margin-bottom: govuk-spacing(2); |
||||
} |
||||
|
||||
.app-filter__header { |
||||
background-color: govuk-colour("light-grey"); |
||||
display: flex; |
||||
justify-content: space-between; |
||||
padding: govuk-spacing(2) govuk-spacing(3); |
||||
position: sticky; |
||||
top: 0; |
||||
z-index: 10; |
||||
|
||||
@include govuk-media-query($from: desktop) { |
||||
position: static; |
||||
} |
||||
|
||||
.app-filter__header { |
||||
background-color: govuk-colour("light-grey"); |
||||
display: flex; |
||||
justify-content: space-between; |
||||
padding: govuk-spacing(2) govuk-spacing(3); |
||||
position: sticky; |
||||
top: 0; |
||||
z-index: 10; |
||||
|
||||
@include govuk-media-query($from: desktop) { |
||||
position: static; |
||||
} |
||||
|
||||
[class^=govuk-heading-] { |
||||
margin-bottom: 0; |
||||
} |
||||
[class^="govuk-heading-"] { |
||||
margin-bottom: 0; |
||||
} |
||||
|
||||
.app-filter__content { |
||||
padding: govuk-spacing(1) govuk-spacing(3) govuk-spacing(4); |
||||
} |
||||
|
||||
.app-filter__content { |
||||
padding: govuk-spacing(1) govuk-spacing(3) govuk-spacing(4); |
||||
} |
||||
|
||||
.app-filter__close { |
||||
@include govuk-font(19); |
||||
|
||||
-webkit-appearance: none; |
||||
background-color: transparent; |
||||
border: none; |
||||
border-radius: 0; |
||||
color: $govuk-text-colour; |
||||
cursor: pointer; |
||||
margin: #{govuk-spacing(1) * -1}; |
||||
padding: govuk-spacing(1); |
||||
|
||||
&:focus { |
||||
background-color: $govuk-focus-colour; |
||||
color: $govuk-focus-text-colour; |
||||
box-shadow: 0 -2px $govuk-focus-colour, 0 4px $govuk-focus-text-colour; |
||||
outline: none; |
||||
} |
||||
|
||||
.app-filter__close { |
||||
@include govuk-font(19); |
||||
|
||||
-webkit-appearance: none; |
||||
background-color: transparent; |
||||
border: none; |
||||
border-radius: 0; |
||||
color: $govuk-text-colour; |
||||
cursor: pointer; |
||||
margin: #{govuk-spacing(1) * -1}; |
||||
padding: govuk-spacing(1); |
||||
// Fix unwanted button padding in Firefox |
||||
&::-moz-focus-inner { |
||||
padding: 0; |
||||
border: 0; |
||||
} |
||||
|
||||
&:focus { |
||||
background-color: $govuk-focus-colour; |
||||
color: $govuk-focus-text-colour; |
||||
box-shadow: 0 -2px $govuk-focus-colour, 0 4px $govuk-focus-text-colour; |
||||
outline: none; |
||||
} |
||||
&::before { |
||||
background-image: url("../assets/images/icon-cross.svg"); |
||||
content: ""; |
||||
display: inline-block; |
||||
height: 14px; |
||||
margin-right: govuk-spacing(1); |
||||
position: relative; |
||||
top: -2px; // Alignment tweak |
||||
vertical-align: middle; |
||||
width: 14px; |
||||
} |
||||
|
||||
// Fix unwanted button padding in Firefox |
||||
&::-moz-focus-inner { |
||||
padding: 0; |
||||
border: 0; |
||||
} |
||||
@include govuk-media-query(desktop) { |
||||
display: none; |
||||
} |
||||
} |
||||
|
||||
&::before { |
||||
background-image: url("../assets/images/icon-cross.svg"); |
||||
content: ""; |
||||
display: inline-block; |
||||
height: 14px; |
||||
margin-right: govuk-spacing(1); |
||||
position: relative; |
||||
top: -2px; // Alignment tweak |
||||
vertical-align: middle; |
||||
width: 14px; |
||||
} |
||||
.app-filter-layout { |
||||
@include govuk-clearfix; |
||||
} |
||||
|
||||
@include govuk-media-query(desktop) { |
||||
display: none; |
||||
} |
||||
.app-filter-toggle__button { |
||||
min-width: 128px; |
||||
@include govuk-media-query(desktop) { |
||||
display: none !important; |
||||
} |
||||
} |
||||
|
||||
.app-filter-layout { |
||||
@include govuk-clearfix; |
||||
.app-filter-layout__filter { |
||||
@include govuk-media-query(desktop) { |
||||
float: left; |
||||
min-width: govuk-grid-width("one-quarter"); |
||||
} |
||||
display: none; |
||||
|
||||
.app-filter-layout__filter { |
||||
@include govuk-media-query(desktop) { |
||||
float: left; |
||||
min-width: govuk-grid-width("one-quarter"); |
||||
} |
||||
@include govuk-media-query(desktop) { |
||||
display: block; |
||||
} |
||||
} |
||||
|
||||
.js-enabled .app-filter-layout__filter { |
||||
outline: 0 none; |
||||
|
||||
@include govuk-media-query($until: desktop) { |
||||
background-color: govuk-colour("light-grey"); |
||||
bottom: govuk-spacing(1); |
||||
border: 1px solid govuk-colour("mid-grey"); |
||||
max-width: 310px; |
||||
min-width: 260px; |
||||
width: 100%; |
||||
overflow-y: scroll; |
||||
position: fixed; |
||||
right: govuk-spacing(1); |
||||
top: govuk-spacing(1); |
||||
z-index: 100; |
||||
|
||||
&:focus { |
||||
outline: $govuk-focus-width solid $govuk-focus-colour; |
||||
} |
||||
} |
||||
} |
||||
.js-enabled .app-filter-layout__filter { |
||||
outline: 0 none; |
||||
|
||||
@include govuk-media-query($until: desktop) { |
||||
background-color: govuk-colour("light-grey"); |
||||
bottom: govuk-spacing(1); |
||||
border: 1px solid govuk-colour("mid-grey"); |
||||
max-width: 310px; |
||||
min-width: 260px; |
||||
width: 100%; |
||||
overflow-y: scroll; |
||||
position: fixed; |
||||
right: govuk-spacing(1); |
||||
top: govuk-spacing(1); |
||||
z-index: 100; |
||||
|
||||
.app-filter-layout__content { |
||||
@include govuk-media-query(desktop) { |
||||
float: right; |
||||
max-width: calc(#{govuk-grid-width("three-quarters")} - #{govuk-spacing(6)}); |
||||
width: 100%; |
||||
&:focus { |
||||
outline: $govuk-focus-width solid $govuk-focus-colour; |
||||
} |
||||
} |
||||
} |
||||
|
||||
.app-filter-layout__content { |
||||
@include govuk-media-query(desktop) { |
||||
float: right; |
||||
max-width: calc( |
||||
#{govuk-grid-width("three-quarters")} - #{govuk-spacing(6)} |
||||
); |
||||
width: 100%; |
||||
} |
||||
} |
||||
|
@ -1,30 +1,32 @@
|
||||
<div class="govuk-grid-column-one-quarter"> |
||||
<div class="app-filter-layout"> |
||||
<div class="app-filter-layout__filter"> |
||||
<div class="app-filter"> |
||||
<div class="app-filter__header"> |
||||
<h2 class="govuk-heading-m">Filters</h2> |
||||
<button class="app-filter__close" type="button">Close</button> |
||||
</div> |
||||
<div class="app-filter__content"> |
||||
<div class="govuk-form-group app-filter__group"> |
||||
<%= form_with url: "/logs/filter", html: { method: :post }, builder: GOVUKDesignSystemFormBuilder::FormBuilder do |f| %> |
||||
<%= f.govuk_check_boxes_fieldset :status, legend: { text: "Status", size: "s"} do %> |
||||
<div class="govuk-checkboxes govuk-checkboxes--small" data-module="govuk-checkboxes"> |
||||
<% statuses = {in_progress: "In progress", submitted: "Completed", not_started: "Not started"} %> |
||||
<% statuses.map do |key, option| %> |
||||
<%= f.govuk_check_box "status", "#{key}", |
||||
label: { text: option }, |
||||
checked: filter_selected?(key), |
||||
size: "s" %> |
||||
<% end %> |
||||
<div class="app-filter-layout__filter" tabindex="-1" id="filter-panel"> |
||||
<div class="app-filter" > |
||||
<div class="app-filter__header"> |
||||
<h2 class="govuk-heading-m">Filters</h2> |
||||
<button |
||||
class="app-filter__close" |
||||
type="button" |
||||
data-controller="filter" |
||||
data-action="click->filter#toggleFilter"> |
||||
Close |
||||
</button> |
||||
</div> |
||||
<div class="app-filter__content"> |
||||
<div class="govuk-form-group app-filter__group"> |
||||
<%= form_with url: "/logs/filter", html: { method: :post }, builder: GOVUKDesignSystemFormBuilder::FormBuilder do |f| %> |
||||
<%= f.govuk_check_boxes_fieldset :status, legend: { text: "Status", size: "s"} do %> |
||||
<div class="govuk-checkboxes govuk-checkboxes--small" data-module="govuk-checkboxes"> |
||||
<% statuses = {in_progress: "In progress", submitted: "Completed", not_started: "Not started"} %> |
||||
<% statuses.map do |key, option| %> |
||||
<%= f.govuk_check_box "status", "#{key}", |
||||
label: { text: option }, |
||||
checked: filter_selected?(key), |
||||
size: "s" %> |
||||
<% end %> |
||||
</div> |
||||
<% end %> |
||||
<%= f.govuk_submit "Apply filters", class: "govuk-!-margin-top-4" %> |
||||
<% end %> |
||||
</div> |
||||
<% end %> |
||||
<%= f.govuk_submit "Apply filters", class: "govuk-!-margin-top-4" %> |
||||
<% end %> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</div> |
Loading…
Reference in new issue