UNPKG

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