-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[docs] Migrate Grid demos to hooks (#15970)
* [docs] Migrate Grid demos to hooks * [docs] Fix complaints * [docs] number to string * Update docs/src/pages/components/grid/SpacingGrid.tsx Co-Authored-By: Olivier Tassinari <[email protected]> * docs:typescript:formatted * Fix name
- Loading branch information
1 parent
64e0b6d
commit 1aa38f2
Showing
18 changed files
with
864 additions
and
292 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<div className={classes.root}> | ||
<Grid container spacing={3}> | ||
<Grid item xs> | ||
<Paper className={classes.paper}>xs</Paper> | ||
</Grid> | ||
<Grid item xs> | ||
<Paper className={classes.paper}>xs</Paper> | ||
</Grid> | ||
<Grid item xs> | ||
<Paper className={classes.paper}>xs</Paper> | ||
</Grid> | ||
</Grid> | ||
<Grid container spacing={3}> | ||
<Grid item xs> | ||
<Paper className={classes.paper}>xs</Paper> | ||
</Grid> | ||
<Grid item xs={6}> | ||
<Paper className={classes.paper}>xs=6</Paper> | ||
</Grid> | ||
<Grid item xs> | ||
<Paper className={classes.paper}>xs</Paper> | ||
</Grid> | ||
</Grid> | ||
</div> | ||
); | ||
} | ||
|
||
export default AutoGrid; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<div className={classes.root}> | ||
<Paper className={classes.paper}> | ||
<Grid container wrap="nowrap" spacing={2}> | ||
<Grid item> | ||
<Avatar>W</Avatar> | ||
</Grid> | ||
<Grid item xs zeroMinWidth> | ||
<Typography noWrap>{message}</Typography> | ||
</Grid> | ||
</Grid> | ||
</Paper> | ||
<Paper className={classes.paper}> | ||
<Grid container wrap="nowrap" spacing={2}> | ||
<Grid item> | ||
<Avatar>W</Avatar> | ||
</Grid> | ||
<Grid item xs> | ||
<Typography noWrap>{message}</Typography> | ||
</Grid> | ||
</Grid> | ||
</Paper> | ||
<Paper className={classes.paper}> | ||
<Grid container wrap="nowrap" spacing={2}> | ||
<Grid item> | ||
<Avatar>W</Avatar> | ||
</Grid> | ||
<Grid item xs> | ||
<Typography>{message}</Typography> | ||
</Grid> | ||
</Grid> | ||
</Paper> | ||
</div> | ||
); | ||
} | ||
|
||
export default AutoGridNoWrap; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<div> | ||
<Typography variant="subtitle1" gutterBottom> | ||
Material-UI Grid: | ||
</Typography> | ||
<Grid container spacing={3}> | ||
<Grid item xs={3}> | ||
<Paper className={classes.paper}>xs=3</Paper> | ||
</Grid> | ||
<Grid item xs={3}> | ||
<Paper className={classes.paper}>xs=3</Paper> | ||
</Grid> | ||
<Grid item xs={3}> | ||
<Paper className={classes.paper}>xs=3</Paper> | ||
</Grid> | ||
<Grid item xs={3}> | ||
<Paper className={classes.paper}>xs=3</Paper> | ||
</Grid> | ||
<Grid item xs={8}> | ||
<Paper className={classes.paper}>xs=8</Paper> | ||
</Grid> | ||
<Grid item xs={4}> | ||
<Paper className={classes.paper}>xs=4</Paper> | ||
</Grid> | ||
</Grid> | ||
<Divider className={classes.divider} /> | ||
<Typography variant="subtitle1" gutterBottom> | ||
CSS Grid Layout: | ||
</Typography> | ||
<div className={classes.container}> | ||
<div style={{ gridColumnEnd: 'span 3' }}> | ||
<Paper className={classes.paper}>xs=3</Paper> | ||
</div> | ||
<div style={{ gridColumnEnd: 'span 3' }}> | ||
<Paper className={classes.paper}>xs=3</Paper> | ||
</div> | ||
<div style={{ gridColumnEnd: 'span 3' }}> | ||
<Paper className={classes.paper}>xs=3</Paper> | ||
</div> | ||
<div style={{ gridColumnEnd: 'span 3' }}> | ||
<Paper className={classes.paper}>xs=3</Paper> | ||
</div> | ||
<div style={{ gridColumnEnd: 'span 8' }}> | ||
<Paper className={classes.paper}>xs=8</Paper> | ||
</div> | ||
<div style={{ gridColumnEnd: 'span 4' }}> | ||
<Paper className={classes.paper}>xs=4</Paper> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default CSSGrid; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.