-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
50 lines (44 loc) · 954 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import React from 'react';
import PropTypes from 'prop-types';
import cx from 'classnames';
const Row = (props) => {
const cols = React.Children.map(props.children, (col) => {
if (props.gutter) {
return React.cloneElement(col, {
style: {
paddingLeft: props.gutter / 2,
paddingRight: props.gutter / 2,
...col.props.style
}
});
}
return col;
});
let style;
if (props.gutter) {
style = {
marginLeft: props.gutter / 2 * -1,
marginRight: props.gutter / 2 * -1,
...props.style
};
}
return (
<div className={ cx('row', props.className) } style={ style }>
{ cols }
</div>
);
};
Row.propTypes = {
gutter: PropTypes.number,
style: PropTypes.object,
className: PropTypes.string,
};
Row.defaultProps = {
gutter: 15,
style: {}
};
Row.displayName = 'GridRow';
Row.propTypes = {
children: PropTypes.node
};
export default Row;