Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wcag search filters navigation #1240

Draft
wants to merge 6 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 43 additions & 38 deletions decidim-core/app/views/decidim/searches/_filters.html.erb
Original file line number Diff line number Diff line change
@@ -1,44 +1,49 @@
<div class="filter-container search__filter">
<button id="dropdown-trigger-search" data-component="dropdown" data-target="dropdown-menu-search" data-auto-close="true">
<%= content_tag :span, t("decidim.searches.filters_small_view.filter_by"), class: "#{"is-active" if params.dig(:filter, :with_resource_type) == nil}" %>
<% @blocks.each do |elements| %>
<% elements.each do |type, results| %>
<%= content_tag :span, class: "#{"is-active" if params.dig(:filter, :with_resource_type) == type}" do %>
<span><%= searchable_resource_human_name(type) %></span>
<nav role="navigation" aria-labelledby="filters-title">
<h1 id="filters-title" class="sr-only">
<%= t("decidim.searches.filters.title", default: "Search filters") %>
</h1>
BarbaraOliveira13 marked this conversation as resolved.
Show resolved Hide resolved
<div class="filter-container search__filter">
<button id="dropdown-trigger-search" data-component="dropdown" data-target="dropdown-menu-search" data-auto-close="true">
<%= content_tag :span, t("decidim.searches.filters_small_view.filter_by"), class: "#{"is-active" if params.dig(:filter, :with_resource_type) == nil}" %>
<% @blocks.each do |elements| %>
<% elements.each do |type, results| %>
<%= content_tag :span, class: "#{"is-active" if params.dig(:filter, :with_resource_type) == type}" do %>
<span><%= searchable_resource_human_name(type) %></span>
<% end %>
<% end %>
<% end %>
<% end %>
<%= icon "arrow-down-s-line", class: "w-8 h-8 flex-none text-secondary fill-current" %>
<%= icon "arrow-up-s-line", class: "w-8 h-8 flex-none text-secondary fill-current" %>
</button>
<div id="dropdown-menu-search" aria-hidden="true">
<div>
<%= link_to main_search_path, class: "filter#{" is-active" if params.dig(:filter, :with_resource_type) == nil}" do %>
<%= resource_type_icon("all") %>
<span><%= t("all", scope: "decidim.searches.filters.state") %></span>
<span class="label ml-auto"><%= @results_count %></span>
<% end %>
</div>
<% @blocks.each do |elements| %>
<%= icon "arrow-down-s-line", class: "w-8 h-8 flex-none text-secondary fill-current" %>
<%= icon "arrow-up-s-line", class: "w-8 h-8 flex-none text-secondary fill-current" %>
</button>
<div id="dropdown-menu-search" aria-hidden="true">
<div>
<% elements.each do |type, results| %>
<div>
<% if results[:count].positive? %>
<%= link_to search_path_by_resource_type(type), class: "filter#{" is-active" if params.dig(:filter, :with_resource_type) == type}" do %>
<%= resource_type_icon(type) %>
<span><%= searchable_resource_human_name(type) %></span>
<span class="label ml-auto"><%= results[:count] %></span>
<% end %>
<% else %>
<%= content_tag :div, class: "filter#{" is-empty" if results[:count].zero?}" do %>
<%= resource_type_icon(type) %>
<span><%= searchable_resource_human_name(type) %></span>
<span class="label ml-auto"><%= results[:count] %></span>
<% end %>
<% end %>
</div>
<%= link_to main_search_path, class: "filter#{" is-active" if params.dig(:filter, :with_resource_type) == nil}" do %>
<%= resource_type_icon("all") %>
<span><%= t("all", scope: "decidim.searches.filters.state") %></span>
<span class="label ml-auto"><%= @results_count %></span>
<% end %>
</div>
<% end %>
<% @blocks.each do |elements| %>
<div>
<% elements.each do |type, results| %>
<div>
<% if results[:count].positive? %>
<%= link_to search_path_by_resource_type(type), class: "filter#{" is-active" if params.dig(:filter, :with_resource_type) == type}" do %>
<%= resource_type_icon(type) %>
<span><%= searchable_resource_human_name(type) %></span>
<span class="label ml-auto"><%= results[:count] %></span>
<% end %>
<% else %>
<%= content_tag :div, class: "filter#{" is-empty" if results[:count].zero?}" do %>
<%= resource_type_icon(type) %>
<span><%= searchable_resource_human_name(type) %></span>
<span class="label ml-auto"><%= results[:count] %></span>
<% end %>
<% end %>
</div>
<% end %>
</div>
<% end %>
</div>
</div>
</div>
</nav>
1 change: 1 addition & 0 deletions decidim-core/config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1710,6 +1710,7 @@ en:
all: All
future: Future
past: Past
title: "Search filters"
filters_small_view:
filter: Filter
filter_and_search: Filter and search
Expand Down
Loading