forked from react-bootstrap/react-bootstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClearfix.js
More file actions
78 lines (67 loc) · 1.67 KB
/
Copy pathClearfix.js
File metadata and controls
78 lines (67 loc) · 1.67 KB
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
76
77
78
import classNames from 'classnames';
import React from 'react';
import elementType from 'react-prop-types/lib/elementType';
import { bsClass, getClassSet, splitBsProps } from './utils/bootstrapUtils';
import capitalize from './utils/capitalize';
import { DEVICE_SIZES } from './utils/StyleConfig';
const propTypes = {
componentClass: elementType,
/**
* Apply clearfix
*
* on Extra small devices Phones
*
* adds class `visible-xs-block`
*/
visibleXsBlock: React.PropTypes.bool,
/**
* Apply clearfix
*
* on Small devices Tablets
*
* adds class `visible-sm-block`
*/
visibleSmBlock: React.PropTypes.bool,
/**
* Apply clearfix
*
* on Medium devices Desktops
*
* adds class `visible-md-block`
*/
visibleMdBlock: React.PropTypes.bool,
/**
* Apply clearfix
*
* on Large devices Desktops
*
* adds class `visible-lg-block`
*/
visibleLgBlock: React.PropTypes.bool,
};
const defaultProps = {
componentClass: 'div',
};
class Clearfix extends React.Component {
render() {
const { componentClass: Component, className, ...props } = this.props;
const [bsProps, elementProps] = splitBsProps(props);
const classes = getClassSet(bsProps);
DEVICE_SIZES.forEach(size => {
const propName = `visible${capitalize(size)}Block`;
if (elementProps[propName]) {
classes[`visible-${size}-block`] = true;
}
delete elementProps[propName];
});
return (
<Component
{...elementProps}
className={classNames(className, classes)}
/>
);
}
}
Clearfix.propTypes = propTypes;
Clearfix.defaultProps = defaultProps;
export default bsClass('clearfix', Clearfix);