From 79235cb98c86c160c8463e4995e5688c596b58e6 Mon Sep 17 00:00:00 2001 From: Zee <50284+zspencer@users.noreply.github.com> Date: Tue, 20 Feb 2024 10:27:53 -0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9E=F0=9F=94=A8=20`Pagination`:=20Fix?= =?UTF-8?q?=20missing=20translation=20error=20for=20`Next`=20and=20`Previo?= =?UTF-8?q?us`=20links=20(#2217)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - https://github.com/zinc-collective/convene/issues/2216 With the Pagy 7 upgrade; the helper I wrote so we could add spacing between the Pagination links broke. This switches out from doing an in-ruby style override to an in-css style override; which should be less fraught. --- .../stylesheets/application.postcss.css | 1 + app/assets/stylesheets/extensions/pagy.scss | 8 +++++ .../journal/journals/_journal.html.erb | 2 +- .../marketplace/orders/index.html.erb | 2 +- app/helpers/pagy_helper.rb | 31 ------------------- app/views/neighborhoods/show.html.erb | 2 +- 6 files changed, 12 insertions(+), 34 deletions(-) create mode 100644 app/assets/stylesheets/extensions/pagy.scss diff --git a/app/assets/stylesheets/application.postcss.css b/app/assets/stylesheets/application.postcss.css index ff9af79db..dc8bd8752 100644 --- a/app/assets/stylesheets/application.postcss.css +++ b/app/assets/stylesheets/application.postcss.css @@ -8,3 +8,4 @@ @import "./utilities.scss"; @import "./components.scss"; @import "actiontext.css"; +@import "./extensions/pagy.scss"; diff --git a/app/assets/stylesheets/extensions/pagy.scss b/app/assets/stylesheets/extensions/pagy.scss new file mode 100644 index 000000000..f0e347199 --- /dev/null +++ b/app/assets/stylesheets/extensions/pagy.scss @@ -0,0 +1,8 @@ +.pagy-nav { + @apply flex justify-between; + + .page.active a, + .page.disabled a { + @apply no-underline; + } +} diff --git a/app/furniture/journal/journals/_journal.html.erb b/app/furniture/journal/journals/_journal.html.erb index 485fa7bde..2b37d4016 100644 --- a/app/furniture/journal/journals/_journal.html.erb +++ b/app/furniture/journal/journals/_journal.html.erb @@ -7,7 +7,7 @@ <%= render Journal::EntryComponent.with_collection(@entries) %> - <%== pagy_nav(@pagy, nav_extra: 'flex justify-between') %> + <%== pagy_nav(@pagy) %> <%= render Journal::NewEntryButtonComponent.new(journal: journal) %> diff --git a/app/furniture/marketplace/orders/index.html.erb b/app/furniture/marketplace/orders/index.html.erb index 33a4ae9de..9191ad744 100644 --- a/app/furniture/marketplace/orders/index.html.erb +++ b/app/furniture/marketplace/orders/index.html.erb @@ -2,5 +2,5 @@ <%- @pagy, @records = pagy(orders.paid) %>
<%= render @records %> - <%== pagy_nav(@pagy, nav_extra: 'flex justify-between mt-4') %> + <%== pagy_nav(@pagy) %>
diff --git a/app/helpers/pagy_helper.rb b/app/helpers/pagy_helper.rb index 95599c572..6b1a93e5c 100644 --- a/app/helpers/pagy_helper.rb +++ b/app/helpers/pagy_helper.rb @@ -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 = +%() - html << if p_prev - %(#{link.call p_prev, pagy_t("pagy.nav.prev"), 'aria-label="previous"'} ) - else - %(#{pagy_t("pagy.nav.prev")} ) - end - pagy.series(**).each do |item| # series example: [1, :gap, 7, 8, "9", 10, 11, :gap, 36] - html << case item - when Integer then %(#{link.call item} ) - when String then %(#{pagy.label_for(item)} ) - when :gap then %(#{pagy_t("pagy.nav.gap")} ) - else raise InternalError, "expected item types in series to be Integer, String or :gap; got #{item.inspect}" - end - end - html << if p_next - %(#{link.call p_next, pagy_t("pagy.nav.next"), 'aria-label="next"'}) - else - %(#{pagy_t("pagy.nav.next")}) - end - html << %() - end end diff --git a/app/views/neighborhoods/show.html.erb b/app/views/neighborhoods/show.html.erb index 318ee160d..2afbedbd0 100644 --- a/app/views/neighborhoods/show.html.erb +++ b/app/views/neighborhoods/show.html.erb @@ -5,7 +5,7 @@ <%= render @records %> - <%== pagy_nav(@pagy, nav_extra: 'flex justify-between') %> + <%== pagy_nav(@pagy) %> <%- if policy(Space).new? %>