-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add numbered pages pagination option #1026
base: main
Are you sure you want to change the base?
Conversation
Is there an opportunity for us to follow the GOV.UK decision here? My spidey sense is that using a list item for the now and next page items, inside a navigation landmark labelled pagination, is misleading (there may be more than 2 pages, its just that only the previous and next ones have been linked to). Further more, if you have numbered pagination with say 3 items, it’ll be announced in a list having 5 items. Which is to say, I think the distinction between those links that appear in a list, and those used for previous and next links, is an important one.
How compatible with the GOV.UK markup would this component be, say if you were using – entirely hypothetically you understand – a GOV.UK-based component library that allowed you to use NHS styles by changing class prefixes from Separately, see #1027; from both wanting visual consistency, and being able to identify the pagination arrows at these smaller sizes, the existing pagination arrows should have open tips. |
Ah sorry, I didn’t explain this well enough. I’ve followed the GOVUK markup for the new 'numbered pages' variant. This means that the numbers are within a What I’ve not done is changed the markup used for the existing 'previous and next links with page titles' variant, which uses this markup in the NHS version: <nav><ul>
<li><a href="#">Previous: page title</a></li>
<li><a href="#">Next: page title</a></li>
</ul></nav> but this in the GOV.UK version: <nav>
<a href="#">Previous: page title</a>
<a href="#">Next: page title</a>
</nav> ( Possibly we should also update this to match the GOV.UK version, but possibly the
Right now the markup for the new numbered pages variant should be mostly compatible except for the SVG for the arrows, which is different. There might also be some other differences in the css names. |
This adds a pagination component to the bottom of the Manage users page, rather than just displaying all users on a single page. The number of users per page is set at 20, although this could be tweaked. The pagination component is not yet part of the NHS design system, so I’ve borrowed the GOV.UK one and applied NHS styling. This is still work-in-progress, and I’m working on contributing this to the NHS design system here: nhsuk/nhsuk-frontend#1026 ## Screenshots ### Manage users | First page | Middle page | Last page | | ------ | ------ | ------ | | ![manage-users-page-1](https://github.com/user-attachments/assets/79f2e200-f771-4327-bc60-e4e30f706d09) | ![manage-users-page-3](https://github.com/user-attachments/assets/635e8a69-72ab-4f93-8fba-623d484cb225) | ![manage-users-page-5](https://github.com/user-attachments/assets/3ba01ff2-3d6d-48be-be78-5e79ec588794) | ### Vaccine batches (on vaccine product page for a given site) ![pagination-of-vaccine-batches](https://github.com/user-attachments/assets/99772ecc-8a09-4300-935f-0c463f6ae7a2) If there are a lot of pages, then ellipsis would be used to show gaps in the sequence, so that the first page, last page, previous and next page are always included: <img width="608" alt="Screenshot 2024-09-23 at 16 09 43" src="https://github.com/user-attachments/assets/500b8dfd-2ecc-4f69-b8a4-3078642a1fbe">
This extends the current Pagination component to support a new variant which is suitable for paging between numbered lists of pages, for example in search results or a long list of patients or appointments.
The variant is based heavily on the GOV.UK Pagination variant, but with a few changes:
#1d70b8
) to NHS.UK blue (#005eb8
)#330072
) instead of the GOV.UK purple (#4c2c92
)#7C2855
) instead of the GOV.UK style which is to have a thicker underline and go slightly darker blue (#003078
) or purpleComparison between GOV.UK numbered pagination and this NHS one
Implementation
The existing Previous and Next variant for the NHS pagination component uses different HTML from the GOV.UK one, for example the NHS one uses a
<ul>
list containing 1 or 2 list items, whereas the GOV.UK one uses<div>
s.To avoid making any breaking changes to the existing pagination component, I’ve left that as-is, including all the existing HTML and CSS classes.
The new numbered variant uses a modifier class of the top-level
<nav>
element (nhsuk-pagination--numbered
) to avoid clashing.Mobile / narrow screens
This needs a bit of thought. The GOV.UK version switches to centre-alignment below a certain width:
...should we copy that? Possibly it switches too early (when there would be space for it to remain on one line).
The GOV.UK variant also drops some of the page numbers on narrow screens:
TODO