Closed shadyvb closed 2 years ago
Adding some additional Acceptance Criteria:
Some examples based on having 250 total pages:
1 2 3 4 ... 250 next >
< prev 1 2 3 4 5 6 7 ... 250 next >
< prev 1 ... 9 10 11 12 13 14 15 ... 250 next >
< prev 1 ... 246 247 248 249 250 next >
< prev 1 ... 247 248 249 250
Hope that makes sense - please feel free to suggest any changes / improvements.
FYI, WordPress has a paginate_links
helper you can use:
$page_links = paginate_links( array(
'base' => 'base_url?paged=%#%',
'format' => '',
'prev_text' => $args['prev_text'],
'next_text' => $args['next_text'],
'total' => $number_pages,
'current' => $current_page,
'mid_size' => $mid_size,
'end_size' => 1,
'show_all' => $args['show_all'],
'type' => 'array'
) );
Does it have a similar thing for React?
Maybe we can grab one these components:
Or just roll our own.
In a use case where a user has 200+ pages on their site. Pagination will start "1 2 3 4 ... 398 399 400" for example. If the user was needing to navigate to page 150, they would need to click through roughly 147 times until they can click page 150, having an option for a user to select a page or input a page number to navigate to quickly be useful.
In Posts in WordPress you can navigate to the previous/next, first/last or specify a page number to navigate too.
I have come across https://www.npmjs.com/package/react-pagination-bar which has some options too, as well as an option for an input to navigate to a specific page : https://react-pagination-bar.vercel.app/
@robindevitt good shout, the default WP pagination is like this so I think it's good to add the option with a go to input. Do you want to update the acceptance criteria?
Looking through the two packages, trust the one package to have functionality that the other one doesn't.
react-pagination-bar has the the input functionality but doesn't offer the option to have 1 2 3 4 ... 250
with the ellipses in-between, so I'm going to see if I can find a package that contains both options/possibilities.
@roborourke I'm leaning towards using a package to get this done as at the moment it's a single use case. If we were using it multiple times over then I would say to develop our own pagination component.
rc-pagination - Ticks all the boxes, unpacked size 157 kB
react-pagination-bar - Doesn't tick all the boxes is the sense of that it doesn't have an option to show pagination like - 1 2 3 4 ... 250
. However its unpacked size is 72.6 kB.
I think implementing rc-pagination
based on acceptance criteria would be good start unless we would want a smaller package and compromise on acceptance criteria?
Your reasoning for using an existing package makes sense to me 👍
The ellipsis is just a common pattern but I wouldn't get too hung up on it if it's clear that there are more pages after the visible ones.
I'd more inclined to use the lighter weight solution and compromise a bit as you note.
Merged and closed by PR 372
Steps to reproduce:
Pagination links container should be wrapped.
Acceptance criteria:
It was noted that adding
flex-wrap:wrap;
to the container should help fix the bug.