Skip to content

Commit

Permalink
Merge pull request #1202 from cozy/fear/labs/GridItem
Browse files Browse the repository at this point in the history
feat(GridItem): Expose experimental GridItem
  • Loading branch information
Crash-- authored Oct 16, 2019
2 parents b43ced1 + b355faf commit 40b4798
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/styleguide.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ module.exports = {
'../react/MuiCozyTheme/ExpansionPanel',
'../react/MuiCozyTheme/Grid'
]
},
{
name: 'Labs',
components: () => ['../react/Labs/GridItem']
}
],
components: '../react/**/*.jsx',
Expand Down
28 changes: 28 additions & 0 deletions react/Labs/GridItem/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
## Grid Item

GridItem is currently experimental since its behavior is
not well defined yet.

```
const MuiCozyTheme = require('../../MuiCozyTheme').default;
const Grid = require('../../MuiCozyTheme/Grid').default;
const GridItem = require('.').default;
const Card = require('../../Card').default;
<MuiCozyTheme>
<Grid container spacing={24}>
<GridItem>
<Card className="u-ellipsis">Homer Simpson</Card>
</GridItem>
<GridItem>
<Card className="u-ellipsis">Homer Simpson</Card>
</GridItem>
<GridItem>
<Card className="u-ellipsis">Homer Simpson</Card>
</GridItem>
<GridItem>
<Card className="u-ellipsis">Homer Simpson</Card>
</GridItem>
</Grid>
</MuiCozyTheme>
```
24 changes: 24 additions & 0 deletions react/Labs/GridItem/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React from 'react'
import PropTypes from 'prop-types'
import cx from 'classnames'
import Grid from '../../MuiCozyTheme/Grid'
import styles from './styles.styl'

const GridItem = ({ onClick, children }) => {
return (
<Grid
item
xs={3}
sm={2}
onClick={() => onClick && onClick()}
className={cx(styles['gridItem-container'])}
>
{children}
</Grid>
)
}
GridItem.propTypes = {
onClick: PropTypes.func,
children: PropTypes.node.isRequired
}
export default GridItem
8 changes: 8 additions & 0 deletions react/Labs/GridItem/styles.styl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.gridItem-container {
text-align center
box-sizing border-box
border-radius 4px
white-space nowrap
overflow hidden
text-overflow ellipsis
}
4 changes: 4 additions & 0 deletions react/Labs/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Labs

In this directory, components you will find are experimental and
subject to API change without creating any breaking change.
Empty file added react/Labs/index.jsx
Empty file.
2 changes: 2 additions & 0 deletions react/__snapshots__/examples.spec.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3307,6 +3307,8 @@ exports[`Label should render examples: Label 3`] = `
</div>"
`;
exports[`Labs/GridItem should render examples: Labs/GridItem 1`] = `"<div></div>"`;
exports[`ListItemText should render examples: ListItemText 1`] = `
"<div>
<div class=\\"styles__c-list-text___3kc3E\\">
Expand Down
1 change: 1 addition & 0 deletions react/examples.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,4 @@ testComponent('Tabs')
testComponent('Text')
testComponent('Textarea')
testComponent('Toggle')
testComponent('Labs/GridItem')

0 comments on commit 40b4798

Please sign in to comment.