Skip to content

Commit

Permalink
Admin member index: Update pagination layout & styles (forem#16995)
Browse files Browse the repository at this point in the history
* pagination theme for new admin view

* align pagination widget correctly in desktop view

* remove bottom pagination

* re-add pagination to the bottom

* use block styling for the links
  • Loading branch information
aitchiss authored Mar 25, 2022
1 parent 706ec6a commit c5ffa8b
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 4 deletions.
3 changes: 3 additions & 0 deletions app/assets/images/chevron-left.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions app/assets/stylesheets/admin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ label {
padding: 8px;
}
}
// New pagination styles as added in Admin Member Index view. As we roll out these styles to other admin views, the above CSS will eventually be removed.
.admin-pagination {
color: var(--link-color-secondary);

&--link {
padding: var(--su-1);
}

&--inactive {
color: var(--base-30);
}
}

.bg-featured {
background: #bbffd2;
Expand Down
11 changes: 7 additions & 4 deletions app/views/admin/users/_member_index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
<%= render "admin/users/index/tabs" %>
</header>

<%= render "admin/users/index/controls" %>
<%= paginate @users, theme: "internal" %>
<div class="flex justify-between">
<%= render "admin/users/index/controls" %>
<%= paginate @users, theme: "admin", scope: @users, label: "Paginate users" %>
</div>

<table class="crayons-table" width="100%">
<thead>
Expand All @@ -26,5 +27,7 @@
</tbody>
</table>

<%= paginate @users, theme: "internal" %>
<div class="flex justify-end">
<%= paginate @users, theme: "admin", scope: @users, label: "Paginate users" %>
</div>
</div>
4 changes: 4 additions & 0 deletions app/views/kaminari/admin/_next_page.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<li class="flex items-center">
<%= link_to_unless current_page.last?, crayons_icon_tag("chevron-right", aria_hidden: true, class: ("admin-pagination--inactive mx-1" if current_page.last?).to_s), url, rel: "next", remote: remote, class: "admin-pagination--link c-link c-link--icon-alone c-link--block",
aria: { label: t("views.pagination.aria_next"), describedby: "pagination-description" } %>
</li>
12 changes: 12 additions & 0 deletions app/views/kaminari/admin/_paginator.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<%= paginator.render do %>
<nav aria-label="<%= label %>" class="admin-pagination flex fs-s items-center">
<span id="pagination-description">
<span class="screen-reader-only">Currently showing: </span>
<%= page_entries_info scope %>
</span>
<ul class="flex">
<%= prev_page_tag %>
<%= next_page_tag %>
</ul>
</nav>
<% end %>
4 changes: 4 additions & 0 deletions app/views/kaminari/admin/_prev_page.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<li class="flex items-center">
<%= link_to_unless current_page.first?, crayons_icon_tag("chevron-left", aria_hidden: true, class: ("admin-pagination--inactive mx-1" if current_page.first?).to_s), url, rel: "prev", remote: remote, class: "admin-pagination--link c-link c-link--icon-alone c-link--block",
aria: { label: t("views.pagination.aria_previous"), describedby: "pagination-description" } %>
</li>
10 changes: 10 additions & 0 deletions config/locales/kaminari.en.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
en:
views:
pagination:
aria_next: "Next page"
aria_previous: "Previous page"
helpers:
page_entries_info:
more_pages:
display_entries: "%{first}&nbsp;-&nbsp;%{last} of %{total}"
6 changes: 6 additions & 0 deletions config/locales/kaminari.fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@
fr:
views:
pagination:
aria_next: "Next page"
aria_previous: "Previous page"
first: "&laquo; Premier"
last: Dernier &raquo;
next: Suivant &rsaquo;
previous: "&lsaquo; Précédent"
truncate: "&hellip;"
helpers:
page_entries_info:
more_pages:
display_entries: "%{first}&nbsp;-&nbsp;%{last} of %{total}"

0 comments on commit c5ffa8b

Please sign in to comment.