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 Drawer demos to hooks #15487

Merged
merged 2 commits 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
17 changes: 6 additions & 11 deletions docs/src/pages/demos/drawers/ClippedDrawer.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 Drawer from '@material-ui/core/Drawer';
import AppBar from '@material-ui/core/AppBar';
import CssBaseline from '@material-ui/core/CssBaseline';
Expand All @@ -16,7 +15,7 @@ import MailIcon from '@material-ui/icons/Mail';

const drawerWidth = 240;

const styles = theme => ({
const useStyles = makeStyles(theme => ({
root: {
display: 'flex',
},
Expand All @@ -35,10 +34,10 @@ const styles = theme => ({
padding: theme.spacing(3),
},
toolbar: theme.mixins.toolbar,
});
}));

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

return (
<div className={classes.root}>
Expand Down Expand Up @@ -106,8 +105,4 @@ function ClippedDrawer(props) {
);
}

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

export default withStyles(styles)(ClippedDrawer);
export default ClippedDrawer;
20 changes: 7 additions & 13 deletions docs/src/pages/demos/drawers/ClippedDrawer.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 Drawer from '@material-ui/core/Drawer';
import AppBar from '@material-ui/core/AppBar';
import CssBaseline from '@material-ui/core/CssBaseline';
Expand All @@ -16,7 +15,7 @@ import MailIcon from '@material-ui/icons/Mail';

const drawerWidth = 240;

const styles = (theme: Theme) =>
const useStyles = makeStyles((theme: Theme) =>
createStyles({
joshwooding marked this conversation as resolved.
Show resolved Hide resolved
root: {
display: 'flex',
Expand All @@ -36,12 +35,11 @@ const styles = (theme: Theme) =>
padding: theme.spacing(3),
},
toolbar: theme.mixins.toolbar,
});
}),
);

interface ClippedDrawerProps extends WithStyles<typeof styles> {}

function ClippedDrawer(props: ClippedDrawerProps) {
const { classes } = props;
function ClippedDrawer() {
const classes = useStyles();

return (
<div className={classes.root}>
Expand Down Expand Up @@ -109,8 +107,4 @@ function ClippedDrawer(props: ClippedDrawerProps) {
);
}

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

export default withStyles(styles)(ClippedDrawer);
export default ClippedDrawer;
17 changes: 6 additions & 11 deletions docs/src/pages/demos/drawers/PermanentDrawerLeft.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 Drawer from '@material-ui/core/Drawer';
import CssBaseline from '@material-ui/core/CssBaseline';
import AppBar from '@material-ui/core/AppBar';
Expand All @@ -16,7 +15,7 @@ import MailIcon from '@material-ui/icons/Mail';

const drawerWidth = 240;

const styles = theme => ({
const useStyles = makeStyles(theme => ({
root: {
display: 'flex',
},
Expand All @@ -37,10 +36,10 @@ const styles = theme => ({
backgroundColor: theme.palette.background.default,
padding: theme.spacing(3),
},
});
}));

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

return (
<div className={classes.root}>
Expand Down Expand Up @@ -110,8 +109,4 @@ function PermanentDrawerLeft(props) {
);
}

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

export default withStyles(styles)(PermanentDrawerLeft);
export default PermanentDrawerLeft;
20 changes: 7 additions & 13 deletions docs/src/pages/demos/drawers/PermanentDrawerLeft.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, withStyles, Theme, WithStyles } from '@material-ui/core/styles';
import { createStyles, Theme, makeStyles } from '@material-ui/core/styles';
import Drawer from '@material-ui/core/Drawer';
import CssBaseline from '@material-ui/core/CssBaseline';
import AppBar from '@material-ui/core/AppBar';
Expand All @@ -16,7 +15,7 @@ import MailIcon from '@material-ui/icons/Mail';

const drawerWidth = 240;

const styles = (theme: Theme) =>
const useStyles = makeStyles((theme: Theme) =>
createStyles({
joshwooding marked this conversation as resolved.
Show resolved Hide resolved
root: {
display: 'flex',
Expand All @@ -38,12 +37,11 @@ const styles = (theme: Theme) =>
backgroundColor: theme.palette.background.default,
padding: theme.spacing(3),
},
});
}),
);

export interface Props extends WithStyles<typeof styles> {}

function PermanentDrawerLeft(props: Props) {
const { classes } = props;
function PermanentDrawerLeft() {
const classes = useStyles();

return (
<div className={classes.root}>
Expand Down Expand Up @@ -113,8 +111,4 @@ function PermanentDrawerLeft(props: Props) {
);
}

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

export default withStyles(styles)(PermanentDrawerLeft);
export default PermanentDrawerLeft;
17 changes: 6 additions & 11 deletions docs/src/pages/demos/drawers/PermanentDrawerRight.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 Drawer from '@material-ui/core/Drawer';
import CssBaseline from '@material-ui/core/CssBaseline';
import AppBar from '@material-ui/core/AppBar';
Expand All @@ -16,7 +15,7 @@ import MailIcon from '@material-ui/icons/Mail';

const drawerWidth = 240;

const styles = theme => ({
const useStyles = makeStyles(theme => ({
root: {
display: 'flex',
},
Expand All @@ -37,10 +36,10 @@ const styles = theme => ({
backgroundColor: theme.palette.background.default,
padding: theme.spacing(3),
},
});
}));

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

return (
<div className={classes.root}>
Expand Down Expand Up @@ -110,8 +109,4 @@ function PermanentDrawerRight(props) {
);
}

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

export default withStyles(styles)(PermanentDrawerRight);
export default PermanentDrawerRight;
20 changes: 7 additions & 13 deletions docs/src/pages/demos/drawers/PermanentDrawerRight.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, createStyles, WithStyles } from '@material-ui/core/styles';
import { Theme, createStyles, makeStyles } from '@material-ui/core/styles';
import Drawer from '@material-ui/core/Drawer';
import CssBaseline from '@material-ui/core/CssBaseline';
import AppBar from '@material-ui/core/AppBar';
Expand All @@ -16,7 +15,7 @@ import MailIcon from '@material-ui/icons/Mail';

const drawerWidth = 240;

const styles = (theme: Theme) =>
const useStyles = makeStyles((theme: Theme) =>
createStyles({
joshwooding marked this conversation as resolved.
Show resolved Hide resolved
root: {
display: 'flex',
Expand All @@ -38,12 +37,11 @@ const styles = (theme: Theme) =>
backgroundColor: theme.palette.background.default,
padding: theme.spacing(3),
},
});
}),
);

export interface Props extends WithStyles<typeof styles> {}

function PermanentDrawerRight(props: Props) {
const { classes } = props;
function PermanentDrawerRight() {
const classes = useStyles();

return (
<div className={classes.root}>
Expand Down Expand Up @@ -113,8 +111,4 @@ function PermanentDrawerRight(props: Props) {
);
}

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

export default withStyles(styles)(PermanentDrawerRight);
export default PermanentDrawerRight;