Skip to content

Fix: Improved first last buttons behavior in pagination component #364

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

Merged
merged 3 commits into from
May 6, 2025

Conversation

andreyjamer
Copy link
Contributor

@andreyjamer andreyjamer commented Apr 1, 2025

Current implementation is lacking slot properties and doesn't check if icons are enabled for the component for first/last buttons.
Also internally slots check is wrong.

Added first last buttons example to documentation

Summary by CodeRabbit

  • Documentation
    • Updated the pagination guides with new sections demonstrating first and last page navigation and advanced customization using slots.
  • New Features
    • Added first and last page buttons to pagination controls with options for large size and icon display.
    • Introduced advanced slot-based customization for pagination buttons, enabling tailored styling and behavior.

Improved dealing with custom templates in the component
Copy link
Contributor

coderabbitai bot commented Apr 1, 2025

Walkthrough

This pull request adds a new section to the pagination documentation demonstrating the "first" and "last" page navigation. A new Vue component (FwbPaginationExampleFirstLast.vue) is introduced to serve as an example of the enhanced FwbPagination capabilities. The component showcases three variations of the pagination feature with different props. Additionally, the FwbPagination.vue component is updated to conditionally render optional first, previous, page, next, and last button slots (and their icons) based on new properties and slot availability.

Changes

File(s) Change Summary
docs/components/pagination.md
docs/components/pagination/examples/FwbPaginationExampleFirstLast.vue
docs/components/pagination/examples/FwbPaginationExampleSlotsAdvanced.vue
docs/components/pagination/examples/FwbPaginationExampleSlots.vue
Added new documentation sections "First and last" and "Advanced slots example" with usage examples of the pagination component using the enable-first-last prop and advanced slot customization. Introduced two new example components demonstrating these features and updated an existing example to include first and last icons.
src/components/FwbPagination/FwbPagination.vue Updated the pagination component to include conditional rendering for the first, prev, page, next, and last button slots, plus icon slots. Added attributes (:set-page, :disabled, and :page) to facilitate first/last page navigation functionality.

Sequence Diagram(s)

sequenceDiagram
  participant U as User
  participant P as FwbPagination
  participant S as State (currentPage)
  
  U->>P: Click "First Page" button
  P->>S: Execute goToFirstPage()
  S-->>P: Update currentPage = 1
  P->>U: Refresh UI

  U->>P: Click "Last Page" button
  P->>S: Execute goToLastPage()
  S-->>P: Update currentPage = totalPages
  P->>U: Refresh UI
Loading

Possibly related PRs

Suggested labels

🪲 bug, 📚 documentation

Suggested reviewers

  • Sqrcz

Poem

I'm a rabbit hopping by,
Spinning stories in code so spry.
First and last pages now take flight,
With each click, the UI shines bright.
Thank you for the changes so neat—
Hop along, let every page be sweet!
🐇✨

Tip

⚡💬 Agentic Chat (Pro Plan, General Availability)
  • We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 506683f and a914a13.

📒 Files selected for processing (3)
  • docs/components/pagination.md (3 hunks)
  • docs/components/pagination/examples/FwbPaginationExampleSlots.vue (1 hunks)
  • docs/components/pagination/examples/FwbPaginationExampleSlotsAdvanced.vue (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • docs/components/pagination/examples/FwbPaginationExampleSlotsAdvanced.vue
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/components/pagination.md
🔇 Additional comments (3)
docs/components/pagination/examples/FwbPaginationExampleSlots.vue (3)

7-7: Good addition of the enable-first-last prop.

This prop enables the first and last navigation buttons, extending the functionality of the pagination component to support navigation to the extremes of the page range.


9-11: Well implemented first-icon slot.

The first-icon slot is properly added with a clear icon representation (⏪) that intuitively indicates navigation to the first page. This follows the same pattern as the existing prev-icon and next-icon slots.


18-20: Well implemented last-icon slot.

The last-icon slot is properly added with a clear icon representation (⏩) that intuitively indicates navigation to the last page. This maintains consistency with the first-icon implementation and completes the full range of navigation options.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration 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

netlify bot commented Apr 1, 2025

Deploy Preview for sensational-seahorse-8635f8 ready!

Name Link
🔨 Latest commit a914a13
🔍 Latest deploy log https://app.netlify.com/sites/sensational-seahorse-8635f8/deploys/680614767f281e00089f645a
😎 Deploy Preview https://deploy-preview-364--sensational-seahorse-8635f8.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@Sqrcz Sqrcz self-assigned this Apr 1, 2025
@Sqrcz
Copy link
Collaborator

Sqrcz commented Apr 4, 2025

Hey, good catch.

I've tested it and it works as expected now.

Would be great if we could add an example where slots are properly used... using setPage prop from <slot> may not be very obvious for everyone...

<template #first-button="{ setPage, disabled }">
    <button
      :disabled="disabled"
      class="custom-first-button"
      @click="setPage()"
    >
      ⏮ First
    </button>
  </template>

@andreyjamer Let me know if you can add something like that to the docs... or you want me to do it.

@andreyjamer
Copy link
Contributor Author

@Sqrcz Sure, I'll add it

@Sqrcz Sqrcz added the 🔧 enhancement New feature or request label Apr 17, 2025
@andreyjamer
Copy link
Contributor Author

@Sqrcz I added Advanced slots example with custom button usages. It provides the example of all properties for different slots of pagination.
It should help, I think.
P.S. Sorry for delay, I was busy with other tasks

Copy link
Collaborator

@Sqrcz Sqrcz left a comment

Choose a reason for hiding this comment

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

Thank you! This makes it way easier to understand/use... 👏

@Sqrcz Sqrcz merged commit 8b5a96e into themesberg:main May 6, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔧 enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants