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/TablePagination - Table with Pagination #1353

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

dhavalveera
Copy link
Contributor

@dhavalveera dhavalveera commented Apr 8, 2024

#1318

this PR adds the Pagination Component to the Table.

Summary by CodeRabbit

  • New Features
    • Introduced pagination for the <Table> component to efficiently manage and navigate through large data sets. Users can now choose between numbered page navigation or Prev/Next buttons for easier data exploration.

Copy link

changeset-bot bot commented Apr 8, 2024

⚠️ No Changeset found

Latest commit: cecd43a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Apr 8, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
flowbite-react ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 8, 2024 8:52am
flowbite-react-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 8, 2024 8:52am

Copy link
Contributor

coderabbitai bot commented Apr 8, 2024

Warning

Rate Limit Exceeded

@dhavalveera has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 8 minutes and 3 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.
Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.
Please see our FAQ for further information.

Commits Files that changed from the base of the PR and between 915d52c and cecd43a.

Walkthrough

This update introduces pagination functionality to the <Table> React component, enhancing its capability to manage and navigate through larger data sets efficiently. Users can now paginate data using either numbered navigation or Prev/Next buttons, improving the component's usability for displaying product information across multiple pages.

Changes

Files Change Summaries
.../docs/components/table.mdx Added pagination functionality for <Table>, including number-based and Prev/Next button navigation.
.../examples/table/index.ts Exported pagination functionality.
.../examples/table/table.pagination.tsx Introduced a pagination feature for the table component to navigate through data pages.

Possibly related issues

🐰✨
In the realm of code where tables extend,
A rabbit hopped, a feature to amend.
With pages numbered, or buttons to press,
Navigating data, no longer a mess.
📚🔢🐾
So hop along, through data vast,
With pagination, a blast from the past!
🎉🐰

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 749734e and 8d319aa.
Files selected for processing (5)
  • packages/ui/src/components/Table/Table.stories.tsx (2 hunks)
  • packages/ui/src/components/Table/Table.tsx (2 hunks)
  • packages/ui/src/components/Table/TablePagination.tsx (1 hunks)
  • packages/ui/src/components/Table/index.ts (1 hunks)
  • packages/ui/src/components/Table/theme.ts (1 hunks)
Additional comments not posted (9)
packages/ui/src/components/Table/index.ts (1)

13-14: The export statements for TablePagination and its related type definitions are correctly implemented and follow the existing pattern for component exports in the library.

packages/ui/src/components/Table/Table.tsx (3)

13-13: Correctly imported TablePagination and its theme, ensuring the new pagination functionality is integrated with the Table component.


21-21: Successfully updated the FlowbiteTableTheme interface to include pagination settings, enhancing the theme's flexibility and supporting the new pagination feature.


61-61: Integration of TablePagination into the Table component's export object is correctly done, making it accessible as a sub-component.

packages/ui/src/components/Table/theme.ts (1)

27-42: The added styles for pagination elements are well-defined and consistent with the library's design system. This ensures a seamless user experience and maintainability of the theme.

packages/ui/src/components/Table/TablePagination.tsx (3)

9-22: The FlowbiteTablePaginationTheme interface is well-defined, covering all necessary styling aspects for the pagination component.


24-30: The TablePaginationProps interface correctly defines the props needed for pagination functionality, ensuring a flexible and customizable component.


32-107: The pagination logic within TablePagination is implemented correctly, with clear handling of page changes and appropriate accessibility considerations. However, consider adding a brief comment explaining the logic behind getLabelDisplayedRowsTo for future maintainability.

Consider adding a brief comment explaining the logic behind getLabelDisplayedRowsTo function for better code readability and maintainability.

packages/ui/src/components/Table/Table.stories.tsx (1)

91-183: The storybook implementation for the Table component with pagination functionality is correctly done, showcasing the new feature effectively. The state management for page number and rows per page, along with the page change handling, are implemented properly.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 8d319aa and 84246cc.
Files selected for processing (3)
  • apps/web/content/docs/components/table.mdx (1 hunks)
  • apps/web/examples/table/index.ts (1 hunks)
  • apps/web/examples/table/table.pagination.tsx (1 hunks)
Additional comments not posted (6)
apps/web/examples/table/index.ts (1)

2-2: Export statement for pagination is correctly added and follows the naming convention of the project.

apps/web/content/docs/components/table.mdx (1)

34-38: The documentation for "Table with Pagination" is clear and effectively explains the new feature. It's a valuable addition for users needing guidance on handling larger data sets.

apps/web/examples/table/table.pagination.tsx (4)

1-2: Import statements are correctly organized and necessary for the component's functionality.


5-98: The example component demonstrates the TablePagination component's usage effectively, using React hooks for state management and handling page changes.


95-95: Pagination logic using the TablePagination component is straightforward and efficiently manages the pagination state.


