forked from react-bootstrap/react-bootstrap-bower
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCol.js
75 lines (64 loc) · 2.04 KB
/
Col.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
71
72
73
74
75
define(function (require, exports, module) {var React = require('react');
var joinClasses = require('./utils/joinClasses');
var classSet = require('./utils/classSet');
var constants = require('./constants');
var Col = React.createClass({displayName: 'Col',
propTypes: {
xs: React.PropTypes.number,
sm: React.PropTypes.number,
md: React.PropTypes.number,
lg: React.PropTypes.number,
xsOffset: React.PropTypes.number,
smOffset: React.PropTypes.number,
mdOffset: React.PropTypes.number,
lgOffset: React.PropTypes.number,
xsPush: React.PropTypes.number,
smPush: React.PropTypes.number,
mdPush: React.PropTypes.number,
lgPush: React.PropTypes.number,
xsPull: React.PropTypes.number,
smPull: React.PropTypes.number,
mdPull: React.PropTypes.number,
lgPull: React.PropTypes.number,
componentClass: React.PropTypes.node.isRequired
},
getDefaultProps: function () {
return {
componentClass: 'div'
};
},
render: function () {
var ComponentClass = this.props.componentClass;
var classes = {};
Object.keys(constants.SIZES).forEach(function (key) {
var size = constants.SIZES[key];
var prop = size;
var classPart = size + '-';
if (this.props[prop]) {
classes['col-' + classPart + this.props[prop]] = true;
}
prop = size + 'Offset';
classPart = size + '-offset-';
if (this.props[prop]) {
classes['col-' + classPart + this.props[prop]] = true;
}
prop = size + 'Push';
classPart = size + '-push-';
if (this.props[prop]) {
classes['col-' + classPart + this.props[prop]] = true;
}
prop = size + 'Pull';
classPart = size + '-pull-';
if (this.props[prop]) {
classes['col-' + classPart + this.props[prop]] = true;
}
}, this);
return (
React.createElement(ComponentClass, React.__spread({}, this.props, {className: joinClasses(this.props.className, classSet(classes))}),
this.props.children
)
);
}
});
module.exports = Col;
});