-
-
Notifications
You must be signed in to change notification settings - Fork 32.7k
[GridList] add OneLined example #5300
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| import React from 'react'; | ||
| import {GridList, GridTile} from 'material-ui/GridList'; | ||
| import IconButton from 'material-ui/IconButton'; | ||
| import StarBorder from 'material-ui/svg-icons/toggle/star-border'; | ||
|
|
||
| const styles = { | ||
| root: { | ||
| display: 'flex', | ||
| flexWrap: 'wrap', | ||
| justifyContent: 'space-around', | ||
| }, | ||
| gridList: { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That was working fine with: display: flex;
margin: auto;
width: 500px;
overflow-x: auto; |
||
| width: 500, | ||
| height: 200, | ||
| flexWrap: 'nowrap', | ||
| overflowX: 'auto', | ||
| marginBottom: 24, | ||
| }, | ||
| }; | ||
|
|
||
| const tilesData = [ | ||
| { | ||
| img: 'images/grid-list/00-52-29-429_640.jpg', | ||
| title: 'Breakfast', | ||
| author: 'jill111', | ||
| }, | ||
| { | ||
| img: 'images/grid-list/burger-827309_640.jpg', | ||
| title: 'Tasty burger', | ||
| author: 'pashminu', | ||
| }, | ||
| { | ||
| img: 'images/grid-list/camera-813814_640.jpg', | ||
| title: 'Camera', | ||
| author: 'Danson67', | ||
| }, | ||
| { | ||
| img: 'images/grid-list/morning-819362_640.jpg', | ||
| title: 'Morning', | ||
| author: 'fancycrave1', | ||
| }, | ||
| { | ||
| img: 'images/grid-list/hats-829509_640.jpg', | ||
| title: 'Hats', | ||
| author: 'Hans', | ||
| }, | ||
| { | ||
| img: 'images/grid-list/honey-823614_640.jpg', | ||
| title: 'Honey', | ||
| author: 'fancycravel', | ||
| }, | ||
| { | ||
| img: 'images/grid-list/vegetables-790022_640.jpg', | ||
| title: 'Vegetables', | ||
| author: 'jill111', | ||
| }, | ||
| { | ||
| img: 'images/grid-list/water-plant-821293_640.jpg', | ||
| title: 'Water plant', | ||
| author: 'BkrmadtyaKarki', | ||
| }, | ||
| ]; | ||
|
|
||
| const GridListExampleOneLined = () => ( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would be better to add the description like this: /**
* A example of arrange tiles for horizontal scrol...
*/
const GridListExampleOneLined = () => ( |
||
| <div style={styles.root}> | ||
| <GridList | ||
| style={styles.gridList} | ||
| cols="2.2" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It should be a number: |
||
| > | ||
| {tilesData.map((tile) => ( | ||
| <GridTile | ||
| key={tile.img} | ||
| title={tile.title} | ||
| actionIcon={<IconButton><StarBorder color="white" /></IconButton>} | ||
| > | ||
| <img src={tile.img} /> | ||
| </GridTile> | ||
| ))} | ||
| </GridList> | ||
| </div> | ||
| ); | ||
|
|
||
| export default GridListExampleOneLined; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,13 +10,17 @@ import gridListExampleSimpleCode from '!raw!./ExampleSimple'; | |
| import GridListExampleSimple from './ExampleSimple'; | ||
| import gridListExampleComplexCode from '!raw!./ExampleComplex'; | ||
| import GridListExampleComplex from './ExampleComplex'; | ||
| import gridListExampleOneLinedCode from '!raw!./ExampleOneLined'; | ||
| import GridListExampleOneLined from './ExampleOneLined'; | ||
| import gridListCode from '!raw!material-ui/GridList/GridList'; | ||
| import gridTileCode from '!raw!material-ui/GridList/GridTile'; | ||
|
|
||
| const descriptions = { | ||
| simple: 'A simple example of a scrollable `GridList` containing a [Subheader](/#/components/subheader).', | ||
| complex: 'This example demonstrates "featured" tiles, using the `rows` and `cols` props to adjust the size of the ' + | ||
| 'tile. The tiles have a customised title, positioned at the top and with a custom gradient `titleBackground`.', | ||
| onelined: 'A example of arrange tiles for horizontal scrollable one line, using the `cols` props to adjust ' + | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can move the example description above the component definition. |
||
| 'first view of tiles.', | ||
| }; | ||
|
|
||
| const GridListPage = () => ( | ||
|
|
@@ -37,6 +41,13 @@ const GridListPage = () => ( | |
| > | ||
| <GridListExampleComplex /> | ||
| </CodeExample> | ||
| <CodeExample | ||
| title="OneLined example" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm wondering if |
||
| description={descriptions.onelined} | ||
| code={gridListExampleOneLinedCode} | ||
| > | ||
| <GridListExampleOneLined /> | ||
| </CodeExample> | ||
| <PropTypeDescription header="### GridList Properties" code={gridListCode} /> | ||
| <PropTypeDescription header="### GridTile Properties" code={gridTileCode} /> | ||
| </div> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From my own test. This node seems useless.