Skip to content

Commit 461eb3d

Browse files
sottaroliviertassinari
authored andcommitted
[docs] Add an One line example for GridLists
Thanks @sottar. Closes mui#5258. Closes mui#5300.
1 parent bc2a0a6 commit 461eb3d

4 files changed

Lines changed: 98 additions & 12 deletions

File tree

docs/src/app/components/pages/components/GridList/ExampleComplex.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ const styles = {
1313
width: 500,
1414
height: 450,
1515
overflowY: 'auto',
16-
marginBottom: 24,
1716
},
1817
};
1918

@@ -62,6 +61,10 @@ const tilesData = [
6261
},
6362
];
6463

64+
/**
65+
* This example demonstrates "featured" tiles, using the `rows` and `cols` props to adjust the size of the tile.
66+
* The tiles have a customised title, positioned at the top and with a custom gradient `titleBackground`.
67+
*/
6568
const GridListExampleComplex = () => (
6669
<div style={styles.root}>
6770
<GridList

docs/src/app/components/pages/components/GridList/ExampleSimple.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ const styles = {
1212
},
1313
gridList: {
1414
width: 500,
15-
height: 500,
15+
height: 450,
1616
overflowY: 'auto',
17-
marginBottom: 24,
1817
},
1918
};
2019

@@ -61,10 +60,13 @@ const tilesData = [
6160
},
6261
];
6362

63+
/**
64+
* A simple example of a scrollable `GridList` containing a [Subheader](/#/components/subheader).
65+
*/
6466
const GridListExampleSimple = () => (
6567
<div style={styles.root}>
6668
<GridList
67-
cellHeight={200}
69+
cellHeight={180}
6870
style={styles.gridList}
6971
>
7072
<Subheader>December</Subheader>
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
import React from 'react';
2+
import {GridList, GridTile} from 'material-ui/GridList';
3+
import IconButton from 'material-ui/IconButton';
4+
import StarBorder from 'material-ui/svg-icons/toggle/star-border';
5+
6+
const styles = {
7+
root: {
8+
display: 'flex',
9+
flexWrap: 'wrap',
10+
justifyContent: 'space-around',
11+
},
12+
gridList: {
13+
display: 'flex',
14+
flexWrap: 'nowrap',
15+
overflowX: 'auto',
16+
},
17+
};
18+
19+
const tilesData = [
20+
{
21+
img: 'images/grid-list/00-52-29-429_640.jpg',
22+
title: 'Breakfast',
23+
author: 'jill111',
24+
},
25+
{
26+
img: 'images/grid-list/burger-827309_640.jpg',
27+
title: 'Tasty burger',
28+
author: 'pashminu',
29+
},
30+
{
31+
img: 'images/grid-list/camera-813814_640.jpg',
32+
title: 'Camera',
33+
author: 'Danson67',
34+
},
35+
{
36+
img: 'images/grid-list/morning-819362_640.jpg',
37+
title: 'Morning',
38+
author: 'fancycrave1',
39+
},
40+
{
41+
img: 'images/grid-list/hats-829509_640.jpg',
42+
title: 'Hats',
43+
author: 'Hans',
44+
},
45+
{
46+
img: 'images/grid-list/honey-823614_640.jpg',
47+
title: 'Honey',
48+
author: 'fancycravel',
49+
},
50+
{
51+
img: 'images/grid-list/vegetables-790022_640.jpg',
52+
title: 'Vegetables',
53+
author: 'jill111',
54+
},
55+
{
56+
img: 'images/grid-list/water-plant-821293_640.jpg',
57+
title: 'Water plant',
58+
author: 'BkrmadtyaKarki',
59+
},
60+
];
61+
62+
/**
63+
* This example demonstrates the horizontal scrollable single-line grid list of images.
64+
*/
65+
const GridListExampleSingleLine = () => (
66+
<div style={styles.root}>
67+
<GridList style={styles.gridList} cols={2.2}>
68+
{tilesData.map((tile) => (
69+
<GridTile
70+
key={tile.img}
71+
title={tile.title}
72+
actionIcon={<IconButton><StarBorder color="white" /></IconButton>}
73+
>
74+
<img src={tile.img} />
75+
</GridTile>
76+
))}
77+
</GridList>
78+
</div>
79+
);
80+
81+
export default GridListExampleSingleLine;

docs/src/app/components/pages/components/GridList/Page.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,33 +10,33 @@ import gridListExampleSimpleCode from '!raw!./ExampleSimple';
1010
import GridListExampleSimple from './ExampleSimple';
1111
import gridListExampleComplexCode from '!raw!./ExampleComplex';
1212
import GridListExampleComplex from './ExampleComplex';
13+
import gridListExampleSingleLineCode from '!raw!./ExampleSingleLine';
14+
import GridListExampleSingleLine from './ExampleSingleLine';
1315
import gridListCode from '!raw!material-ui/GridList/GridList';
1416
import gridTileCode from '!raw!material-ui/GridList/GridTile';
1517

16-
const descriptions = {
17-
simple: 'A simple example of a scrollable `GridList` containing a [Subheader](/#/components/subheader).',
18-
complex: 'This example demonstrates "featured" tiles, using the `rows` and `cols` props to adjust the size of the ' +
19-
'tile. The tiles have a customised title, positioned at the top and with a custom gradient `titleBackground`.',
20-
};
21-
2218
const GridListPage = () => (
2319
<div>
2420
<Title render={(previousTitle) => `Grid List - ${previousTitle}`} />
2521
<MarkdownElement text={gridListReadmeText} />
2622
<CodeExample
2723
title="Simple example"
28-
description={descriptions.simple}
2924
code={gridListExampleSimpleCode}
3025
>
3126
<GridListExampleSimple />
3227
</CodeExample>
3328
<CodeExample
3429
title="Complex example"
35-
description={descriptions.complex}
3630
code={gridListExampleComplexCode}
3731
>
3832
<GridListExampleComplex />
3933
</CodeExample>
34+
<CodeExample
35+
title="One line example"
36+
code={gridListExampleSingleLineCode}
37+
>
38+
<GridListExampleSingleLine />
39+
</CodeExample>
4040
<PropTypeDescription header="### GridList Properties" code={gridListCode} />
4141
<PropTypeDescription header="### GridTile Properties" code={gridTileCode} />
4242
</div>

0 commit comments

Comments
 (0)