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

[docs] Migrate List demos to hooks #15488

Merged
merged 1 commit into from
Apr 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
18 changes: 7 additions & 11 deletions docs/src/pages/demos/lists/AlignItemsList.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';
import { withStyles } from '@material-ui/core/styles';
import { makeStyles } from '@material-ui/core/styles';
import List from '@material-ui/core/List';
import ListItem from '@material-ui/core/ListItem';
import Divider from '@material-ui/core/Divider';
Expand All @@ -9,7 +8,7 @@ import ListItemAvatar from '@material-ui/core/ListItemAvatar';
import Avatar from '@material-ui/core/Avatar';
import Typography from '@material-ui/core/Typography';

const styles = theme => ({
const useStyles = makeStyles(theme => ({
root: {
width: '100%',
maxWidth: 360,
Expand All @@ -18,10 +17,11 @@ const styles = theme => ({
inline: {
display: 'inline',
},
});
}));

function AlignItemsList() {
const classes = useStyles();

function AlignItemsList(props) {
const { classes } = props;
return (
<List className={classes.root}>
<ListItem alignItems="flex-start">
Expand Down Expand Up @@ -93,8 +93,4 @@ function AlignItemsList(props) {
);
}

AlignItemsList.propTypes = {
classes: PropTypes.object.isRequired,
};

export default withStyles(styles)(AlignItemsList);
export default AlignItemsList;
19 changes: 7 additions & 12 deletions docs/src/pages/demos/lists/AlignItemsList.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';
import { createStyles, Theme, withStyles, WithStyles } from '@material-ui/core/styles';
import { createStyles, Theme, makeStyles } from '@material-ui/core/styles';
import List from '@material-ui/core/List';
import ListItem from '@material-ui/core/ListItem';
import Divider from '@material-ui/core/Divider';
Expand All @@ -9,7 +8,7 @@ import ListItemAvatar from '@material-ui/core/ListItemAvatar';
import Avatar from '@material-ui/core/Avatar';
import Typography from '@material-ui/core/Typography';

const styles = (theme: Theme) =>
const useStyles = makeStyles((theme: Theme) =>
createStyles({
joshwooding marked this conversation as resolved.
Show resolved Hide resolved
root: {
width: '100%',
Expand All @@ -19,12 +18,12 @@ const styles = (theme: Theme) =>
inline: {
display: 'inline',
},
});
}),
);

export interface AlignItemListProps extends WithStyles<typeof styles> {}
function AlignItemsList() {
const classes = useStyles();

function AlignItemsList(props: AlignItemListProps) {
const { classes } = props;
return (
<List className={classes.root}>
<ListItem alignItems="flex-start">
Expand Down Expand Up @@ -96,8 +95,4 @@ function AlignItemsList(props: AlignItemListProps) {
);
}

AlignItemsList.propTypes = {
classes: PropTypes.object.isRequired,
} as any;

export default withStyles(styles)(AlignItemsList);
export default AlignItemsList;
18 changes: 7 additions & 11 deletions docs/src/pages/demos/lists/FolderList.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';
import { withStyles } from '@material-ui/core/styles';
import { makeStyles } from '@material-ui/core/styles';
import List from '@material-ui/core/List';
import ListItem from '@material-ui/core/ListItem';
import ListItemText from '@material-ui/core/ListItemText';
Expand All @@ -10,16 +9,17 @@ import ImageIcon from '@material-ui/icons/Image';
import WorkIcon from '@material-ui/icons/Work';
import BeachAccessIcon from '@material-ui/icons/BeachAccess';

const styles = theme => ({
const useStyles = makeStyles(theme => ({
root: {
width: '100%',
maxWidth: 360,
backgroundColor: theme.palette.background.paper,
},
});
}));

function FolderList() {
const classes = useStyles();

function FolderList(props) {
const { classes } = props;
return (
<List className={classes.root}>
<ListItem>
Expand Down Expand Up @@ -50,8 +50,4 @@ function FolderList(props) {
);
}

FolderList.propTypes = {
classes: PropTypes.object.isRequired,
};

export default withStyles(styles)(FolderList);
export default FolderList;
19 changes: 7 additions & 12 deletions docs/src/pages/demos/lists/FolderList.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';
import { createStyles, Theme, withStyles, WithStyles } from '@material-ui/core/styles';
import { createStyles, Theme, makeStyles } from '@material-ui/core/styles';
import List from '@material-ui/core/List';
import ListItem from '@material-ui/core/ListItem';
import ListItemText from '@material-ui/core/ListItemText';
Expand All @@ -10,19 +9,19 @@ import ImageIcon from '@material-ui/icons/Image';
import WorkIcon from '@material-ui/icons/Work';
import BeachAccessIcon from '@material-ui/icons/BeachAccess';

const styles = (theme: Theme) =>
const useStyles = makeStyles((theme: Theme) =>
createStyles({
joshwooding marked this conversation as resolved.
Show resolved Hide resolved
root: {
width: '100%',
maxWidth: 360,
backgroundColor: theme.palette.background.paper,
},
});
}),
);

export interface FolderListProps extends WithStyles<typeof styles> {}
function FolderList() {
const classes = useStyles();

function FolderList(props: FolderListProps) {
const { classes } = props;
return (
<List className={classes.root}>
<ListItem>
Expand Down Expand Up @@ -53,8 +52,4 @@ function FolderList(props: FolderListProps) {
);
}

FolderList.propTypes = {
classes: PropTypes.object.isRequired,
} as any;

export default withStyles(styles)(FolderList);
export default FolderList;
18 changes: 7 additions & 11 deletions docs/src/pages/demos/lists/InsetList.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import React from 'react';
import PropTypes from 'prop-types';
import { withStyles } from '@material-ui/core/styles';
import { makeStyles } from '@material-ui/core/styles';
import List from '@material-ui/core/List';
import ListItem from '@material-ui/core/ListItem';
import ListItemIcon from '@material-ui/core/ListItemIcon';
import ListItemText from '@material-ui/core/ListItemText';
import StarIcon from '@material-ui/icons/Star';

const styles = theme => ({
const useStyles = makeStyles(theme => ({
root: {
width: '100%',
maxWidth: 360,
backgroundColor: theme.palette.background.paper,
},
});
}));

function InsetList() {
const classes = useStyles();

function InsetList(props) {
const { classes } = props;
return (
<List component="nav" className={classes.root}>
<ListItem button>
Expand All @@ -32,8 +32,4 @@ function InsetList(props) {
);
}

InsetList.propTypes = {
classes: PropTypes.object.isRequired,
};

export default withStyles(styles)(InsetList);
export default InsetList;
19 changes: 7 additions & 12 deletions docs/src/pages/demos/lists/InsetList.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
import React from 'react';
import PropTypes from 'prop-types';
import { createStyles, Theme, withStyles, WithStyles } from '@material-ui/core/styles';
import { createStyles, Theme, makeStyles } from '@material-ui/core/styles';
import List from '@material-ui/core/List';
import ListItem from '@material-ui/core/ListItem';
import ListItemIcon from '@material-ui/core/ListItemIcon';
import ListItemText from '@material-ui/core/ListItemText';
import StarIcon from '@material-ui/icons/Star';

const styles = (theme: Theme) =>
const useStyles = makeStyles((theme: Theme) =>
createStyles({
joshwooding marked this conversation as resolved.
Show resolved Hide resolved
root: {
width: '100%',
maxWidth: 360,
backgroundColor: theme.palette.background.paper,
},
});
}),
);

export interface InsetListProps extends WithStyles<typeof styles> {}
function InsetList() {
const classes = useStyles();

function InsetList(props: InsetListProps) {
const { classes } = props;
return (
<List component="nav" className={classes.root}>
<ListItem button>
Expand All @@ -35,8 +34,4 @@ function InsetList(props: InsetListProps) {
);
}

InsetList.propTypes = {
classes: PropTypes.object.isRequired,
} as any;

export default withStyles(styles)(InsetList);
export default InsetList;
17 changes: 6 additions & 11 deletions docs/src/pages/demos/lists/PinnedSubheaderList.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import React from 'react';
import PropTypes from 'prop-types';
import { withStyles } from '@material-ui/core/styles';
import { makeStyles } from '@material-ui/core/styles';
import List from '@material-ui/core/List';
import ListItem from '@material-ui/core/ListItem';
import ListItemText from '@material-ui/core/ListItemText';
import ListSubheader from '@material-ui/core/ListSubheader';

const styles = theme => ({
const useStyles = makeStyles(theme => ({
root: {
width: '100%',
maxWidth: 360,
Expand All @@ -22,10 +21,10 @@ const styles = theme => ({
backgroundColor: 'inherit',
padding: 0,
},
});
}));

function PinnedSubheaderList(props) {
const { classes } = props;
function PinnedSubheaderList() {
const classes = useStyles();

return (
<List className={classes.root} subheader={<li />}>
Expand All @@ -45,8 +44,4 @@ function PinnedSubheaderList(props) {
);
}

PinnedSubheaderList.propTypes = {
classes: PropTypes.object.isRequired,
};

export default withStyles(styles)(PinnedSubheaderList);
export default PinnedSubheaderList;
20 changes: 7 additions & 13 deletions docs/src/pages/demos/lists/PinnedSubheaderList.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import React from 'react';
import PropTypes from 'prop-types';
import { createStyles, Theme, withStyles, WithStyles } from '@material-ui/core/styles';
import { createStyles, Theme, makeStyles } from '@material-ui/core/styles';
import List from '@material-ui/core/List';
import ListItem from '@material-ui/core/ListItem';
import ListItemText from '@material-ui/core/ListItemText';
import ListSubheader from '@material-ui/core/ListSubheader';

const styles = (theme: Theme) =>
const useStyles = makeStyles((theme: Theme) =>
createStyles({
joshwooding marked this conversation as resolved.
Show resolved Hide resolved
root: {
width: '100%',
Expand All @@ -23,12 +22,11 @@ const styles = (theme: Theme) =>
backgroundColor: 'inherit',
padding: 0,
},
});
}),
);

export interface PinnedSubheaderListProps extends WithStyles<typeof styles> {}

function PinnedSubheaderList(props: PinnedSubheaderListProps) {
const { classes } = props;
function PinnedSubheaderList() {
const classes = useStyles();

return (
<List className={classes.root} subheader={<li />}>
Expand All @@ -48,8 +46,4 @@ function PinnedSubheaderList(props: PinnedSubheaderListProps) {
);
}

PinnedSubheaderList.propTypes = {
classes: PropTypes.object.isRequired,
} as any;

export default withStyles(styles)(PinnedSubheaderList);
export default PinnedSubheaderList;
18 changes: 7 additions & 11 deletions docs/src/pages/demos/lists/SimpleList.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';
import { withStyles } from '@material-ui/core/styles';
import { makeStyles } from '@material-ui/core/styles';
import List from '@material-ui/core/List';
import ListItem from '@material-ui/core/ListItem';
import ListItemIcon from '@material-ui/core/ListItemIcon';
Expand All @@ -9,20 +8,21 @@ import Divider from '@material-ui/core/Divider';
import InboxIcon from '@material-ui/icons/Inbox';
import DraftsIcon from '@material-ui/icons/Drafts';

const styles = theme => ({
const useStyles = makeStyles(theme => ({
root: {
width: '100%',
maxWidth: 360,
backgroundColor: theme.palette.background.paper,
},
});
}));

function ListItemLink(props) {
return <ListItem button component="a" {...props} />;
}

function SimpleList(props) {
const { classes } = props;
function SimpleList() {
const classes = useStyles();

return (
<div className={classes.root}>
<List component="nav">
Expand Down Expand Up @@ -52,8 +52,4 @@ function SimpleList(props) {
);
}

SimpleList.propTypes = {
classes: PropTypes.object.isRequired,
};

export default withStyles(styles)(SimpleList);
export default SimpleList;
Loading