UNPKG

1.9 kBJavaScriptView Raw
1import _extends from "@babel/runtime/helpers/esm/extends";
2import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3import React from 'react';
4import PropTypes from 'prop-types';
5import classNames from 'classnames';
6import { mapToCssModules, tagPropType } from './utils';
7var propTypes = {
8 light: PropTypes.bool,
9 dark: PropTypes.bool,
10 full: PropTypes.bool,
11 fixed: PropTypes.string,
12 sticky: PropTypes.string,
13 color: PropTypes.string,
14 role: PropTypes.string,
15 tag: tagPropType,
16 className: PropTypes.string,
17 cssModule: PropTypes.object,
18 expand: PropTypes.oneOfType([PropTypes.bool, PropTypes.string])
19};
20var defaultProps = {
21 tag: 'nav',
22 expand: false
23};
24
25var getExpandClass = function getExpandClass(expand) {
26 if (expand === false) {
27 return false;
28 } else if (expand === true || expand === 'xs') {
29 return 'navbar-expand';
30 }
31
32 return "navbar-expand-" + expand;
33};
34
35var Navbar = function Navbar(props) {
36 var _classNames;
37
38 var expand = props.expand,
39 className = props.className,
40 cssModule = props.cssModule,
41 light = props.light,
42 dark = props.dark,
43 fixed = props.fixed,
44 sticky = props.sticky,
45 color = props.color,
46 Tag = props.tag,
47 attributes = _objectWithoutPropertiesLoose(props, ["expand", "className", "cssModule", "light", "dark", "fixed", "sticky", "color", "tag"]);
48
49 var classes = mapToCssModules(classNames(className, 'navbar', getExpandClass(expand), (_classNames = {
50 'navbar-light': light,
51 'navbar-dark': dark
52 }, _classNames["bg-" + color] = color, _classNames["fixed-" + fixed] = fixed, _classNames["sticky-" + sticky] = sticky, _classNames)), cssModule);
53 return React.createElement(Tag, _extends({}, attributes, {
54 className: classes
55 }));
56};
57
58Navbar.propTypes = propTypes;
59Navbar.defaultProps = defaultProps;
60export default Navbar;
\No newline at end of file