190-201: The export of the pagination object is correctly structured for use in documentation or examples, with appropriate properties set.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 84246cc and 12c00f5.
Files selected for processing (1)
  • apps/web/examples/table/table.pagination.tsx (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • apps/web/examples/table/table.pagination.tsx

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 12c00f5 and 708b363.
Files selected for processing (6)
  • apps/web/content/docs/components/table.mdx (1 hunks)
  • apps/web/examples/table/index.ts (1 hunks)
  • apps/web/examples/table/table.paginationButton.tsx (1 hunks)
  • apps/web/examples/table/table.paginationNumber.tsx (1 hunks)
  • packages/ui/src/components/Table/Table.stories.tsx (2 hunks)
  • packages/ui/src/components/Table/TablePagination.tsx (1 hunks)
Files skipped from review as they are similar to previous changes (3)
  • apps/web/examples/table/index.ts
  • packages/ui/src/components/Table/Table.stories.tsx
  • packages/ui/src/components/Table/TablePagination.tsx
Additional comments not posted (3)
apps/web/content/docs/components/table.mdx (1)

34-44: The documentation for the new pagination features is clear and well-integrated with the existing content. Great job on providing concise and informative examples for both number-based and Prev/Next button-based pagination.

apps/web/examples/table/table.paginationNumber.tsx (1)

1-209: The example implementation for number-based pagination in a table is correctly done, demonstrating the usage of state management and pagination controls effectively. For real-world applications, consider replacing the hardcoded sample data with dynamic data sources.

apps/web/examples/table/table.paginationButton.tsx (1)

1-209: The example implementation for Prev/Next button-based pagination in a table is correctly done, showing how to effectively use pagination controls with a different pagination type. As with the number-based pagination example, consider using dynamic data sources for real-world applications.

@SutuSebastian
Copy link
Collaborator

on dark theme it has no active item
Screenshot 2024-04-08 at 11 18 30

@dhavalveera
Copy link
Contributor Author

on dark theme it has no active item Screenshot 2024-04-08 at 11 18 30

Okay!. I'll check and update it. Thanks for point it out..

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 708b363 and 63774cf.
Files selected for processing (2)
  • packages/ui/src/components/Table/TablePagination.tsx (1 hunks)
  • packages/ui/src/components/Table/theme.ts (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • packages/ui/src/components/Table/TablePagination.tsx
  • packages/ui/src/components/Table/theme.ts

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 63774cf and c9ec929.
Files selected for processing (3)
  • apps/web/content/docs/components/table.mdx (1 hunks)
  • apps/web/examples/table/index.ts (1 hunks)
  • apps/web/examples/table/table.pagination.tsx (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • apps/web/examples/table/index.ts
  • apps/web/examples/table/table.pagination.tsx
Additional comments not posted (1)
apps/web/content/docs/components/table.mdx (1)

34-39: Consider enhancing the "Table with Pagination" section by detailing the specific props used for pagination. This addition would provide clearer guidance to developers on how to implement pagination with the <Table> component.

apps/web/content/docs/components/table.mdx Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Actionable comments outside the diff hunks (1)
apps/web/content/docs/components/table.mdx (1)

Line range hint 18-18: Please ensure there are spaces between sentences for better readability.

- ...ent and the children components such as `<Table.Head>`, `<Table.Body>`, `<Table.Row>` and `<Table.Cell>`.
+ ...ent and the children components such as `<Table.Head>`, `<Table.Body>`, `<Table.Row>` and `<Table.Cell>`. 
Review Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between c9ec929 and 915d52c.
Files selected for processing (1)
  • apps/web/content/docs/components/table.mdx (1 hunks)
Additional comments not posted (1)
apps/web/content/docs/components/table.mdx (1)

34-38: The addition of the Table with Pagination section is clear and well-integrated into the document. It effectively communicates the new functionality.

@dhavalveera
Copy link
Contributor Author

@SutuSebastian Sir, one question though it arises in my mind is like, in the current Pagination component, we're limiting the size to 5 without allowing or giving an option to the User, that whether they need to show more or not on the single page by-default. e.g. by-default I want to show 10 rows per Page, but with the current Pagination it's restricted or can say it isn't allowed, then I guess we need to modify the Pagination to allow the User to pass an arbitrary value that how many rows/result they want to show on a single page instead of not allowing them to modify this behavior.

Please share your @SutuSebastian inputs & feedbacks on this, and if this makes a valid point, then I would be happy to go ahead and make this necessary changes.

@SutuSebastian
Copy link
Collaborator

@dhavalveera totally agreed. Lets fix and extend the pagination component properly and make it production ready once in for all.

The current state is broken.

@SutuSebastian
Copy link
Collaborator

While u're at it, investigate how a pagination component should work and the flexibility of it, and try to make a controller for it (a hook) and expose that as well, for the headless approach

@dhavalveera
Copy link
Contributor Author

@dhavalveera totally agreed. Lets fix and extend the pagination component properly and make it production ready once in for all.

The current state is broken.

For this one, I'll dig into the existing Pagination Component and we check it out how I can extend one to fix it and it production ready.

@dhavalveera
Copy link
Contributor Author

dhavalveera commented Apr 9, 2024

While u're at it, investigate how a pagination component should work and the flexibility of it, and try to make a controller for it (a hook) and expose that as well, for the headless approach

while working with Table.Pagination Component I understood a little bit is like we need to provide different kind of Pagination to the Users as like below:

  1. Next / Previous Button
  2. Next/Previous Button with Numbers in between if they want that as way
  3. one more possible option could be something like a dropdown menu thing where there're possibilities => 1. a Dropdown Menu with predefined options if not passed by User or with the list Users want. and along with it Left/Right Icon for Prev/Next
  4. then Pagination for Numbers with Square/Circle as an Border & maybe different colors.
  5. Input Field for allowing to enter Custom Page Number.

those are some possibilities I came across for the Pagination Components.

Furthermore @SutuSebastian -- above suggestions & possibilities I came across for the Pagination components aren't implemented in the Flowbite's Core Package, so how we can proceed it with flowbite-react?

@SutuSebastian please share your feedback & input on this.

@dhavalveera
Copy link
Contributor Author

@SutuSebastian - can you please review?

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.

None yet

2 participants