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

🐞🔨 Pagination: Fix missing translation error for Next and Previous links #2217

Merged
merged 1 commit into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions app/assets/stylesheets/application.postcss.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
@import "./utilities.scss";
@import "./components.scss";
@import "actiontext.css";
@import "./extensions/pagy.scss";
8 changes: 8 additions & 0 deletions app/assets/stylesheets/extensions/pagy.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.pagy-nav {
@apply flex justify-between;

.page.active a,
.page.disabled a {
@apply no-underline;
}
}
2 changes: 1 addition & 1 deletion app/furniture/journal/journals/_journal.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<%= render Journal::EntryComponent.with_collection(@entries) %>
</div>

<%== pagy_nav(@pagy, nav_extra: 'flex justify-between') %>
<%== pagy_nav(@pagy) %>

<%= render Journal::NewEntryButtonComponent.new(journal: journal) %>
</section>
2 changes: 1 addition & 1 deletion app/furniture/marketplace/orders/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
<%- @pagy, @records = pagy(orders.paid) %>
<div class="mx-auto w-full max-w-prose">
<%= render @records %>
<%== pagy_nav(@pagy, nav_extra: 'flex justify-between mt-4') %>
<%== pagy_nav(@pagy) %>
</div>
31 changes: 0 additions & 31 deletions app/helpers/pagy_helper.rb
Original file line number Diff line number Diff line change
@@ -1,35 +1,4 @@
module PagyHelper
include Pagy::Backend
include Pagy::Frontend

# @todo submit a patch to Pagy which allows us to override the classes using `nav_extra`
# since there wasn't a tidy seam to inject tailwind classes on the container beyond
# copy-paste-and-replace
def pagy_nav(pagy, pagy_id: nil, link_extra: "", nav_extra: "", **)
p_id = %( id="#{pagy_id}") if pagy_id
link = pagy_link_proc(pagy, link_extra: link_extra)
p_prev = pagy.prev
p_next = pagy.next

html = +%(<nav#{p_id} class="pagy-nav pagination #{nav_extra}">)
html << if p_prev
%(<span class="page prev">#{link.call p_prev, pagy_t("pagy.nav.prev"), 'aria-label="previous"'}</span> )
else
%(<span class="page prev disabled">#{pagy_t("pagy.nav.prev")}</span> )
end
pagy.series(**).each do |item| # series example: [1, :gap, 7, 8, "9", 10, 11, :gap, 36]
html << case item
when Integer then %(<span class="page">#{link.call item}</span> )
when String then %(<span class="page active">#{pagy.label_for(item)}</span> )
when :gap then %(<span class="page gap">#{pagy_t("pagy.nav.gap")}</span> )
else raise InternalError, "expected item types in series to be Integer, String or :gap; got #{item.inspect}"
end
end
html << if p_next
%(<span class="page next">#{link.call p_next, pagy_t("pagy.nav.next"), 'aria-label="next"'}</span>)
else
%(<span class="page next disabled">#{pagy_t("pagy.nav.next")}</span>)
end
html << %(</nav>)
end
end
2 changes: 1 addition & 1 deletion app/views/neighborhoods/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<%= render @records %>
</div>

<%== pagy_nav(@pagy, nav_extra: 'flex justify-between') %>
<%== pagy_nav(@pagy) %>

<%- if policy(Space).new? %>
<div class="text-center w-full">
Expand Down
Loading