UNPKG

1.54 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 React from 'react';
7import PropTypes from 'prop-types';
8
9import Collapse from './Collapse';
10import { prefix } from './utils/bootstrapUtils';
11
12var contextTypes = {
13 $bs_navbar: PropTypes.shape({
14 bsClass: PropTypes.string,
15 expanded: PropTypes.bool
16 })
17};
18
19var NavbarCollapse = function (_React$Component) {
20 _inherits(NavbarCollapse, _React$Component);
21
22 function NavbarCollapse() {
23 _classCallCheck(this, NavbarCollapse);
24
25 return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
26 }
27
28 NavbarCollapse.prototype.render = function render() {
29 var _props = this.props,
30 children = _props.children,
31 props = _objectWithoutProperties(_props, ['children']);
32
33 var navbarProps = this.context.$bs_navbar || { bsClass: 'navbar' };
34
35 var bsClassName = prefix(navbarProps, 'collapse');
36
37 return React.createElement(
38 Collapse,
39 _extends({ 'in': navbarProps.expanded }, props),
40 React.createElement(
41 'div',
42 { className: bsClassName },
43 children
44 )
45 );
46 };
47
48 return NavbarCollapse;
49}(React.Component);
50
51NavbarCollapse.contextTypes = contextTypes;
52
53export default NavbarCollapse;
\No newline at end of file