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

feat(DataTable): add support for pagination #3199

Merged
merged 20 commits into from
Apr 27, 2023

Conversation

joshblack
Copy link
Member

@joshblack joshblack commented Apr 19, 2023

Batch https://github.com/github/primer/issues/1890

Add support for pagination within a DataTable. This adds in a Table.Pagination component along with a storybook story to demonstrate the behavior, presentation, and semantics of pagination alongside a table. This PR does not include support for loading or error states; these will be added in a follow-up PR.

Loom walkthrough of the behavior and changes here: https://www.loom.com/share/b2b67e2102074c55a86b2617860639fc

Changelog

New

  • Add Table.Pagination and corresponding storybook story
  • Add internal components
    • ButtonReset
    • LiveRegion, LiveRegionOutlet, and Message
    • VisuallyHidden

@changeset-bot
Copy link

changeset-bot bot commented Apr 19, 2023

🦋 Changeset detected

Latest commit: d401d8a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/react Minor

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

@github-actions
Copy link
Contributor

github-actions bot commented Apr 19, 2023

size-limit report 📦

Path Size
dist/browser.esm.js 121.18 KB (0%)
dist/browser.umd.js 121.47 KB (0%)

@joshblack joshblack temporarily deployed to github-pages April 19, 2023 22:27 — with GitHub Actions Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-3199 April 19, 2023 22:27 Inactive
@joshblack joshblack temporarily deployed to github-pages April 20, 2023 16:39 — with GitHub Actions Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-3199 April 20, 2023 16:39 Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-3199 April 20, 2023 17:58 Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-3199 April 20, 2023 18:00 Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-3199 April 20, 2023 18:01 Inactive
@joshblack joshblack temporarily deployed to github-pages April 20, 2023 18:03 — with GitHub Actions Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-3199 April 20, 2023 18:03 Inactive
@joshblack joshblack temporarily deployed to github-pages April 20, 2023 20:01 — with GitHub Actions Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-3199 April 20, 2023 20:02 Inactive
@joshblack joshblack temporarily deployed to github-pages April 21, 2023 14:56 — with GitHub Actions Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-3199 April 21, 2023 14:56 Inactive
@joshblack joshblack added skip changeset This change does not need a changelog and removed skip changeset This change does not need a changelog labels Apr 25, 2023
@joshblack joshblack requested a review from a team April 25, 2023 18:58
@github-actions github-actions bot temporarily deployed to storybook-preview-3199 April 25, 2023 18:59 Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-3199 April 25, 2023 19:01 Inactive
@joshblack joshblack temporarily deployed to github-pages April 25, 2023 19:04 — with GitHub Actions Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-3199 April 25, 2023 19:04 Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-3199 April 25, 2023 19:05 Inactive
@joshblack joshblack temporarily deployed to github-pages April 26, 2023 15:29 — with GitHub Actions Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-3199 April 26, 2023 15:30 Inactive
@joshblack joshblack temporarily deployed to github-pages April 26, 2023 17:39 — with GitHub Actions Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-3199 April 26, 2023 17:40 Inactive
Copy link
Contributor

@colebemis colebemis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work on this, @joshblack! Excited for async behavior next ✨

selectPage,
selectNextPage,
selectPreviousPage,
} = usePagination({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love how this simplifies the Pagination component ❤️

return context
}

function LiveRegion({children}: React.PropsWithChildren) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excited about LiveRegion! Can't wait to use this in TreeView

)
}

function Message({value}: {value: string}) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a declarative API for making announcements?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@colebemis exactly, still trying to see if it works the way we anticipate 😅 Thankfully everything announces as-intended right now but a little worried about the declarative API translating to side-effects with announcements.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love it!!

Copy link
Contributor

@mperrotti mperrotti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great! I had a few comments, but nothing worth blocking the PR over.

@@ -0,0 +1,478 @@
import {ChevronLeftIcon, ChevronRightIcon} from '@primer/octicons-react'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little worried about keeping this1 in sync with our exported Pagination component.

Do you think it makes sense to do either of these?

  • Introduce a new pagination component for use-cases like these
  • Do a follow up PR where we update our existing Pagination component to have some of the features you've added here

Footnotes

  1. I'm only talking about the page numbers and prev/next buttons. I don't think we have other needs for the "1-10 of 1000" bit yet.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I definitely think there is something there where we could merge the two components, in particular to share appearance and behavior. It'd be great if we could figure out how to allow customization of the inner pages to allow for the different navigation use-cases (button vs a). I have no idea how to expose this kind of stuff to an end user without coming up with some kind of naming scheme between the two though 🤔

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we create an issue to figure this out? Want to discuss it during the next Primer patterns working session?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely! Made one over at: https://github.com/github/primer/issues/2164 feel free to add to it if I missed anything 👀

src/DataTable/Pagination.tsx Show resolved Hide resolved
src/internal/components/VisuallyHidden.tsx Show resolved Hide resolved
src/internal/components/VisuallyHidden.tsx Show resolved Hide resolved
@joshblack joshblack temporarily deployed to github-pages April 26, 2023 21:19 — with GitHub Actions Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-3199 April 26, 2023 21:19 Inactive
@joshblack joshblack temporarily deployed to github-pages April 27, 2023 15:08 — with GitHub Actions Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-3199 April 27, 2023 15:08 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants