UNPKG

cpui-components

Version:

77 lines (58 loc) 2.95 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.Container = undefined; var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _propTypes = require('prop-types'); var _propTypes2 = _interopRequireDefault(_propTypes); var _constants = require('./../../constants'); var _constants2 = _interopRequireDefault(_constants); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var Container = exports.Container = function (_Component) { _inherits(Container, _Component); function Container(props) { _classCallCheck(this, Container); var _this = _possibleConstructorReturn(this, (Container.__proto__ || Object.getPrototypeOf(Container)).call(this, props)); _this.render = function () { return _react2.default.createElement( 'div', _this.props, _this.props.clearfix && _react2.default.createElement('span', { style: _this.styles.clearfix }), _this.props.children, _this.props.clearfix && _react2.default.createElement('span', { style: _this.styles.clearfix }) ); }; _this.styles = { clearfix: { clear: 'both', display: 'table' }, container: { marginLeft: 'auto', marginRight: 'auto', maxWidth: _this.props.maxWidth, paddingLeft: _this.props.gutter, paddingRight: _this.props.gutter } }; props.style = _extends({}, _this.styles.container, _this.props.style); return _this; } return Container; }(_react.Component); Container.propTypes = { clearfix: _propTypes2.default.bool, gutter: _propTypes2.default.number, maxWidth: _propTypes2.default.number }; Container.defaultProps = { gutter: _constants2.default.width.gutter, maxWidth: _constants2.default.width.container }; exports.default = Container;