Skip to content

Commit

Permalink
Add tooltips, make newest/oldest buttons tooltip only
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonKhorev committed Aug 22, 2024
1 parent 8dbc221 commit 6cbb996
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions app/helpers/pagination_helper.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module PaginationHelper
def pagination_item(params, &block)
def pagination_item(params, title, &block)
link_class = "page-link icon-link text-center"
page_link_content = capture(&block)
if params
page_link = link_to page_link_content, params, :class => link_class, :data => { "turbo-frame" => "pagination", "turbo-action" => "advance" }
page_link = link_to page_link_content, params, :class => link_class, :title => title, :data => { "turbo-frame" => "pagination", "turbo-action" => "advance" }
tag.li page_link, :class => "page-item d-flex"
else
page_link = tag.span page_link_content, :class => link_class
Expand Down
14 changes: 8 additions & 6 deletions app/views/shared/_pagination.html.erb
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
<nav class="d-flex justify-content-between gap-2">
<ul class="pagination">
<%= pagination_item(newer_id && @params.merge(:before => nil, :after => nil)) do %>
<%= pagination_item(newer_id && @params.merge(:before => nil, :after => nil),
t(:newest, :scope => translation_scope)) do %>
<%= previous_page_svg_tag :class => "flex-shrink-0", :count => 2 %>
<span class="d-none d-md-block"><%= t :newest, :scope => translation_scope %></span>
<% end %>
</ul>
<ul class="pagination">
<%= pagination_item(newer_id && @params.merge(:before => nil, :after => newer_id)) do %>
<%= pagination_item(newer_id && @params.merge(:before => nil, :after => newer_id),
t(:newer, :scope => translation_scope)) do %>
<%= previous_page_svg_tag :class => "flex-shrink-0" %>
<span class="d-none d-sm-block"><%= t :newer, :scope => translation_scope %></span>
<% end %>
<%= pagination_item(older_id && @params.merge(:before => older_id, :after => nil)) do %>
<%= pagination_item(older_id && @params.merge(:before => older_id, :after => nil),
t(:older, :scope => translation_scope)) do %>
<span class="d-none d-sm-block"><%= t :older, :scope => translation_scope %></span>
<%= next_page_svg_tag :class => "flex-shrink-0" %>
<% end %>
</ul>
<ul class="pagination">
<%= pagination_item(older_id && @params.merge(:before => nil, :after => 0)) do %>
<span class="d-none d-md-block"><%= t :oldest, :scope => translation_scope %></span>
<%= pagination_item(older_id && @params.merge(:before => nil, :after => 0),
t(:oldest, :scope => translation_scope)) do %>
<%= next_page_svg_tag :class => "flex-shrink-0", :count => 2 %>
<% end %>
</ul>
Expand Down

0 comments on commit 6cbb996

Please sign in to comment.