Skip to content

Commit

Permalink
Make Pagy use the legacy nav bar
Browse files Browse the repository at this point in the history
Pagy has deprecated the size array format and replaced it with an
integer. This is more sensible but doesn't fit in with the GOV.UK Design
System's guidance that says:

> For smaller screens, show page numbers for:
>
> * the current page
> * previous and next pages
> * first and last pages
>
> For larger screens, show page numbers for:
>
> * the current page
> * at least one page immediately before and after the current page
> * first and last pages

The numeric size doesn't provide quite enough control over what's
displayed before/after the current page.

As a result we have to enable the Size Extra[0] functionality, which
allows us to use the old implementation.

Also, Pagy has replaced the items param with limit[1], so the specs have
been updated accordingly.

[0] https://ddnexus.github.io/pagy/docs/extras/size/
[1] https://ddnexus.github.io/pagy/changelog/#version-900
  • Loading branch information
peteryates committed Aug 13, 2024
1 parent a220959 commit 57465fd
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion guide/lib/examples/pagination_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def pagination_lots_of_pages

def pagination_lots_of_pages_data
<<~PAGINATION_DATA
{ pagy: Pagy.new(count: 100, page: 9, size: [1, 1, 1, 1], items: 5) }
{ pagy: Pagy.new(count: 100, page: 9, size: [1, 1, 1, 1], limit: 5) }
PAGINATION_DATA
end

Expand Down
1 change: 1 addition & 0 deletions lib/govuk/components.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
require "govuk/components/engine"
require "html_attributes_utils"
require "pagy"
require "pagy/extras/size"
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'spec_helper'

RSpec.describe(GovukComponent::PaginationComponent, type: :component) do
let(:pagy) { Pagy.new(page: 2, count: 20, items: 5, size: [1, 1, 1, 1]) }
let(:pagy) { Pagy.new(page: 2, count: 20, limit: 5, size: [1, 1, 1, 1]) }
let(:kwargs) { { pagy: } }

describe "configuration" do
Expand Down
4 changes: 2 additions & 2 deletions spec/components/govuk_component/pagination_component_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

RSpec.describe(GovukComponent::PaginationComponent, type: :component) do
let(:count) { 30 }
let(:items) { 5 }
let(:limit) { 5 }
let(:size) { [1, 2, 2, 1] }
let(:defaults) { { count:, items:, size: } }
let(:defaults) { { count:, limit:, size: } }
let(:current_page) { 2 }
let(:pagy) { Pagy.new(page: current_page, **defaults) }
let(:component_css_class) { 'govuk-pagination' }
Expand Down

0 comments on commit 57465fd

Please sign in to comment.