From ea179a11c2c789d980cd583f582cfb977f7fea3f Mon Sep 17 00:00:00 2001 From: Cyril Auburtin Date: Sun, 25 Feb 2018 12:18:55 +0100 Subject: [PATCH] [docs] Add CSSGrid comparison example (#10433) * [docs] Add CSSGrid comparison example * add flexbox --- docs/src/pages/layout/grid/AutoGridNoWrap.js | 62 +++++++------- docs/src/pages/layout/grid/CSSGrid.js | 87 ++++++++++++++++++++ docs/src/pages/layout/grid/grid.md | 7 ++ pages/layout/grid.js | 7 ++ 4 files changed, 135 insertions(+), 28 deletions(-) create mode 100644 docs/src/pages/layout/grid/CSSGrid.js diff --git a/docs/src/pages/layout/grid/AutoGridNoWrap.js b/docs/src/pages/layout/grid/AutoGridNoWrap.js index 5afe4e1cbf1766..b7024efbe8d2fc 100644 --- a/docs/src/pages/layout/grid/AutoGridNoWrap.js +++ b/docs/src/pages/layout/grid/AutoGridNoWrap.js @@ -8,7 +8,11 @@ import Typography from 'material-ui/Typography'; const styles = theme => ({ root: { - width: 400, + overflow: 'hidden', + padding: `0 ${theme.spacing.unit * 3}px`, + }, + wrapper: { + maxWidth: 400, }, paper: { margin: theme.spacing.unit, @@ -23,36 +27,38 @@ function AutoGridNoWrap(props) { return (
- - - - W - - - {message} - - - - - - - W - - - {message} +
+ + + + W + + + {message} + - - - - - - W + + + + + W + + + {message} + - - {message} + + + + + W + + + {message} + - - + +
); } diff --git a/docs/src/pages/layout/grid/CSSGrid.js b/docs/src/pages/layout/grid/CSSGrid.js new file mode 100644 index 00000000000000..3abd667a7304dd --- /dev/null +++ b/docs/src/pages/layout/grid/CSSGrid.js @@ -0,0 +1,87 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import { withStyles } from 'material-ui/styles'; +import Typography from 'material-ui/Typography'; +import Paper from 'material-ui/Paper'; +import Divider from 'material-ui/Divider'; +import Grid from 'material-ui/Grid'; + +const styles = theme => ({ + container: { + display: 'grid', + gridTemplateColumns: 'repeat(12, 1fr)', + gridGap: `${theme.spacing.unit * 3}px`, + }, + paper: { + padding: theme.spacing.unit, + textAlign: 'center', + color: theme.palette.text.secondary, + whiteSpace: 'nowrap', + marginBottom: theme.spacing.unit, + }, + divider: { + margin: `${theme.spacing.unit * 2}px 0`, + }, +}); + +function CSSGrid(props) { + const { classes } = props; + + 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 +
+
+
+ ); +} + +CSSGrid.propTypes = { + classes: PropTypes.object.isRequired, +}; + +export default withStyles(styles)(CSSGrid); diff --git a/docs/src/pages/layout/grid/grid.md b/docs/src/pages/layout/grid/grid.md index 073bddccc73263..cb5447728d1fca 100644 --- a/docs/src/pages/layout/grid/grid.md +++ b/docs/src/pages/layout/grid/grid.md @@ -47,6 +47,13 @@ That also means you can set the width of one *item* and the others will automati {{"demo": "pages/layout/grid/AutoGrid.js"}} +## CSS Grid Layout + +**CSS Grid Layout** excels at dividing a page into major regions, or defining the relationship in terms of size, position, and layer, between parts of a control built from HTML primitives. +Unfortunately, CSS grid is only supported by the most recent browsers. + +{{"demo": "pages/layout/grid/CSSGrid.js"}} + ## Limitations ### Negative margin diff --git a/pages/layout/grid.js b/pages/layout/grid.js index 8e0de85fb54a09..806a99182bdd18 100644 --- a/pages/layout/grid.js +++ b/pages/layout/grid.js @@ -41,6 +41,13 @@ module.exports = require('fs') raw: preval` module.exports = require('fs') .readFileSync(require.resolve('docs/src/pages/layout/grid/AutoGrid'), 'utf8') +`, + }, + 'pages/layout/grid/CSSGrid.js': { + js: require('docs/src/pages/layout/grid/CSSGrid').default, + raw: preval` +module.exports = require('fs') + .readFileSync(require.resolve('docs/src/pages/layout/grid/CSSGrid'), 'utf8') `, }, 'pages/layout/grid/AutoGridNoWrap.js': {