Skip to content

Commit

Permalink
Make admin pagination accessible
Browse files Browse the repository at this point in the history
We label the pagination icon wrappers with "aria-label", while hiding
the icon itself to screen readers. We also mark as "aria-disable"'d when
the first/last page is reached.
  • Loading branch information
waiting-for-dev committed Jul 21, 2023
1 parent b19fd5d commit 180400b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion admin/app/components/solidus_admin/base_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class BaseComponent < ViewComponent::Base
def icon_tag(name, **attrs)
href = image_path("solidus_admin/remixicon.symbol.svg") + "#ri-#{name}"
tag.svg(
class: attrs[:class],
**attrs
) do
tag.use(
"xlink:href": href
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@
<ul class="flex items-center">
<li>
<% if @page.first? %>
<span class="<%= link_classes(rounded: :left) %>">
<%= icon_tag("arrow-left-s-line", class: "fill-current text-grey-400 w-5 h-5") %>
<span class="<%= link_classes(rounded: :left) %>", "aria-label"=<%= t(".prev") %>, "aria-disabled"=true>
<%= icon_tag("arrow-left-s-line", class: "fill-current text-grey-400 w-5 h-5", "aria-hidden" => true) %>
</span>
<% else %>
<%= link_to @path.call(@page.number - 1), class: link_classes(rounded: :left) do %>
<%= icon_tag("arrow-left-s-line", class: "w-5 h-5") %>
<%= link_to @path.call(@page.number - 1), class: link_classes(rounded: :left), "aria-label" => t(".prev") do %>
<%= icon_tag("arrow-left-s-line", class: "w-5 h-5", "aria-hidden" => true) %>
<% end %>
<% end %>
</li>

<li>
<% if @page.last? %>
<span class="<%= link_classes(rounded: :right) %>">
<%= icon_tag("arrow-right-s-line", class: "fill-current text-grey-400 w-5 h-5") %>
<span class="<%= link_classes(rounded: :right) %>", "aria-label"=<%= t(".next") %>, "aria-disabled"=true>
<%= icon_tag("arrow-right-s-line", class: "fill-current text-grey-400 w-5 h-5", "aria-hidden" => true) %>
</span>
<% else %>
<%= link_to @path.call(@page.next_param), class: link_classes(rounded: :right) do %>
<%= icon_tag("arrow-right-s-line", class: "w-5 h-5") %>
<%= link_to @path.call(@page.next_param), class: link_classes(rounded: :right), "aria-label" => t(".next") do %>
<%= icon_tag("arrow-right-s-line", class: "w-5 h-5", "aria-hidden" => true) %>
<% end %>
<% end %>
</li>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
en:
next: Next
prev: Previous

0 comments on commit 180400b

Please sign in to comment.