Created
August 21, 2017 16:59
-
-
Save blvdmitry/51d2a17d551268e78a43f278c84d977a to your computer and use it in GitHub Desktop.
Margin example 3
This file contains hidden or 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
import React from 'react'; | |
import c from 'classnames'; | |
import injectSheet from 'react-jss'; | |
import s from './styles'; | |
class Group extends React.PureComponent { | |
render() { | |
const { children = [], inline, classes, className, small } = this.props; | |
const rootClassNames = c( | |
classes.group, | |
className, | |
inline && classes['group-inline'], | |
small && classes['group-small'], | |
); | |
return ( | |
<div className={rootClassNames}> | |
{ | |
React.Children.map(children, child => | |
child && ( | |
<div className={classes.groupItem} key={child.key}> | |
{ child } | |
</div> | |
), | |
) | |
} | |
</div> | |
); | |
} | |
} | |
export default injectSheet(s)(Group); |
This file contains hidden or 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
export default { | |
group: { | |
margin: '-16px 0 0 -16px', | |
}, | |
groupItem: { | |
padding: '16px 0 0 16px', | |
}, | |
'group-inline': { | |
'& $groupItem': { | |
display: 'inline-block', | |
verticalAlign: 'middle', | |
}, | |
}, | |
'group-small': { | |
margin: '-8px 0 0 -8px', | |
'& $groupItem': { | |
padding: '8px 0 0 8px', | |
}, | |
}, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment