diff --git a/docs/src/pages/components/grid/AutoGrid.js b/docs/src/pages/components/grid/AutoGrid.js index 849947b73ad43b..1a1e3ce47342a7 100644 --- a/docs/src/pages/components/grid/AutoGrid.js +++ b/docs/src/pages/components/grid/AutoGrid.js @@ -1,10 +1,9 @@ import React from 'react'; -import PropTypes from 'prop-types'; -import { withStyles } from '@material-ui/core/styles'; +import { makeStyles } from '@material-ui/core/styles'; import Paper from '@material-ui/core/Paper'; import Grid from '@material-ui/core/Grid'; -const styles = theme => ({ +const useStyles = makeStyles(theme => ({ root: { flexGrow: 1, }, @@ -13,10 +12,10 @@ const styles = theme => ({ textAlign: 'center', color: theme.palette.text.secondary, }, -}); +})); -function AutoGrid(props) { - const { classes } = props; +function AutoGrid() { + const classes = useStyles(); return (
@@ -46,8 +45,4 @@ function AutoGrid(props) { ); } -AutoGrid.propTypes = { - classes: PropTypes.object.isRequired, -}; - -export default withStyles(styles)(AutoGrid); +export default AutoGrid; diff --git a/docs/src/pages/components/grid/AutoGrid.tsx b/docs/src/pages/components/grid/AutoGrid.tsx new file mode 100644 index 00000000000000..22324a40de26eb --- /dev/null +++ b/docs/src/pages/components/grid/AutoGrid.tsx @@ -0,0 +1,50 @@ +import React from 'react'; +import { makeStyles, createStyles, Theme } from '@material-ui/core/styles'; +import Paper from '@material-ui/core/Paper'; +import Grid from '@material-ui/core/Grid'; + +const useStyles = makeStyles((theme: Theme) => + createStyles({ + root: { + flexGrow: 1, + }, + paper: { + padding: theme.spacing(2), + textAlign: 'center', + color: theme.palette.text.secondary, + }, + }), +); + +function AutoGrid() { + const classes = useStyles(); + + return ( +
+ + + xs + + + xs + + + xs + + + + + xs + + + xs=6 + + + xs + + +
+ ); +} + +export default AutoGrid; diff --git a/docs/src/pages/components/grid/AutoGridNoWrap.js b/docs/src/pages/components/grid/AutoGridNoWrap.js index 9010f942a10d60..dcc1a6d48c16a2 100644 --- a/docs/src/pages/components/grid/AutoGridNoWrap.js +++ b/docs/src/pages/components/grid/AutoGridNoWrap.js @@ -1,12 +1,11 @@ import React from 'react'; -import PropTypes from 'prop-types'; import Paper from '@material-ui/core/Paper'; -import { withStyles } from '@material-ui/core/styles'; +import { makeStyles } from '@material-ui/core/styles'; import Grid from '@material-ui/core/Grid'; import Avatar from '@material-ui/core/Avatar'; import Typography from '@material-ui/core/Typography'; -const styles = theme => ({ +const useStyles = makeStyles(theme => ({ root: { flexGrow: 1, overflow: 'hidden', @@ -17,13 +16,13 @@ const styles = theme => ({ margin: `${theme.spacing(1)}px auto`, padding: theme.spacing(2), }, -}); +})); const message = `Truncation should be conditionally applicable on this long line of text as this is a much longer line than what the container can support. `; -function AutoGridNoWrap(props) { - const { classes } = props; +function AutoGridNoWrap() { + const classes = useStyles(); return (
@@ -61,8 +60,4 @@ function AutoGridNoWrap(props) { ); } -AutoGridNoWrap.propTypes = { - classes: PropTypes.object.isRequired, -}; - -export default withStyles(styles)(AutoGridNoWrap); +export default AutoGridNoWrap; diff --git a/docs/src/pages/components/grid/AutoGridNoWrap.tsx b/docs/src/pages/components/grid/AutoGridNoWrap.tsx new file mode 100644 index 00000000000000..084c3524fd8442 --- /dev/null +++ b/docs/src/pages/components/grid/AutoGridNoWrap.tsx @@ -0,0 +1,65 @@ +import React from 'react'; +import Paper from '@material-ui/core/Paper'; +import { makeStyles, createStyles, Theme } from '@material-ui/core/styles'; +import Grid from '@material-ui/core/Grid'; +import Avatar from '@material-ui/core/Avatar'; +import Typography from '@material-ui/core/Typography'; + +const useStyles = makeStyles((theme: Theme) => + createStyles({ + root: { + flexGrow: 1, + overflow: 'hidden', + padding: theme.spacing(0, 3), + }, + paper: { + maxWidth: 400, + margin: `${theme.spacing(1)}px auto`, + padding: theme.spacing(2), + }, + }), +); + +const message = `Truncation should be conditionally applicable on this long line of text + as this is a much longer line than what the container can support. `; + +function AutoGridNoWrap() { + const classes = useStyles(); + + return ( +
+ + + + W + + + {message} + + + + + + + W + + + {message} + + + + + + + W + + + {message} + + + +
+ ); +} + +export default AutoGridNoWrap; diff --git a/docs/src/pages/components/grid/CSSGrid.js b/docs/src/pages/components/grid/CSSGrid.js index efbf3b672dd3e9..bd3eb355be0321 100644 --- a/docs/src/pages/components/grid/CSSGrid.js +++ b/docs/src/pages/components/grid/CSSGrid.js @@ -1,16 +1,15 @@ import React from 'react'; -import PropTypes from 'prop-types'; -import { withStyles } from '@material-ui/core/styles'; +import { makeStyles } from '@material-ui/core/styles'; import Typography from '@material-ui/core/Typography'; import Paper from '@material-ui/core/Paper'; import Divider from '@material-ui/core/Divider'; import Grid from '@material-ui/core/Grid'; -const styles = theme => ({ +const useStyles = makeStyles(theme => ({ container: { display: 'grid', gridTemplateColumns: 'repeat(12, 1fr)', - gridGap: `${theme.spacing(3)}px`, + gridGap: theme.spacing(3), }, paper: { padding: theme.spacing(1), @@ -22,10 +21,10 @@ const styles = theme => ({ divider: { margin: theme.spacing(2, 0), }, -}); +})); -function CSSGrid(props) { - const { classes } = props; +function CSSGrid() { + const classes = useStyles(); return (
@@ -80,8 +79,4 @@ function CSSGrid(props) { ); } -CSSGrid.propTypes = { - classes: PropTypes.object.isRequired, -}; - -export default withStyles(styles)(CSSGrid); +export default CSSGrid; diff --git a/docs/src/pages/components/grid/CSSGrid.tsx b/docs/src/pages/components/grid/CSSGrid.tsx new file mode 100644 index 00000000000000..ba5353677dfae5 --- /dev/null +++ b/docs/src/pages/components/grid/CSSGrid.tsx @@ -0,0 +1,84 @@ +import React from 'react'; +import { makeStyles, createStyles, Theme } from '@material-ui/core/styles'; +import Typography from '@material-ui/core/Typography'; +import Paper from '@material-ui/core/Paper'; +import Divider from '@material-ui/core/Divider'; +import Grid from '@material-ui/core/Grid'; + +const useStyles = makeStyles((theme: Theme) => + createStyles({ + container: { + display: 'grid', + gridTemplateColumns: 'repeat(12, 1fr)', + gridGap: theme.spacing(3), + }, + paper: { + padding: theme.spacing(1), + textAlign: 'center', + color: theme.palette.text.secondary, + whiteSpace: 'nowrap', + marginBottom: theme.spacing(1), + }, + divider: { + margin: theme.spacing(2, 0), + }, + }), +); + +function CSSGrid() { + const classes = useStyles(); + + return ( +
+ + Material-UI Grid: + + + + xs=3 + + + xs=3 + + + xs=3 + + + xs=3 + + + xs=8 + + + xs=4 + + + + + CSS Grid Layout: + +
+
+ xs=3 +
+
+ xs=3 +
+
+ xs=3 +
+
+ xs=3 +
+
+ xs=8 +
+
+ xs=4 +
+
+
+ ); +} + +export default CSSGrid; diff --git a/docs/src/pages/components/grid/CenteredGrid.js b/docs/src/pages/components/grid/CenteredGrid.js index a5cf198acc0e57..bfd11a47a4fc71 100644 --- a/docs/src/pages/components/grid/CenteredGrid.js +++ b/docs/src/pages/components/grid/CenteredGrid.js @@ -1,10 +1,9 @@ import React from 'react'; -import PropTypes from 'prop-types'; -import { withStyles } from '@material-ui/core/styles'; +import { makeStyles } from '@material-ui/core/styles'; import Paper from '@material-ui/core/Paper'; import Grid from '@material-ui/core/Grid'; -const styles = theme => ({ +const useStyles = makeStyles(theme => ({ root: { flexGrow: 1, }, @@ -13,10 +12,10 @@ const styles = theme => ({ textAlign: 'center', color: theme.palette.text.secondary, }, -}); +})); -function CenteredGrid(props) { - const { classes } = props; +function CenteredGrid() { + const classes = useStyles(); return (
@@ -47,8 +46,4 @@ function CenteredGrid(props) { ); } -CenteredGrid.propTypes = { - classes: PropTypes.object.isRequired, -}; - -export default withStyles(styles)(CenteredGrid); +export default CenteredGrid; diff --git a/docs/src/pages/components/grid/CenteredGrid.tsx b/docs/src/pages/components/grid/CenteredGrid.tsx new file mode 100644 index 00000000000000..25b3e77204b4f4 --- /dev/null +++ b/docs/src/pages/components/grid/CenteredGrid.tsx @@ -0,0 +1,51 @@ +import React from 'react'; +import { makeStyles, createStyles, Theme } from '@material-ui/core/styles'; +import Paper from '@material-ui/core/Paper'; +import Grid from '@material-ui/core/Grid'; + +const useStyles = makeStyles((theme: Theme) => + createStyles({ + root: { + flexGrow: 1, + }, + paper: { + padding: theme.spacing(2), + textAlign: 'center', + color: theme.palette.text.secondary, + }, + }), +); + +function CenteredGrid() { + const classes = useStyles(); + + return ( +
+ + + xs=12 + + + xs=6 + + + xs=6 + + + xs=3 + + + xs=3 + + + xs=3 + + + xs=3 + + +
+ ); +} + +export default CenteredGrid; diff --git a/docs/src/pages/components/grid/ComplexGrid.js b/docs/src/pages/components/grid/ComplexGrid.js index 3df1564aeec3b5..00821579c6919a 100644 --- a/docs/src/pages/components/grid/ComplexGrid.js +++ b/docs/src/pages/components/grid/ComplexGrid.js @@ -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 Grid from '@material-ui/core/Grid'; import Paper from '@material-ui/core/Paper'; import Typography from '@material-ui/core/Typography'; import ButtonBase from '@material-ui/core/ButtonBase'; -const styles = theme => ({ +const useStyles = makeStyles(theme => ({ root: { flexGrow: 1, }, @@ -25,10 +24,11 @@ const styles = theme => ({ maxWidth: '100%', maxHeight: '100%', }, -}); +})); + +function ComplexGrid() { + const classes = useStyles(); -function ComplexGrid(props) { - const { classes } = props; return (
@@ -67,8 +67,4 @@ function ComplexGrid(props) { ); } -ComplexGrid.propTypes = { - classes: PropTypes.object.isRequired, -}; - -export default withStyles(styles)(ComplexGrid); +export default ComplexGrid; diff --git a/docs/src/pages/components/grid/ComplexGrid.tsx b/docs/src/pages/components/grid/ComplexGrid.tsx new file mode 100644 index 00000000000000..5c8b64eb06f93a --- /dev/null +++ b/docs/src/pages/components/grid/ComplexGrid.tsx @@ -0,0 +1,72 @@ +import React from 'react'; +import { makeStyles, createStyles, Theme } from '@material-ui/core/styles'; +import Grid from '@material-ui/core/Grid'; +import Paper from '@material-ui/core/Paper'; +import Typography from '@material-ui/core/Typography'; +import ButtonBase from '@material-ui/core/ButtonBase'; + +const useStyles = makeStyles((theme: Theme) => + createStyles({ + root: { + flexGrow: 1, + }, + paper: { + padding: theme.spacing(2), + margin: 'auto', + maxWidth: 500, + }, + image: { + width: 128, + height: 128, + }, + img: { + margin: 'auto', + display: 'block', + maxWidth: '100%', + maxHeight: '100%', + }, + }), +); + +function ComplexGrid() { + const classes = useStyles(); + + return ( +
+ + + + + complex + + + + + + + Standard license + + + Full resolution 1920x1080 • JPEG + + + ID: 1030114 + + + + + Remove + + + + + $19.00 + + + + +
+ ); +} + +export default ComplexGrid; diff --git a/docs/src/pages/components/grid/FullWidthGrid.js b/docs/src/pages/components/grid/FullWidthGrid.js index 5664d56404d6b8..feb92a87e0316b 100644 --- a/docs/src/pages/components/grid/FullWidthGrid.js +++ b/docs/src/pages/components/grid/FullWidthGrid.js @@ -1,10 +1,9 @@ import React from 'react'; -import PropTypes from 'prop-types'; -import { withStyles } from '@material-ui/core/styles'; +import { makeStyles } from '@material-ui/core/styles'; import Paper from '@material-ui/core/Paper'; import Grid from '@material-ui/core/Grid'; -const styles = theme => ({ +const useStyles = makeStyles(theme => ({ root: { flexGrow: 1, }, @@ -13,10 +12,10 @@ const styles = theme => ({ textAlign: 'center', color: theme.palette.text.secondary, }, -}); +})); -function FullWidthGrid(props) { - const { classes } = props; +function FullWidthGrid() { + const classes = useStyles(); return (
@@ -47,8 +46,4 @@ function FullWidthGrid(props) { ); } -FullWidthGrid.propTypes = { - classes: PropTypes.object.isRequired, -}; - -export default withStyles(styles)(FullWidthGrid); +export default FullWidthGrid; diff --git a/docs/src/pages/components/grid/FullWidthGrid.tsx b/docs/src/pages/components/grid/FullWidthGrid.tsx new file mode 100644 index 00000000000000..cec133592850ed --- /dev/null +++ b/docs/src/pages/components/grid/FullWidthGrid.tsx @@ -0,0 +1,51 @@ +import React from 'react'; +import { makeStyles, createStyles, Theme } from '@material-ui/core/styles'; +import Paper from '@material-ui/core/Paper'; +import Grid from '@material-ui/core/Grid'; + +const useStyles = makeStyles((theme: Theme) => + createStyles({ + root: { + flexGrow: 1, + }, + paper: { + padding: theme.spacing(2), + textAlign: 'center', + color: theme.palette.text.secondary, + }, + }), +); + +function FullWidthGrid() { + const classes = useStyles(); + + return ( +
+ + + xs=12 + + + xs=12 sm=6 + + + xs=12 sm=6 + + + xs=6 sm=3 + + + xs=6 sm=3 + + + xs=6 sm=3 + + + xs=6 sm=3 + + +
+ ); +} + +export default FullWidthGrid; diff --git a/docs/src/pages/components/grid/InteractiveGrid.js b/docs/src/pages/components/grid/InteractiveGrid.js index 1bc27d01aac017..cf70ffe54d8b6a 100644 --- a/docs/src/pages/components/grid/InteractiveGrid.js +++ b/docs/src/pages/components/grid/InteractiveGrid.js @@ -1,7 +1,4 @@ import React from 'react'; -import PropTypes from 'prop-types'; -import { withStyles } from '@material-ui/core/styles'; -import MarkdownElement from 'docs/src/modules/components/MarkdownElement'; import Grid from '@material-ui/core/Grid'; import FormControl from '@material-ui/core/FormControl'; import FormLabel from '@material-ui/core/FormLabel'; @@ -9,8 +6,13 @@ import FormControlLabel from '@material-ui/core/FormControlLabel'; import RadioGroup from '@material-ui/core/RadioGroup'; import Radio from '@material-ui/core/Radio'; import Paper from '@material-ui/core/Paper'; +import { makeStyles } from '@material-ui/core/styles'; +// We don't have a typescript version of MarkdownElement +// tslint:disable-next-line: ban-ts-ignore +// @ts-ignore +import MarkdownElement from 'docs/src/modules/components/MarkdownElement'; -const styles = theme => ({ +const useStyles = makeStyles(theme => ({ root: { flexGrow: 1, }, @@ -25,26 +27,15 @@ const styles = theme => ({ control: { padding: theme.spacing(2), }, -}); - -class InteractiveGrid extends React.Component { - state = { - direction: 'row', - justify: 'center', - alignItems: 'center', - }; +})); - handleChange = key => (event, value) => { - this.setState({ - [key]: value, - }); - }; +function InteractiveGrid() { + const classes = useStyles(); + const [direction, setDirection] = React.useState('row'); + const [justify, setJustify] = React.useState('center'); + const [alignItems, setAlignItems] = React.useState('center'); - render() { - const { classes } = this.props; - const { alignItems, direction, justify } = this.state; - - const code = ` + const code = ` \`\`\`jsx - - - {[0, 1, 2].map(value => ( - - - {`Cell ${value + 1}`} - - - ))} - - - - - - - - direction - - } label="row" /> - } label="row-reverse" /> - } label="column" /> - } - label="column-reverse" - /> - - - - - - justify - - } label="flex-start" /> - } label="center" /> - } label="flex-end" /> - } - label="space-between" - /> - } - label="space-around" - /> - } - label="space-evenly" - /> - - - - - - alignItems - - } label="flex-start" /> - } label="center" /> - } label="flex-end" /> - } label="stretch" /> - } label="baseline" /> - - - + return ( + + + + {[0, 1, 2].map(value => ( + + + {`Cell ${value + 1}`} + - - - - + ))} - ); - } + + + + + + direction + setDirection(value)} + > + } label="row" /> + } label="row-reverse" /> + } label="column" /> + } + label="column-reverse" + /> + + + + + + justify + setJustify(value)} + > + } label="flex-start" /> + } label="center" /> + } label="flex-end" /> + } + label="space-between" + /> + } label="space-around" /> + } label="space-evenly" /> + + + + + + alignItems + setAlignItems(value)} + > + } label="flex-start" /> + } label="center" /> + } label="flex-end" /> + } label="stretch" /> + } label="baseline" /> + + + + + + + + + + + ); } -InteractiveGrid.propTypes = { - classes: PropTypes.object.isRequired, -}; - -export default withStyles(styles)(InteractiveGrid); +export default InteractiveGrid; diff --git a/docs/src/pages/components/grid/InteractiveGrid.tsx b/docs/src/pages/components/grid/InteractiveGrid.tsx new file mode 100644 index 00000000000000..f9e4fe338aa4ed --- /dev/null +++ b/docs/src/pages/components/grid/InteractiveGrid.tsx @@ -0,0 +1,149 @@ +import React from 'react'; +import Grid, { GridItemsAlignment, GridJustification, GridDirection } from '@material-ui/core/Grid'; +import FormControl from '@material-ui/core/FormControl'; +import FormLabel from '@material-ui/core/FormLabel'; +import FormControlLabel from '@material-ui/core/FormControlLabel'; +import RadioGroup from '@material-ui/core/RadioGroup'; +import Radio from '@material-ui/core/Radio'; +import Paper from '@material-ui/core/Paper'; +import { makeStyles, createStyles, Theme } from '@material-ui/core/styles'; +// We don't have a typescript version of MarkdownElement +// tslint:disable-next-line: ban-ts-ignore +// @ts-ignore +import MarkdownElement from 'docs/src/modules/components/MarkdownElement'; + +const useStyles = makeStyles((theme: Theme) => + createStyles({ + root: { + flexGrow: 1, + }, + demo: { + height: 240, + }, + paper: { + padding: theme.spacing(2), + height: '100%', + color: theme.palette.text.secondary, + }, + control: { + padding: theme.spacing(2), + }, + }), +); + +function InteractiveGrid() { + const classes = useStyles(); + const [direction, setDirection] = React.useState('row'); + const [justify, setJustify] = React.useState('center'); + const [alignItems, setAlignItems] = React.useState('center'); + + const code = ` +\`\`\`jsx + +\`\`\` +`; + + return ( + + + + {[0, 1, 2].map(value => ( + + + {`Cell ${value + 1}`} + + + ))} + + + + + + + + direction + setDirection(value as GridDirection)} + > + } label="row" /> + } label="row-reverse" /> + } label="column" /> + } + label="column-reverse" + /> + + + + + + justify + setJustify(value as GridJustification)} + > + } label="flex-start" /> + } label="center" /> + } label="flex-end" /> + } + label="space-between" + /> + } label="space-around" /> + } label="space-evenly" /> + + + + + + alignItems + setAlignItems(value as GridItemsAlignment)} + > + } label="flex-start" /> + } label="center" /> + } label="flex-end" /> + } label="stretch" /> + } label="baseline" /> + + + + + + + + + + + ); +} + +export default InteractiveGrid; diff --git a/docs/src/pages/components/grid/NestedGrid.js b/docs/src/pages/components/grid/NestedGrid.js index 08b0747cec2e83..07a316efe546ea 100644 --- a/docs/src/pages/components/grid/NestedGrid.js +++ b/docs/src/pages/components/grid/NestedGrid.js @@ -1,10 +1,9 @@ import React from 'react'; -import PropTypes from 'prop-types'; -import { withStyles } from '@material-ui/core/styles'; +import { makeStyles } from '@material-ui/core/styles'; import Paper from '@material-ui/core/Paper'; import Grid from '@material-ui/core/Grid'; -const styles = theme => ({ +const useStyles = makeStyles(theme => ({ root: { flexGrow: 1, }, @@ -13,52 +12,42 @@ const styles = theme => ({ textAlign: 'center', color: theme.palette.text.secondary, }, -}); +})); -function FormRow(props) { - const { classes } = props; +function NestedGrid() { + const classes = useStyles(); - return ( - - - item - - - item - - - item - - - ); -} - -FormRow.propTypes = { - classes: PropTypes.object.isRequired, -}; - -function NestedGrid(props) { - const { classes } = props; + function FormRow() { + return ( + + + item + + + item + + + item + + + ); + } return (
- + - + - +
); } -NestedGrid.propTypes = { - classes: PropTypes.object.isRequired, -}; - -export default withStyles(styles)(NestedGrid); +export default NestedGrid; diff --git a/docs/src/pages/components/grid/NestedGrid.tsx b/docs/src/pages/components/grid/NestedGrid.tsx new file mode 100644 index 00000000000000..674bc984207afb --- /dev/null +++ b/docs/src/pages/components/grid/NestedGrid.tsx @@ -0,0 +1,55 @@ +import React from 'react'; +import { makeStyles, createStyles, Theme } from '@material-ui/core/styles'; +import Paper from '@material-ui/core/Paper'; +import Grid from '@material-ui/core/Grid'; + +const useStyles = makeStyles((theme: Theme) => + createStyles({ + root: { + flexGrow: 1, + }, + paper: { + padding: theme.spacing(1), + textAlign: 'center', + color: theme.palette.text.secondary, + }, + }), +); + +function NestedGrid() { + const classes = useStyles(); + + function FormRow() { + return ( + + + item + + + item + + + item + + + ); + } + + return ( +
+ + + + + + + + + + + +
+ ); +} + +export default NestedGrid; diff --git a/docs/src/pages/components/grid/SpacingGrid.js b/docs/src/pages/components/grid/SpacingGrid.js index 3c419995e4e1c6..c2842de1f6b917 100644 --- a/docs/src/pages/components/grid/SpacingGrid.js +++ b/docs/src/pages/components/grid/SpacingGrid.js @@ -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 Grid from '@material-ui/core/Grid'; import FormLabel from '@material-ui/core/FormLabel'; import FormControlLabel from '@material-ui/core/FormControlLabel'; @@ -8,7 +7,7 @@ import RadioGroup from '@material-ui/core/RadioGroup'; import Radio from '@material-ui/core/Radio'; import Paper from '@material-ui/core/Paper'; -const styles = theme => ({ +const useStyles = makeStyles(theme => ({ root: { flexGrow: 1, }, @@ -19,69 +18,54 @@ const styles = theme => ({ control: { padding: theme.spacing(2), }, -}); +})); -class GuttersGrid extends React.Component { - state = { - spacing: '2', - }; +function SpacingGrid() { + const [spacing, setSpacing] = React.useState(2); + const classes = useStyles(); - handleChange = key => (event, value) => { - this.setState({ - [key]: value, - }); - }; - - render() { - const { classes } = this.props; - const { spacing } = this.state; + function handleChange(event, value) { + setSpacing(Number(value)); + } - return ( - - - - {[0, 1, 2].map(value => ( - - - - ))} - - - - - - - spacing - - } label="0" /> - } label="1" /> - } label="2" /> - } label="3" /> - } label="4" /> - } label="5" /> - } label="6" /> - } label="7" /> - } label="8" /> - } label="9" /> - } label="10" /> - - + return ( + + + + {[0, 1, 2].map(value => ( + + - + ))} - ); - } + + + + + spacing + + {[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(value => ( + } + label={value.toString()} + /> + ))} + + + + + +
+ ); } -GuttersGrid.propTypes = { - classes: PropTypes.object.isRequired, -}; - -export default withStyles(styles)(GuttersGrid); +export default SpacingGrid; diff --git a/docs/src/pages/components/grid/SpacingGrid.tsx b/docs/src/pages/components/grid/SpacingGrid.tsx new file mode 100644 index 00000000000000..62ad9d8375f7e2 --- /dev/null +++ b/docs/src/pages/components/grid/SpacingGrid.tsx @@ -0,0 +1,73 @@ +import React from 'react'; +import { makeStyles, createStyles, Theme } from '@material-ui/core/styles'; +import Grid, { GridSpacing } from '@material-ui/core/Grid'; +import FormLabel from '@material-ui/core/FormLabel'; +import FormControlLabel from '@material-ui/core/FormControlLabel'; +import RadioGroup from '@material-ui/core/RadioGroup'; +import Radio from '@material-ui/core/Radio'; +import Paper from '@material-ui/core/Paper'; + +const useStyles = makeStyles((theme: Theme) => + createStyles({ + root: { + flexGrow: 1, + }, + paper: { + height: 140, + width: 100, + }, + control: { + padding: theme.spacing(2), + }, + }), +); + +function SpacingGrid() { + const [spacing, setSpacing] = React.useState(2); + const classes = useStyles(); + + function handleChange(event: any, value: string) { + setSpacing(Number(value) as GridSpacing); + } + + return ( + + + + {[0, 1, 2].map(value => ( + + + + ))} + + + + + + + spacing + + {[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(value => ( + } + label={value.toString()} + /> + ))} + + + + + + + ); +} + +export default SpacingGrid;