Skip to content
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

Components: Add Pagination component #55650

Open
t-hamano opened this issue Oct 26, 2023 · 0 comments
Open

Components: Add Pagination component #55650

t-hamano opened this issue Oct 26, 2023 · 0 comments
Labels
[Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Package] Components /packages/components [Type] Enhancement A suggestion for improvement.

Comments

@t-hamano
Copy link
Contributor

t-hamano commented Oct 26, 2023

What problem does this address?

The current Gutenberg project uses pagination in several places.

These paginations are built uniquely in each location, but I imagine they could be implemented as a common component. In other words, it is a component similar to the_posts_pagination() function.

What is your proposed solution?

If we mimic the output of the_posts_pagination(), it will probably look something like this:

buttons-pagination

Apart from this, we may also need a type that allows you to enter the page number in a text box:

of-pagination

I'm imagining the following usage, for example:

import { Pagination } from '@wordpress/components';

function MyComponent() {
	const [ currentPage, setCurrentPage ] = useState( 1 );
	return (
		<div className="my-pagination">
			<Pagination
				total="10"
				current={ currentPage }
				midSize="3"
				prevText="Previous page"
				nextText="Next page"
				type="list"
				hasPageInput
				isSmall
				onChange={ ( newPage ) => setCurrentPage( newPage ) }
			/>
		</div>
	);
}

Screenshots

Below is the pagination that I was able to find. In addition to this, pagination may also be implemented for revisions, as seen in #53621.

Patterns Inserter

patterns-inserter

Pattern Page

patterns

Data View

data-view

@t-hamano t-hamano added [Type] Enhancement A suggestion for improvement. [Package] Components /packages/components labels Oct 26, 2023
@afercia afercia added the [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). label Jun 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Package] Components /packages/components [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

2 participants