forked from reactstrap/reactstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContainer.js
More file actions
38 lines (30 loc) · 898 Bytes
/
Container.js
File metadata and controls
38 lines (30 loc) · 898 Bytes
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
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { mapToCssModules, tagPropType } from './utils';
const propTypes = {
tag: tagPropType,
fluid: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
className: PropTypes.string,
cssModule: PropTypes.object,
};
const defaultProps = {
tag: 'div',
};
function Container(props) {
const { className, cssModule, fluid, tag: Tag, ...attributes } = props;
let containerClass = 'container';
if (fluid === true) {
containerClass = 'container-fluid';
} else if (fluid) {
containerClass = `container-${fluid}`;
}
const classes = mapToCssModules(
classNames(className, containerClass),
cssModule,
);
return <Tag {...attributes} className={classes} />;
}
Container.propTypes = propTypes;
Container.defaultProps = defaultProps;
export default Container;