-
Notifications
You must be signed in to change notification settings - Fork 466
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
Add support for custom pagination #1026
Conversation
* new prop `renderPagination` * customizable page size
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, @prayerslayer thanks for the PR. Have a few questions:
- What is the intention to introduce
setSize
function? - At
L700
I think we should only check forrenderPagination
prop and not the type as it would be handled using prop type. Thoughts ?
Hey!
Thanks for taking the time! |
I fixed the second point you mentioned @jyash97. As for the first one, I'd prefer the custom pagination component to be written like this (from my local storybook): <ReactiveListDefault
pagination={boolean("pagination", true)}
renderPagination={({ pages, totalPages, currentPage, setPage, setSize }) => {
const selectPage = Number.isFinite(pages) && (
<select onChange={e => setPage(parseInt(e.target.value, 10))}>
{new Array(pages).fill(0).map((_, i) => (
<option value={i}>{i + 1}</option>
))}
</select>
);
const selectPageSize = (
<div>
Page size:{" "}
<select onChange={e => setSize(parseInt(e.target.value, 10))}>
<option selected value={5}>5</option>
<option value={10}>10</option>
<option value={25}>25</option>
<option value={50}>50</option>
</select>
</div>
);
return (
<div>
Page {currentPage + 1}/{pages} {selectPage} {selectPageSize}
</div>
);
}}
paginationAt={select(
"paginationAt",
{ bottom: "bottom", top: "top", both: "both" },
"bottom"
)}
size={number('size', 5)}
pages={number("pages", 5)}
title="Meetups"
/> I hope that makes things more clear. Is there anything else I'd need to do to get this merged? Also I was thinking about how one would write custom pagination, but with the additional requirement that it'd be different whether it's at the top or bottom. Think e.g. page size selection and result count at the top, page selection at the bottom. How would that work? I think the most straightforward solution would be pass an additional property |
Hey @prayerslayer For the custom pagination size, we can cover it in a different PR after this is merged. But I think that can be achieved using |
Sure, thank you very much :) Let me know if I can help. |
Hey @prayerslayer Check this codesandbox example: https://codesandbox.io/s/reactivelist-1czg3 If this looks good, we can remove |
Hi!
Yeah, I realized that before, but I'm not sure I like it. See my previous comment:
Pagination state (current page, number of pages, page size) is now distributed among But maybe I'm trying to change too much here. I don't really agree with how my code will look like, but I think a |
Done @jyash97 :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes look good only a small change is needed. 💯
Thanks! I checked all |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome 💯
Thanks for the PR. Really clean implementation 💥
@lakhansamani @bietkul If this looks good we can merge it.
PR looks good, @jyash97 Can you please update the docs then we can merge it. |
Added here: appbaseio/reactive-manual#182 |
Awesome, thanks! Do you know when this will be available in a release? :) Asking because the docs are already updated 😅 |
Hey @prayerslayer It will be released soon and I will update you over here once the new version is out. Thanks for the contribution 💯 |
@prayerslayer It's been released now. |
Very nice, thanks a ton! |
Hello,
I'm planning to use your nice Elasticsearch UI for a web project, but I need custom pagination (issue #127).
Changes:
renderPagination
. It should be a function that receives pagination-related data and should return a JSX elementsize
part ofReactiveList
state, because it's relatively common that you let users choose the page size, and it's more convenient for developers if they can do it from their custom pagination component.This seems to work in a storybook, but I'm wondering if the diff you see is all there is to it.
playground
is a separate repo, do I make a PR to add the storybook there?Anyways I hope you find it helpful and maybe we can merge it at some point :)