Skip to content

Commit

Permalink
fix feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
mbrookes committed Jan 16, 2020
1 parent 3a882dc commit 8cbc072
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 44 deletions.
6 changes: 1 addition & 5 deletions docs/src/pages/components/pagination/PaginationLink.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { MemoryRouter as Router } from 'react-router';
import { Link as RouterLink } from 'react-router-dom';
import { Link } from 'react-router-dom';
import { makeStyles } from '@material-ui/core/styles';
import Pagination from '@material-ui/lab/Pagination';
import PaginationItem from '@material-ui/lab/PaginationItem';
Expand All @@ -13,10 +13,6 @@ const useStyles = makeStyles(theme => ({
},
}));

// 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 Link = React.forwardRef((props, ref) => <RouterLink innerRef={ref} {...props} />);

export default function PaginationLink() {
return (
<Router>
Expand Down
8 changes: 1 addition & 7 deletions docs/src/pages/components/pagination/PaginationLink.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { MemoryRouter as Router } from 'react-router';
import { Link as RouterLink } from 'react-router-dom';
import { Link } from 'react-router-dom';
import { createStyles, makeStyles, Theme } from '@material-ui/core/styles';
import Pagination from '@material-ui/lab/Pagination';
import PaginationItem from '@material-ui/lab/PaginationItem';
Expand All @@ -15,12 +15,6 @@ const useStyles = makeStyles((theme: Theme) =>
}),
);

// 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 Link = React.forwardRef<HTMLAnchorElement, RouterLinkProps>((props, ref) => (
<RouterLink innerRef={ref} {...props} />
));

export default function PaginationLink() {
return (
<Router>
Expand Down
9 changes: 2 additions & 7 deletions docs/src/pages/components/pagination/PaginationLink2.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { MemoryRouter as Router } from 'react-router';
import { Link as RouterLink } from 'react-router-dom';
import { Link } from 'react-router-dom';
import { makeStyles } from '@material-ui/core/styles';
import { usePagination } from '@material-ui/lab/Pagination';
import Pagination from '@material-ui/lab/Pagination';
Expand All @@ -14,10 +14,6 @@ const useStyles = makeStyles(theme => ({
},
}));

// 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 Link = React.forwardRef((props, ref) => <RouterLink innerRef={ref} {...props} />);

export default function PaginationLink2() {
const { items } = usePagination({
count: 10,
Expand All @@ -27,12 +23,11 @@ export default function PaginationLink2() {
<Router>
<Pagination>
{items.map((item, index) => (
<li>
<li key={index.toString()}>
<PaginationItem
to={`/cars${item.page === 1 ? '' : `?page=${item.page}`}`}
component={Link}
{...item}
key={index.toString()}
/>
</li>
))}
Expand Down
11 changes: 2 additions & 9 deletions docs/src/pages/components/pagination/PaginationLink2.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { MemoryRouter as Router } from 'react-router';
import { Link as RouterLink } from 'react-router-dom';
import { Link } from 'react-router-dom';
import { createStyles, makeStyles, Theme } from '@material-ui/core/styles';
import { usePagination } from '@material-ui/lab/Pagination';
import Pagination from '@material-ui/lab/Pagination';
Expand All @@ -16,12 +16,6 @@ const useStyles = makeStyles((theme: Theme) =>
}),
);

// 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 Link = React.forwardRef<HTMLAnchorElement, RouterLinkProps>((props, ref) => (
<RouterLink innerRef={ref} {...props} />
));

export default function PaginationLink2() {
const { items } = usePagination({
count: 10,
Expand All @@ -31,12 +25,11 @@ export default function PaginationLink2() {
<Router>
<Pagination>
{items.map((item, index) => (
<li>
<li key={index.toString()}>
<PaginationItem
to={`/cars${item.page === 1 ? '' : `?page=${item.page}`}`}
component={Link}
{...item}
key={index.toString()}
/>
</li>
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@ const useStyles = makeStyles(theme => ({
},
}));

export default function PaginationOutlinedRounded() {
export default function PaginationRounded() {
const classes = useStyles();

return (
<div className={classes.root}>
<Pagination count={10} shape="rounded" />
<Pagination count={10} variant="outlined" shape="rounded" />
<Pagination count={10} variant="outlined" shape="rounded" color="primary" />
<Pagination count={10} variant="outlined" shape="rounded" color="secondary" />
<Pagination count={10} variant="outlined" shape="rounded" disabled />
</div>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@ const useStyles = makeStyles((theme: Theme) =>
}),
);

export default function PaginationOutlinedRounded() {
export default function PaginationRounded() {
const classes = useStyles();

return (
<div className={classes.root}>
<Pagination count={10} shape="rounded" />
<Pagination count={10} variant="outlined" shape="rounded" />
<Pagination count={10} variant="outlined" shape="rounded" color="primary" />
<Pagination count={10} variant="outlined" shape="rounded" color="secondary" />
<Pagination count={10} variant="outlined" shape="rounded" disabled />
</div>
);
}
6 changes: 3 additions & 3 deletions docs/src/pages/components/pagination/pagination.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ components: Pagination

## Pagination

{{"demo": "pages/components/pagination/Pagination.js"}}
{{"demo": "pages/components/pagination/BasicPagination.js"}}

## Outlined pagination

{{"demo": "pages/components/pagination/PaginationOutlined.js"}}

## Outlined rounded pagination
## Rounded pagination

{{"demo": "pages/components/pagination/PaginationOutlinedRounded.js"}}
{{"demo": "pages/components/pagination/PaginationRounded.js"}}

## Pagination size

Expand Down
4 changes: 2 additions & 2 deletions packages/material-ui-lab/src/Pagination/Pagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const styles = {
display: 'flex',
flexWrap: 'wrap',
alignItems: 'center',
listStyleType: 'none',
listStyle: 'none',
padding: 0, // Reset
margin: 0, // Reset
},
Expand Down Expand Up @@ -46,7 +46,7 @@ const Pagination = React.forwardRef(function Pagination(props, ref) {
>
{children ||
items.map((item, index) => (
<li>{renderItem({ key: index.toString(), ...item, ...itemProps })}</li>
<li key={index.toString()}>{renderItem({ ...item, ...itemProps })}</li>
))}
</ul>
);
Expand Down
6 changes: 3 additions & 3 deletions packages/material-ui-lab/src/PaginationItem/PaginationItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ function ariaLabel(type, page, selected) {
return `Go to ${type} page`;
}

function PaginationItem(props) {
const PaginationItem = React.forwardRef(function PaginationItem(props, ref) {
const {
classes,
className,
Expand Down Expand Up @@ -258,7 +258,7 @@ function PaginationItem(props) {
)}
</React.Fragment>
);
}
});

PaginationItem.propTypes = {
/**
Expand All @@ -279,7 +279,7 @@ PaginationItem.propTypes = {
*/
component: PropTypes.elementType,
/**
* If `true`, the button will be disabled.
* If `true`, the item will be disabled.
*/
disabled: PropTypes.bool,
/**
Expand Down

0 comments on commit 8cbc072

Please sign in to comment.