-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
[Pagination] Add new component #18449
Comments
How about something like this? https://github.com/vim-labs/materialui-pagination-component |
@iRyanBell Thanks for sharing. We will need to provide a built-in solution in Material-UI in the near future. I hope we can deliver it by Q1 2020. Would you be interested in this effort? I can guide you into this. I would need to run a benchmark in order to better understand how we can move forward. It would likely require a new effort, taking the good parts from everybody, your project included. |
@oliviertassinari Count me in. |
@iRyanBell Awesome, I will try to quick that off tomorrow. |
in case you are interested. this lib is used by react-bootsrap https://github.com/ultimate-pagination/react-ultimate-pagination |
BenchmarkI have used the following sources to benchmark:
ProposalI would recommend the following:
Pagination.propTypes = {
/**
* If `true`, all links will be disabled.
*/
disabled: PropTypes.bool,
/**
* The size.
*
* default 'medium'
*/
size: PropTypes.oneOf(['small', 'medium']),
/**
* The active color.
*/
color: PropTypes.oneOf(['primary', 'secondary']),
/**
* Callback fired when the page is changed.
*
* @param {object} event The event source of the callback.
* @param {number} page The page selected.
*/
onChange: PropTypes.func,
/**
* The zero-based index of the current page.
*/
page: PropTypes.number.isRequired,
/**
* The total number of pages.
*/
count: PropTypes.number.isRequired,
/**
* Number of always visible pages at the beginning and end.
*/
boundaryRange: PropTypes.number,
/**
* Number of always visible pages before and after the current one.
*/
siblingRange: PropTypes.number,
/**
* If `true`, show the first page item.
*/
displayFirstItem: PropTypes.bool,
/**
* Render the item.
*
* @param {object} params
* @returns {ReactNode}
*/
renderItem: PropTypes.func,
/**
* Text label for the first page item.
*
* default First page
*/
firstItemText: PropTypes.string,
/**
* Text label for the next page item.
*
* default Next page
*/
nextItemText: PropTypes.string,
/**
* Text label for the next page item.
*
* default Last page
*/
lastItemText: PropTypes.string,
/**
* Text label for the next page item.
*
* default Previous page
*/
previousItemText: PropTypes.string,
/**
* If `true`, hide the next page item.
*/
hideNextItem: PropTypes.bool,
/**
* If `true`, hide the previous page item.
*/
hidePreviousItem: PropTypes.bool,
/**
* If `true`, show the last page item.
*/
displayLastItem: PropTypes.bool,
};
References
|
I share the same observation. I have seen one select based pagination (baseui). An input field seems more frequent. For instance https://www.shutterstock.com/fr/search/tree.
Actually, I think that |
I had another thought, what if we expose the Pagination DOM structure. Something like this (1)? import React from 'react';
import { Link } from '@material-ui/core';
import { Link as RouterLink } from 'react-router-dom';
import { usePagination, Pagination, PaginationItem } from '@material-ui/lab';
// The use of React.forwardRef will no longer be required for react-router-dom v6.
// See https://github.com/ReactTraining/react-router/issues/6056
const Link1 = React.forwardRef<HTMLAnchorElement, RouterLinkProps>((props, ref) => (
<RouterLink innerRef={ref} {...props} />
));
function MyPagination() {
const items = usePagination({
page: 2,
count: 10,
});
return (
<Pagination>
{items.map(item =>
<PaginationItem
to={`/cars${item.page === 1 ? '' : `?page=${item.page}`}`}
component={Link1}
{...item}
/>
)}
</Pagination>
)
} Instead of (2) import React from 'react';
import { Link } from '@material-ui/core';
import { Link as RouterLink } from 'react-router-dom';
import { Pagination, PaginationItem } from '@material-ui/lab';
// The use of React.forwardRef will no longer be required for react-router-dom v6.
// See https://github.com/ReactTraining/react-router/issues/6056
const Link1 = React.forwardRef<HTMLAnchorElement, RouterLinkProps>((props, ref) => (
<RouterLink innerRef={ref} {...props} />
));
function MyPagination() {
return (
<Pagination
page={2}
count={10}
renderItem={(item => (
<PaginationItem
to={`/cars${item.page === 1 ? '' : `?page=${item.page}`}`}
component={Link1}
{...item}
/>
)}
/>
)
} But maybe we can support both. |
We need the new Pagination component like this https://react.semantic-ui.com/addons/pagination/
The text was updated successfully, but these errors were encountered: