Storybook preview
What does this PR do?
Provides a first pass proposal and prototype examples for <Pagination />
.
Demonstrates proof of concept:
- Pagination applied to
<List />
and <DataTable />
<List
data={data}
paginationProps={{
border: { side: 'top', color: 'border' },
show: 6,
step: 15,
pad: { top: 'small' },
}}
/>
<DataTable
columns={columns}
data={[...DATA]}
step={10}
paginationProps={{
margin: { top: 'small' },
pad: { vertical: 'small' },
round: 'xsmall',
step: 4,
}}
/>
- Pagination as a parent which renders its children
<Pagination items={data}>
{item => <Text key={item.entry}>{item.entry}</Text>}
</Pagination>
Proposed API Surface:
export interface PaginationProps {
a11yTitle?: string,
items: number | (string | number | React.ReactElement)[ ], /* Either array of items if called directly, or number of items if called indirectly via another component */
numEdgePages?: number, /* number page indices to display at indices bounds */
numMiddlePages?: number, /* number page indices to display pre/post current page index */
onChange?: function,
page?: number, /* current page */
show?: number, /* initial page index to show, defaultPage? */
showFirst?: boolean, /* show button for jump to first page index */
showLast?: boolean, /* show button for jump to last page index */
step?: number, /* number of items to show per page, itemsPerPage? */
children?: function, /* function to be called when each item is rendered */
boxProps?: BoxTypes, /* any box props */
}
Functionality brainstorm:
For users:
- Should allow user to progress to next step of results
- Should allow user to return to the previous step of results
- Should provide an easy mechanism for the user to jump to the first page of results
- Should provide an easy mechanism for the user to jump to the last page of results
- Should provide an indicator for the total number of pages
- Should provide an indicator for the current page
For callers:
- Should provide simple/minimalistic implementation, but allow for opt-in added functionality
- Should be able to paginate the following layouts / visualizations:
- Grid of results
- List of results
- Rows in a Table (?)
- Rows in a DataTable
- Others? (e.g. Drop?)
- Should allow caller to specify the number of items per page
- Should automatically calculate the number of pages so the caller does not have to
- Should allow the caller to call directly (?)
- Should allow caller to provide an array of items
- Should allow caller to specify how each item is rendered
- Should allow the caller to use Pagination indirectly via other components such as List, Table (?), DataTable, and Grid.
- Should allow the caller to specify Pagination props via the calling component
TODOs:
- Gather feedback on interface and approach
- Documentation
- Unit tests
- Stories
Where should the reviewer start?
Pagination.js & Pagination stories
What testing has been done on this PR?
Storybook
TODOS:
- Unit tests & snapshots
- Clean up and elaborate stories
How should this be manually tested?
Storybook
Any background context you want to provide?
What are the relevant issues?
https://github.com/grommet/grommet/issues/4617
https://github.com/grommet/grommet/issues/4647
Screenshots (if appropriate)
Do the grommet docs need to be updated?
Eventually.
Should this PR be mentioned in the release notes?
Eventually.
Is this change backwards compatible or is it a breaking change?