1 | var _excluded = ["expand", "className", "cssModule", "light", "dark", "fixed", "sticky", "color", "container", "tag", "children"];
|
2 | function _extends() { _extends = Object.assign ? Object.assign.bind() : 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; }; return _extends.apply(this, arguments); }
|
3 | function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
4 | function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
5 | function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
6 | import React from 'react';
|
7 | import PropTypes from 'prop-types';
|
8 | import classNames from 'classnames';
|
9 | import { mapToCssModules, tagPropType } from './utils';
|
10 | var propTypes = {
|
11 | children: PropTypes.node,
|
12 |
|
13 | className: PropTypes.string,
|
14 |
|
15 | color: PropTypes.string,
|
16 |
|
17 | container: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
|
18 |
|
19 | cssModule: PropTypes.object,
|
20 |
|
21 | dark: PropTypes.bool,
|
22 |
|
23 | expand: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
|
24 |
|
25 | fixed: PropTypes.string,
|
26 |
|
27 | light: PropTypes.bool,
|
28 | role: PropTypes.string,
|
29 |
|
30 | sticky: PropTypes.string,
|
31 |
|
32 | tag: tagPropType
|
33 | };
|
34 | var getExpandClass = function getExpandClass(expand) {
|
35 | if (expand === false) {
|
36 | return false;
|
37 | }
|
38 | if (expand === true || expand === 'xs') {
|
39 | return 'navbar-expand';
|
40 | }
|
41 | return "navbar-expand-".concat(expand);
|
42 | };
|
43 | function Navbar(props) {
|
44 | var _classNames;
|
45 | var _props$expand = props.expand,
|
46 | expand = _props$expand === void 0 ? false : _props$expand,
|
47 | className = props.className,
|
48 | cssModule = props.cssModule,
|
49 | light = props.light,
|
50 | dark = props.dark,
|
51 | fixed = props.fixed,
|
52 | sticky = props.sticky,
|
53 | color = props.color,
|
54 | _props$container = props.container,
|
55 | container = _props$container === void 0 ? 'fluid' : _props$container,
|
56 | _props$tag = props.tag,
|
57 | Tag = _props$tag === void 0 ? 'nav' : _props$tag,
|
58 | children = props.children,
|
59 | attributes = _objectWithoutProperties(props, _excluded);
|
60 | var classes = mapToCssModules(classNames(className, 'navbar', getExpandClass(expand), (_classNames = {
|
61 | 'navbar-light': light,
|
62 | 'navbar-dark': dark
|
63 | }, _defineProperty(_classNames, "bg-".concat(color), color), _defineProperty(_classNames, "fixed-".concat(fixed), fixed), _defineProperty(_classNames, "sticky-".concat(sticky), sticky), _classNames)), cssModule);
|
64 | var containerClass = container && container === true ? 'container' : "container-".concat(container);
|
65 | return React.createElement(Tag, _extends({}, attributes, {
|
66 | className: classes
|
67 | }), container ? React.createElement("div", {
|
68 | className: containerClass
|
69 | }, children) : children);
|
70 | }
|
71 | Navbar.propTypes = propTypes;
|
72 | export default Navbar; |
\ | No newline at end of file |