1 | import _extends from 'babel-runtime/helpers/extends';
|
2 | import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
|
3 | import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
|
4 | import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
|
5 | import _inherits from 'babel-runtime/helpers/inherits';
|
6 | import classNames from 'classnames';
|
7 | import React from 'react';
|
8 | import PropTypes from 'prop-types';
|
9 |
|
10 | import { prefix } from './utils/bootstrapUtils';
|
11 | import createChainedFunction from './utils/createChainedFunction';
|
12 |
|
13 | var propTypes = {
|
14 | onClick: PropTypes.func,
|
15 | |
16 |
|
17 |
|
18 | children: PropTypes.node
|
19 | };
|
20 |
|
21 | var contextTypes = {
|
22 | $bs_navbar: PropTypes.shape({
|
23 | bsClass: PropTypes.string,
|
24 | expanded: PropTypes.bool,
|
25 | onToggle: PropTypes.func.isRequired
|
26 | })
|
27 | };
|
28 |
|
29 | var NavbarToggle = function (_React$Component) {
|
30 | _inherits(NavbarToggle, _React$Component);
|
31 |
|
32 | function NavbarToggle() {
|
33 | _classCallCheck(this, NavbarToggle);
|
34 |
|
35 | return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
|
36 | }
|
37 |
|
38 | NavbarToggle.prototype.render = function render() {
|
39 | var _props = this.props,
|
40 | onClick = _props.onClick,
|
41 | className = _props.className,
|
42 | children = _props.children,
|
43 | props = _objectWithoutProperties(_props, ['onClick', 'className', 'children']);
|
44 |
|
45 | var navbarProps = this.context.$bs_navbar || { bsClass: 'navbar' };
|
46 |
|
47 | var buttonProps = _extends({
|
48 | type: 'button'
|
49 | }, props, {
|
50 | onClick: createChainedFunction(onClick, navbarProps.onToggle),
|
51 | className: classNames(className, prefix(navbarProps, 'toggle'), !navbarProps.expanded && 'collapsed')
|
52 | });
|
53 |
|
54 | if (children) {
|
55 | return React.createElement(
|
56 | 'button',
|
57 | buttonProps,
|
58 | children
|
59 | );
|
60 | }
|
61 |
|
62 | return React.createElement(
|
63 | 'button',
|
64 | buttonProps,
|
65 | React.createElement(
|
66 | 'span',
|
67 | { className: 'sr-only' },
|
68 | 'Toggle navigation'
|
69 | ),
|
70 | React.createElement('span', { className: 'icon-bar' }),
|
71 | React.createElement('span', { className: 'icon-bar' }),
|
72 | React.createElement('span', { className: 'icon-bar' })
|
73 | );
|
74 | };
|
75 |
|
76 | return NavbarToggle;
|
77 | }(React.Component);
|
78 |
|
79 | NavbarToggle.propTypes = propTypes;
|
80 | NavbarToggle.contextTypes = contextTypes;
|
81 |
|
82 | export default NavbarToggle; |
\ | No newline at end of file |