Skip to content

Commit

Permalink
replace push method with append
Browse files Browse the repository at this point in the history
  • Loading branch information
“BogdanDanilescu” committed Nov 28, 2024
1 parent 7bf3b69 commit 6c00bca
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
4 changes: 4 additions & 0 deletions examples/wagtail/core/jinja/home_page.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
{% from 'combo-box/combo-box.html' import govieComboBox %}
{% from 'alert/alert.html' import govieAlert %}
{% from 'toast/toast.html' import govieToast %}
{% from 'pagination/pagination.html' import goviePagination %}

{% from 'vars.jinja' import comboBoxProps, cookieBannerProps, modalProps, footerProps, HeaderProps, SelectProps, tabsProps, radioProps, listProps %}

Expand Down Expand Up @@ -224,6 +225,9 @@
"title": "Info Alert",
"children": "<div>Content</div>"
}) }}

<h2>Pagination</h2>
{{ goviePagination({'totalPages': 10, 'currentPage': 5}) }}

<h2>Footer (Local)</h2>
<footer class="govie-footer"></footer>
Expand Down
20 changes: 10 additions & 10 deletions packages/html/ds/src/pagination/pagination.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,25 +60,25 @@
{%- set display_pages = [1] -%}

{% if props.currentPage > 2 %}
{% set display_pages = (display_pages.push(-1), display_pages) %}
{% set temp = display_pages.append(-1) %}
{% endif %}

{% if props.currentPage > 1 and props.currentPage < props.totalPages %}
{% set display_pages = (display_pages.push(props.currentPage), display_pages) %}
{% set temp = display_pages.append(props.currentPage) %}
{% endif %}

{% if props.currentPage < props.totalPages - 1 %}
{% set display_pages = (display_pages.push(-2), display_pages) %}
{% set temp = display_pages.append(-2) %}
{% endif %}

{% if props.totalPages > 1 %}
{% set display_pages = (display_pages.push(props.totalPages), display_pages) %}
{% set temp = display_pages.append(props.totalPages) %}
{% endif %}

{% if props.totalPages <= 3 %}
{% set display_pages = [] %}
{% for index in range(1, props.totalPages + 1) %}
{% set display_pages = (display_pages.push(index), display_pages) %}
{% set temp = display_pages.append(index) %}
{% endfor %}
{% endif %}

Expand Down Expand Up @@ -113,25 +113,25 @@
{%- set display_pages = [] -%}

{% if props.currentPage > 3 %}
{% set display_pages = (display_pages.push(1), display_pages) %}
{% set temp = display_pages.append(1) %}
{% endif %}

{% if props.currentPage > 4 %}
{% set display_pages = (display_pages.push(-1), display_pages) %}
{% set temp = display_pages.append(-1) %}
{% endif %}

{% for index in range(props.currentPage - 2, props.currentPage + 3) %}
{% if index >= 1 and index <= props.totalPages %}
{% set display_pages = (display_pages.push(index), display_pages) %}
{% set temp = display_pages.append(index) %}
{% endif %}
{% endfor %}

{% if props.currentPage < props.totalPages - 3 %}
{% set display_pages = (display_pages.push(-2), display_pages) %}
{% set temp = display_pages.append(-2) %}
{% endif %}

{% if props.currentPage < props.totalPages - 2 %}
{% set display_pages = (display_pages.push(props.totalPages), display_pages) %}
{% set temp = display_pages.append(props.totalPages) %}
{% endif %}

<div class="md:gi-flex gi-items-center gi-justify-between gi-gap-2 gi-hidden">
Expand Down

0 comments on commit 6c00bca

Please sign in to comment.