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 Divider demos to hooks #15490

Merged
merged 5 commits into from
Apr 25, 2019
Merged
Show file tree
Hide file tree
Changes from 4 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/dividers/InsetDividers.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 @@ -11,16 +10,17 @@ import WorkIcon from '@material-ui/icons/Work';
import BeachAccessIcon from '@material-ui/icons/BeachAccess';
import Divider from '@material-ui/core/Divider';

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

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

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

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

export default withStyles(styles)(InsetDividers);
export default InsetDividers;
19 changes: 7 additions & 12 deletions docs/src/pages/demos/dividers/InsetDividers.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 { withStyles, Theme, WithStyles, WithTheme, createStyles } from '@material-ui/core/styles';
import { Theme, createStyles, 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 @@ -11,19 +10,19 @@ import WorkIcon from '@material-ui/icons/Work';
import BeachAccessIcon from '@material-ui/icons/BeachAccess';
import Divider from '@material-ui/core/Divider';

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

type Props = WithStyles<typeof styles> & WithTheme;
function InsetDividers() {
const classes = useStyles();

function InsetDividers(props: Props) {
const { classes } = props;
return (
<List className={classes.root}>
<ListItem>
Expand Down Expand Up @@ -56,8 +55,4 @@ function InsetDividers(props: Props) {
);
}

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

export default withStyles(styles)(InsetDividers);
export default InsetDividers;
18 changes: 7 additions & 11 deletions docs/src/pages/demos/dividers/ListDividers.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
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 Divider from '@material-ui/core/Divider';

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

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

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

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

export default withStyles(styles)(ListDividers);
export default ListDividers;
19 changes: 7 additions & 12 deletions docs/src/pages/demos/dividers/ListDividers.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
import React from 'react';
import PropTypes from 'prop-types';
import { withStyles, createStyles, Theme, WithStyles, WithTheme } 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 Divider from '@material-ui/core/Divider';

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

type Props = WithStyles<typeof styles> & WithTheme;
function ListDividers() {
const classes = useStyles();

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

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

export default withStyles(styles)(ListDividers);
export default ListDividers;
18 changes: 7 additions & 11 deletions docs/src/pages/demos/dividers/MiddleDividers.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import React from 'react';
import PropTypes from 'prop-types';
import { withStyles } from '@material-ui/core/styles';
import { makeStyles } from '@material-ui/core/styles';
import Chip from '@material-ui/core/Chip';
import Button from '@material-ui/core/Button';
import Grid from '@material-ui/core/Grid';
import Divider from '@material-ui/core/Divider';
import Typography from '@material-ui/core/Typography';

const styles = theme => ({
const useStyles = makeStyles(theme => ({
root: {
width: '100%',
maxWidth: 360,
Expand All @@ -25,10 +24,11 @@ const styles = theme => ({
section3: {
margin: theme.spacing(3, 1, 1),
},
});
}));

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

function MiddleDividers(props) {
const { classes } = props;
return (
<div className={classes.root}>
<div className={classes.section1}>
Expand Down Expand Up @@ -68,8 +68,4 @@ function MiddleDividers(props) {
);
}

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

export default withStyles(styles)(MiddleDividers);
export default MiddleDividers;
19 changes: 7 additions & 12 deletions docs/src/pages/demos/dividers/MiddleDividers.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import React from 'react';
import PropTypes from 'prop-types';
import { withStyles, createStyles, Theme, WithStyles, WithTheme } from '@material-ui/core/styles';
import { createStyles, Theme, makeStyles } from '@material-ui/core/styles';
import Chip from '@material-ui/core/Chip';
import Button from '@material-ui/core/Button';
import Grid from '@material-ui/core/Grid';
import Divider from '@material-ui/core/Divider';
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 @@ -26,12 +25,12 @@ const styles = (theme: Theme) =>
section3: {
margin: theme.spacing(3, 1, 1),
},
});
}),
);

type Props = WithStyles<typeof styles> & WithTheme;
function MiddleDividers() {
const classes = useStyles();

function MiddleDividers(props: Props) {
const { classes } = props;
return (
<div className={classes.root}>
<div className={classes.section1}>
Expand Down Expand Up @@ -71,8 +70,4 @@ function MiddleDividers(props: Props) {
);
}

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

export default withStyles(styles)(MiddleDividers);
export default MiddleDividers;
20 changes: 8 additions & 12 deletions docs/src/pages/demos/dividers/SubheaderDividers.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 ListItemAvatar from '@material-ui/core/ListItemAvatar';
Expand All @@ -10,7 +9,7 @@ import BeachAccessIcon from '@material-ui/icons/BeachAccess';
import Divider from '@material-ui/core/Divider';
import Typography from '@material-ui/core/Typography';

const styles = theme => ({
const useStyles = makeStyles(theme => ({
root: {
width: '100%',
maxWidth: 360,
Expand All @@ -20,12 +19,13 @@ const styles = theme => ({
margin: `5px 0 0 ${theme.spacing(2)}px`,
},
dividerInset: {
margin: `5px 0 0 ${theme.spacing(9)}px`,
margin: `5px 0 0 ${theme.spacing(2)}px`,
oliviertassinari marked this conversation as resolved.
Show resolved Hide resolved
},
});
}));

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

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

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

export default withStyles(styles)(SubheaderDividers);
export default SubheaderDividers;
42 changes: 19 additions & 23 deletions docs/src/pages/demos/dividers/SubheaderDividers.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 { withStyles, WithStyles, WithTheme, Theme } from '@material-ui/core/styles';
import { makeStyles, Theme, createStyles } from '@material-ui/core/styles';
import List from '@material-ui/core/List';
import ListItem from '@material-ui/core/ListItem';
import ListItemAvatar from '@material-ui/core/ListItemAvatar';
Expand All @@ -10,24 +9,25 @@ import BeachAccessIcon from '@material-ui/icons/BeachAccess';
import Divider from '@material-ui/core/Divider';
import Typography from '@material-ui/core/Typography';

const styles = (theme: Theme) => ({
root: {
width: '100%',
maxWidth: 360,
backgroundColor: theme.palette.background.paper,
},
dividerFullWidth: {
margin: `5px 0 0 ${theme.spacing(2)}px`,
},
dividerInset: {
margin: `5px 0 0 ${theme.spacing(9)}px`,
},
});
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,
},
dividerFullWidth: {
margin: `5px 0 0 ${theme.spacing(2)}px`,
},
dividerInset: {
margin: `5px 0 0 ${theme.spacing(2)}px`,
},
}),
);

type Props = WithStyles<typeof styles> & WithTheme;
function SubheaderDividers() {
const classes = useStyles();

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

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

export default withStyles(styles)(SubheaderDividers);
export default SubheaderDividers;