Background
Pagination is an optional feature of the Table component that can be added to the footer section when needed. We will provide a standard pagination UI built into the Table component, but dev users could add their own in the footer slot if desired. This task covers implementation of the standard Table pagination.
The pagination UI will consist of the following elements:
- Items per page selector
- Number of items indicator (optional; not recommended for large datasets)
- Page arrows
User story
As a user, I want to be able to look through data in an efficient, readable way
As a developer, I want to improve performance by fetching and displaying small portions of data at once
Design spec
Guidelines
Open questions
- Can the number of rows in the Select to be customizable by whoever is implementing the table?
- Yes, this should be customizable. A default set will exist in the Table component, but it can be overridden.
- Are there performance concerns at a certain level of rows? e.g. Should we enforce a max?
- When fetching data from the MediaWiki API, a limit of 50 items is enforced, so 50 seems like a sensible limit.
- Is it possible to only show the text "rows" once, for the selected amount so we don't repeat it for every option?
- Yes, this is possible with our Select component.
- Can the usage of this pagination be optional?
- Yes - users will be able to turn on the default pagination we build into the Table component, or add their own custom pagination using the Table component's #footer slot.
API and UI details
API
Part of the implementation work of this task will be to determine how to enable, control, and respond to pagination. See Vuetify's data table for an example. The parent component will need to know which items to show at a given time, and when to fetch/provide new rows to show when the user interacts with the pagination.
All user-facing strings will need to come from props with a default English value, including:
- aria-label for the items per page selector
- "rows" label in the items per page selector
- "all" option label in the items per page selector
- "X-Y of Z items" in the number of items indicator
- aria-labels for all of the icon-only navigation buttons
Positioning
Pagination will be displayed at the bottom as default, while the top pagination could be optionally included.
Items per page selector
- The selected option will have word "rows" after it when displayed in the Select handle
- The default set of options will be 10, 20, and 50. This can be overridden via a prop.
- The default option will be 10
- Optional improvement (could be done as a separate task later): If the total number of items has been passed in (to show the number of items indicator), and one of the options doesn't makes sense, that option should not be shown. For example, if there are 18 total items, the "50" option should not be shown because "20" already shows all items.
Number of items indicator
- Will be displayed if the dev user provides the total number of items in the dataset
- Otherwise, it will not be displayed
- Will be hidden on small screens to save space
- Ensure the default example uses an en-dash e.g. "X–Y of Z items"
Page arrows
- Need aria-labels for accessibility
- On the first page, the first and previous buttons should be disabled. Same for the last and next buttons on the last page.
Acceptance criteria (or Done)
Design
- Design the Figma spec sheet and add it in this task
- Update the component in the Figma library. This step will be done by a DST member.
- Document the Guidelines for this Table's pagination and include them in the Table's guidelines in Codex
Code
- Implement the component in Codex