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: add show on single page prop to Pager #263

Merged
merged 2 commits into from
Oct 24, 2024

Conversation

matsilva
Copy link

@matsilva matsilva commented Oct 24, 2024

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

Currently, when pageCount === 1, the content is always hidden. There is no option to override this behavior.

Issue Number: N/A

What is the new behavior?

A new optional boolean flag showOnSinglePage has been introduced. When set to true, shows the pager even if there is only one page. If defaults to false and keeps the existing behavior in tact.

Does this PR introduce a breaking change?

[x] Yes
[ ] No

Other information

I did not include it in this pr, but I used the following storybook story to easily test the changes. You just need to set total to 10 and set hideOnSinglePage to false via the controls.

export const Default = ({ page = 0, size = 10, total = 100, ...rest }) => {
  return <Pager page={page} size={size} total={total} {...rest} />;
};

Copy link

netlify bot commented Oct 24, 2024

Deploy Preview for reablocks-storybook ready!

Name Link
🔨 Latest commit fa9456b
🔍 Latest deploy log https://app.netlify.com/sites/reablocks-storybook/deploys/671a87c325e90f00086bcf55
😎 Deploy Preview https://deploy-preview-263--reablocks-storybook.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.

@@ -123,7 +133,7 @@ export const Pager: FC<PagerProps> = ({
}
}, [canNext, page, onPageChange, pageCount]);

if (pageCount === 1) {
if (hideOnSinglePage && pageCount === 1) {
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be better to just remove this logic and the user can deteremine if they want to do this themselves. If you just want to remove this check, we can push a release for ya.

Copy link
Author

@matsilva matsilva Oct 24, 2024

Choose a reason for hiding this comment

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

I think it would be better to just remove this logic and the user can deteremine if they want to do this themselves.

This makes sense.

If you just want to remove this check, we can push a release for ya.

There is an ask to show the pagination at all times, so that would be great 👍

Copy link
Author

Choose a reason for hiding this comment

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

Let me know what you want me to do here.

Copy link
Member

Choose a reason for hiding this comment

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

Ya, just delete that if statement/additions and lgtm.

@amcdnl amcdnl merged commit c27aff7 into reaviz:master Oct 24, 2024
5 checks passed
@matsilva matsilva deleted the add-pager-show-on-single-page branch October 24, 2024 17:52
@amcdnl
Copy link
Member

amcdnl commented Oct 24, 2024

released in latest

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.

2 participants