Skip to content

Instantly share code, notes, and snippets.

@blvdmitry
Created August 21, 2017 16:59
Show Gist options
  • Save blvdmitry/51d2a17d551268e78a43f278c84d977a to your computer and use it in GitHub Desktop.
Save blvdmitry/51d2a17d551268e78a43f278c84d977a to your computer and use it in GitHub Desktop.
Margin example 3
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);
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