UNPKG

1.87 kBJavaScriptView Raw
1import _extends from 'babel-runtime/helpers/extends';
2import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
3import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
4import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
5import _inherits from 'babel-runtime/helpers/inherits';
6import classNames from 'classnames';
7import React from 'react';
8import PropTypes from 'prop-types';
9import elementType from 'prop-types-extra/lib/elementType';
10
11import { bsClass, prefix, splitBsProps } from './utils/bootstrapUtils';
12
13var propTypes = {
14 /**
15 * Turn any fixed-width grid layout into a full-width layout by this property.
16 *
17 * Adds `container-fluid` class.
18 */
19 fluid: PropTypes.bool,
20 /**
21 * You can use a custom element for this component
22 */
23 componentClass: elementType
24};
25
26var defaultProps = {
27 componentClass: 'div',
28 fluid: false
29};
30
31var Grid = function (_React$Component) {
32 _inherits(Grid, _React$Component);
33
34 function Grid() {
35 _classCallCheck(this, Grid);
36
37 return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
38 }
39
40 Grid.prototype.render = function render() {
41 var _props = this.props,
42 fluid = _props.fluid,
43 Component = _props.componentClass,
44 className = _props.className,
45 props = _objectWithoutProperties(_props, ['fluid', 'componentClass', 'className']);
46
47 var _splitBsProps = splitBsProps(props),
48 bsProps = _splitBsProps[0],
49 elementProps = _splitBsProps[1];
50
51 var classes = prefix(bsProps, fluid && 'fluid');
52
53 return React.createElement(Component, _extends({}, elementProps, { className: classNames(className, classes) }));
54 };
55
56 return Grid;
57}(React.Component);
58
59Grid.propTypes = propTypes;
60Grid.defaultProps = defaultProps;
61
62export default bsClass('container', Grid);
\No newline at end of file