-
Notifications
You must be signed in to change notification settings - Fork 545
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
Make the showPages
prop on our Pagination components responsive
#3390
Conversation
🦋 Changeset detectedLatest commit: 34bc0c8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
size-limit report 📦
|
…r/react into mp/pagination-responsive-showpages
…r/react into mp/pagination-responsive-showpages
@mperrotti sorry for the delay on this! Just wanted to ask if this is something that could be built-in, e.g. the steps are always hidden at narrow and become visible at larger breakpoints, or if |
@joshblack - instead of building it in, I wanted to give users the option to change the value for different viewport sizes. For example, I might be using pagination in a narrow sidebar on wide screens, so I'd want to set |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the stuff from container queries figured moving forward with option 2 works like you suggested would work! Just had one question on the implementation, curious what you think 👀
src/DataTable/Pagination.tsx
Outdated
@@ -202,7 +238,7 @@ export function Pagination({ | |||
</Button> | |||
</Step> | |||
{pageCount > 0 ? ( | |||
<Step> | |||
<Step hiddenViewportRanges={getViewportRangesToHidePages()}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the hiddenViewportRanges
prop something that can be placed on TablePaginationSteps
? Would be great to calculate this once and place it on the outermost node and then target it e.g.
@media ${viewportRanges.narrow} {
.TablePaginationSteps[data-hidden-viewport-ranges*='narrow'] > *:not(:first-child):not(:last-child) {
display: none;
}
.TablePaginationSteps[data-hidden-viewport-ranges*='narrow'] > *:first-child {
margin-inline-end: 0;
}
}
If not, I think this is something we should calculate once instead of as a function and just pass its value to each Step
instead of messing around with useCallback()
and calling it for each step.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh good catch! Ok, I'll refactor 👍
…ponsive-showpages
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🥳
The
showPages
prop on both Pagination components can now accept a responsive value.Closes #2773
Screenshots
Kapture.2023-06-07.at.16.56.12.mp4
Merge checklist
Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.