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? %>