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
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/data/Pager/Pager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ export interface PagerProps {
*/
displayMode?: 'pages' | 'items' | 'all';

/**
* Determines whether content should be shown when there is only a single page.
*
* @type {boolean}
* @default true
* @optional
*/
hideOnSinglePage?: boolean;

/**
* The theme for the Pager.
*/
Expand All @@ -98,6 +107,7 @@ export const Pager: FC<PagerProps> = ({
nextArrow = <NextArrow />,
onPageChange,
displayMode = 'pages',
hideOnSinglePage = true,
theme: customTheme
}) => {
const pageCount = Math.ceil(total / size);
Expand All @@ -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.

return null;
}

Expand Down
Loading