-
Notifications
You must be signed in to change notification settings - Fork 134
/
Copy pathhorizontal-split.jsx
41 lines (35 loc) · 1016 Bytes
/
horizontal-split.jsx
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
import { Row, Col, Container } from "../helpers/bootstrap";
import React from "react";
export class HorizontalSplit extends React.Component {
static COLUMN_CLASSES = {
1: ["xs-12"],
2: ["xs-12", "lg-6"],
3: ["xs-12", "lg-4"],
4: ["xs-12", "sm-6", "lg-3"],
6: ["xs-12", "sm-6", "lg-4"],
12: ["xs-12", "sm-6", "lg-3"],
};
static propTypes = {
padding: React.PropTypes.oneOf(["sm", "md", "lg"]),
};
static defaultProps = {
padding: "sm",
};
render() {
const numSections = this.props.children.length;
if (12 % numSections !== 0) {
return null;
}
return (
<Row className={`neal-horizontal-split neal-horizontal-split-${this.props.padding}`}>
{this.props.children.map((child, idx) => {
return (
<Col size={HorizontalSplit.COLUMN_CLASSES[numSections]} className="neal-horizontal-split-col" key={idx}>
{child}
</Col>
);
})}
</Row>
);
}
}