From baac6c14ce607bd35b9194c94f6fd722ef4e6dce Mon Sep 17 00:00:00 2001 From: Matt Simon Date: Wed, 1 Feb 2023 13:56:05 +0000 Subject: [PATCH 01/18] Change concatenation method to be compatible with jinja2 --- src/components/pagination/_macro.njk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/pagination/_macro.njk b/src/components/pagination/_macro.njk index 5376a4098a..3e545fa6ee 100644 --- a/src/components/pagination/_macro.njk +++ b/src/components/pagination/_macro.njk @@ -7,7 +7,7 @@ {% endfor %} {% set totalPages = params.pages | length %} - {% set position = "Page " + currentPageIndex + " of " + totalPages %} + {% set position = "Page " ~ currentPageIndex ~ " of " ~ totalPages %} {% set lastPage = params.pages | last %} {% set firstPage = params.pages | first %} From 5949eaa2a487768ab9bd3377dd9325b644bb817b Mon Sep 17 00:00:00 2001 From: Precious Onyenaucheya Date: Thu, 18 May 2023 10:49:17 +0100 Subject: [PATCH 02/18] make component compatible with jinja --- src/components/pagination/_macro.njk | 136 +++++++++++++-------------- 1 file changed, 68 insertions(+), 68 deletions(-) diff --git a/src/components/pagination/_macro.njk b/src/components/pagination/_macro.njk index 3e545fa6ee..389f55de3b 100644 --- a/src/components/pagination/_macro.njk +++ b/src/components/pagination/_macro.njk @@ -1,72 +1,72 @@ {% macro onsPagination(params) %} - {% set currentPageIndex = "" %} - {% for page in params.pages %} - {% if page.current %} - {% set currentPageIndex = loop.index %} - {% endif %} - {% endfor %} + {% set currentPageIndex = "" %} + {% for page in params.pages %} + {% if page.current %} + {% set currentPageIndex = loop.index %} + {% endif %} + {% endfor %} - {% set totalPages = params.pages | length %} - {% set position = "Page " ~ currentPageIndex ~ " of " ~ totalPages %} - {% set lastPage = params.pages | last %} - {% set firstPage = params.pages | first %} + {% set totalPages = params.pages | length %} + {% set position = "Page " ~ currentPageIndex ~ " of " ~ totalPages %} + {% set lastPage = params.pages | last %} + {% set firstPage = params.pages | first %} - + {% endmacro %} From d85c52d996288f6d5a42fcdb91e54e4198929e93 Mon Sep 17 00:00:00 2001 From: Precious Onyenaucheya Date: Fri, 9 Jun 2023 10:40:37 +0100 Subject: [PATCH 03/18] refactor pagination --- src/components/pagination/_macro-options.md | 8 +-- src/components/pagination/_macro.njk | 18 ++--- .../pagination/example-pagination-first.njk | 4 +- .../pagination/example-pagination-last.njk | 4 +- ...ple-pagination-with-no-range-indicator.njk | 4 +- .../pagination/example-pagination.njk | 72 +++++++++---------- 6 files changed, 53 insertions(+), 57 deletions(-) diff --git a/src/components/pagination/_macro-options.md b/src/components/pagination/_macro-options.md index 714ebd41a3..f7ef495dc3 100644 --- a/src/components/pagination/_macro-options.md +++ b/src/components/pagination/_macro-options.md @@ -5,10 +5,10 @@ | next | string | true | Text label for the “Next” link | | classes | string | false | Classes to add to the pagination HTML `nav` element | | hideRangeIndicator | boolean | false | Set to “true” to hide the range indicator on viewports ≥ 740px | +| currentPageNumber | integer | true | Sets the current page number | ## Page -| Name | Type | Required | Description | -| ------- | ------- | -------- | ------------------------------------------------------- | -| url | string | true | The URL for the HTML `href` attribute for the page link | -| current | boolean | false | Set to “true” for the current loaded page link | +| Name | Type | Required | Description | +| ---- | ------ | -------- | ------------------------------------------------------- | +| url | string | true | The URL for the HTML `href` attribute for the page link | diff --git a/src/components/pagination/_macro.njk b/src/components/pagination/_macro.njk index 389f55de3b..f792624da1 100644 --- a/src/components/pagination/_macro.njk +++ b/src/components/pagination/_macro.njk @@ -1,15 +1,11 @@ {% macro onsPagination(params) %} - {% set currentPageIndex = "" %} - {% for page in params.pages %} - {% if page.current %} - {% set currentPageIndex = loop.index %} - {% endif %} - {% endfor %} - + {% set currentPageIndex = params.currentPageNumber %} {% set totalPages = params.pages | length %} {% set position = "Page " ~ currentPageIndex ~ " of " ~ totalPages %} {% set lastPage = params.pages | last %} {% set firstPage = params.pages | first %} + {% set prevPageIndex = currentPageIndex - 1 %} + {% set nextPageIndex = currentPageIndex + 1 %}