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] Improve the docs of the Grid component #25429

Merged
merged 3 commits into from
Mar 21, 2021
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
5 changes: 5 additions & 0 deletions docs/src/pages/components/box/box.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,8 @@ import Box from '@material-ui/core/Box';
## System props

As a CSS utility component, the `Box` also supports all [`system`](/system/properties/) properties. You can use them as prop directly on the component.
For instance, a margin-top:

```jsx
<Box mt={2}>
```
16 changes: 3 additions & 13 deletions docs/src/pages/components/grid/AutoGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,16 @@ import Paper from '@material-ui/core/Paper';
import Grid from '@material-ui/core/Grid';

const Item = styled(Paper)(({ theme }) => ({
padding: theme.spacing(2),
// TODO withStyles removal
...theme.typography.body2,
padding: theme.spacing(1),
textAlign: 'center',
color: theme.palette.text.secondary,
}));

export default function AutoGrid() {
return (
<Box sx={{ flexGrow: 1 }}>
<Grid container spacing={3}>
<Grid item xs>
<Item>xs</Item>
</Grid>
<Grid item xs>
<Item>xs</Item>
</Grid>
<Grid item xs>
<Item>xs</Item>
</Grid>
</Grid>
<br />
<Grid container spacing={3}>
<Grid item xs>
<Item>xs</Item>
Expand Down
17 changes: 4 additions & 13 deletions docs/src/pages/components/grid/AutoGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,19 @@ import { experimentalStyled as styled } from '@material-ui/core/styles';
import Box from '@material-ui/core/Box';
import Paper from '@material-ui/core/Paper';
import Grid from '@material-ui/core/Grid';
import * as CSS from 'csstype';

const Item = styled(Paper)(({ theme }) => ({
padding: theme.spacing(2),
// TODO withStyles removal
...(theme.typography.body2 as CSS.Properties),
padding: theme.spacing(1),
textAlign: 'center',
color: theme.palette.text.secondary,
}));

export default function AutoGrid() {
return (
<Box sx={{ flexGrow: 1 }}>
<Grid container spacing={3}>
<Grid item xs>
<Item>xs</Item>
</Grid>
<Grid item xs>
<Item>xs</Item>
</Grid>
<Grid item xs>
<Item>xs</Item>
</Grid>
</Grid>
<br />
<Grid container spacing={3}>
<Grid item xs>
<Item>xs</Item>
Expand Down
34 changes: 34 additions & 0 deletions docs/src/pages/components/grid/BasicGrid.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import * as React from 'react';
import { experimentalStyled as styled } from '@material-ui/core/styles';
import Box from '@material-ui/core/Box';
import Paper from '@material-ui/core/Paper';
import Grid from '@material-ui/core/Grid';

const Item = styled(Paper)(({ theme }) => ({
// TODO withStyles removal
...theme.typography.body2,
padding: theme.spacing(1),
textAlign: 'center',
color: theme.palette.text.secondary,
}));

export default function BasicGrid() {
return (
<Box sx={{ flexGrow: 1 }}>
<Grid container spacing={2}>
<Grid item xs={8}>
<Item>xs=8</Item>
</Grid>
<Grid item xs={4}>
<Item>xs=4</Item>
</Grid>
<Grid item xs={4}>
<Item>xs=4</Item>
</Grid>
<Grid item xs={8}>
<Item>xs=8</Item>
</Grid>
</Grid>
</Box>
);
}
35 changes: 35 additions & 0 deletions docs/src/pages/components/grid/BasicGrid.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import * as React from 'react';
import { experimentalStyled as styled } from '@material-ui/core/styles';
import Box from '@material-ui/core/Box';
import Paper from '@material-ui/core/Paper';
import Grid from '@material-ui/core/Grid';
import * as CSS from 'csstype';

const Item = styled(Paper)(({ theme }) => ({
// TODO withStyles removal
...(theme.typography.body2 as CSS.Properties),
padding: theme.spacing(1),
textAlign: 'center',
color: theme.palette.text.secondary,
}));

export default function BasicGrid() {
return (
<Box sx={{ flexGrow: 1 }}>
<Grid container spacing={2}>
<Grid item xs={8}>
<Item>xs=8</Item>
</Grid>
<Grid item xs={4}>
<Item>xs=4</Item>
</Grid>
<Grid item xs={4}>
<Item>xs=4</Item>
</Grid>
<Grid item xs={8}>
<Item>xs=8</Item>
</Grid>
</Grid>
</Box>
);
}
58 changes: 11 additions & 47 deletions docs/src/pages/components/grid/CSSGrid.js
Original file line number Diff line number Diff line change
@@ -1,69 +1,33 @@
import * as React from 'react';
import { experimentalStyled as styled } from '@material-ui/core/styles';
import Box from '@material-ui/core/Box';
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 Item = styled(Paper)(({ theme }) => ({
// TODO withStyles removal
...theme.typography.body2,
padding: theme.spacing(1),
textAlign: 'center',
color: theme.palette.text.secondary,
whiteSpace: 'nowrap',
marginBottom: theme.spacing(1),
}));

export default function CSSGrid() {
return (
<div>
<Typography variant="subtitle1" gutterBottom component="div">
Material-UI Grid:
</Typography>
<Grid container spacing={3}>
<Grid item xs={3}>
<Item>xs=3</Item>
</Grid>
<Grid item xs={3}>
<Item>xs=3</Item>
</Grid>
<Grid item xs={3}>
<Item>xs=3</Item>
</Grid>
<Grid item xs={3}>
<Item>xs=3</Item>
</Grid>
<Grid item xs={8}>
<Box sx={{ width: 1 }}>
<Box display="grid" gridTemplateColumns="repeat(12, 1fr)" gap={2}>
<Box gridColumn="auto / span 8">
<Item>xs=8</Item>
</Grid>
<Grid item xs={4}>
<Item>xs=4</Item>
</Grid>
</Grid>
<Divider sx={{ my: 2 }} />
<Typography variant="subtitle1" gutterBottom component="div">
CSS Grid Layout:
</Typography>
<Box sx={{ display: 'grid', gridTemplateColumns: 'repeat(12, 1fr)', gap: 3 }}>
<Box sx={{ gridColumnEnd: 'span 3' }}>
<Item>xs=3</Item>
</Box>
<Box sx={{ gridColumnEnd: 'span 3' }}>
<Item>xs=3</Item>
</Box>
<Box sx={{ gridColumnEnd: 'span 3' }}>
<Item>xs=3</Item>
<Box gridColumn="auto / span 4">
<Item>xs=4</Item>
</Box>
<Box sx={{ gridColumnEnd: 'span 3' }}>
<Item>xs=3</Item>
<Box gridColumn="auto / span 4">
<Item>xs=4</Item>
</Box>
<Box sx={{ gridColumnEnd: 'span 8' }}>
<Box gridColumn="auto / span 8">
<Item>xs=8</Item>
</Box>
<Box sx={{ gridColumnEnd: 'span 4' }}>
<Item>xs=4</Item>
</Box>
</Box>
</div>
</Box>
);
}
59 changes: 12 additions & 47 deletions docs/src/pages/components/grid/CSSGrid.tsx
Original file line number Diff line number Diff line change
@@ -1,69 +1,34 @@
import * as React from 'react';
import { experimentalStyled as styled } from '@material-ui/core/styles';
import Box from '@material-ui/core/Box';
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';
import * as CSS from 'csstype';

const Item = styled(Paper)(({ theme }) => ({
// TODO withStyles removal
...(theme.typography.body2 as CSS.Properties),
padding: theme.spacing(1),
textAlign: 'center',
color: theme.palette.text.secondary,
whiteSpace: 'nowrap',
marginBottom: theme.spacing(1),
}));

export default function CSSGrid() {
return (
<div>
<Typography variant="subtitle1" gutterBottom component="div">
Material-UI Grid:
</Typography>
<Grid container spacing={3}>
<Grid item xs={3}>
<Item>xs=3</Item>
</Grid>
<Grid item xs={3}>
<Item>xs=3</Item>
</Grid>
<Grid item xs={3}>
<Item>xs=3</Item>
</Grid>
<Grid item xs={3}>
<Item>xs=3</Item>
</Grid>
<Grid item xs={8}>
<Box sx={{ width: 1 }}>
<Box display="grid" gridTemplateColumns="repeat(12, 1fr)" gap={2}>
<Box gridColumn="auto / span 8">
<Item>xs=8</Item>
</Grid>
<Grid item xs={4}>
<Item>xs=4</Item>
</Grid>
</Grid>
<Divider sx={{ my: 2 }} />
<Typography variant="subtitle1" gutterBottom component="div">
CSS Grid Layout:
</Typography>
<Box sx={{ display: 'grid', gridTemplateColumns: 'repeat(12, 1fr)', gap: 3 }}>
<Box sx={{ gridColumnEnd: 'span 3' }}>
<Item>xs=3</Item>
</Box>
<Box sx={{ gridColumnEnd: 'span 3' }}>
<Item>xs=3</Item>
</Box>
<Box sx={{ gridColumnEnd: 'span 3' }}>
<Item>xs=3</Item>
<Box gridColumn="auto / span 4">
<Item>xs=4</Item>
</Box>
<Box sx={{ gridColumnEnd: 'span 3' }}>
<Item>xs=3</Item>
<Box gridColumn="auto / span 4">
<Item>xs=4</Item>
</Box>
<Box sx={{ gridColumnEnd: 'span 8' }}>
<Box gridColumn="auto / span 8">
<Item>xs=8</Item>
</Box>
<Box sx={{ gridColumnEnd: 'span 4' }}>
<Item>xs=4</Item>
</Box>
</Box>
</div>
</Box>
);
}
41 changes: 0 additions & 41 deletions docs/src/pages/components/grid/CenteredGrid.js

This file was deleted.

41 changes: 0 additions & 41 deletions docs/src/pages/components/grid/CenteredGrid.tsx

This file was deleted.

Loading