-
Notifications
You must be signed in to change notification settings - Fork 126
/
columns.js
70 lines (65 loc) · 1.66 KB
/
columns.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import CONSTANTS from '../../constants';
import Column from './components/column';
import COLUMN_CONSTANTS from './constants';
const breakpoints = [null].concat(Object.keys(CONSTANTS.BREAKPOINTS).map(key => CONSTANTS.BREAKPOINTS[key]));
export default class Columns extends PureComponent {
static propTypes = {
children: PropTypes.node,
className: PropTypes.string,
style: PropTypes.object,
/**
* Breakpoint where columns become stacked.
*/
breakpoint: PropTypes.oneOf(breakpoints),
/**
* `true` to remove space between columns
*/
gapless: PropTypes.bool,
/**
* `true` if you want to use more than one line if you add more column elements that would fit in a single row.
*/
multiline: PropTypes.bool,
/**
* `true` you want the columns inside to be horizontaly centered
*/
centered: PropTypes.bool,
}
static defaultProps = {
children: null,
className: '',
style: {},
breakpoint: null,
gapless: false,
centered: false,
multiline: true,
}
static Column = Column
static CONSTANTS = COLUMN_CONSTANTS
render() {
const {
children,
className,
style,
breakpoint,
gapless,
multiline,
centered,
} = this.props;
return (
<div
className={classNames(className, 'columns', {
[`is-${breakpoint}`]: breakpoint,
'is-gapless': gapless,
'is-multiline': multiline,
'is-centered': centered,
})}
style={style}
>
{children}
</div>
);
}
}