1
- import React from 'react' ;
2
- import PropTypes from 'prop-types' ;
3
- import classNames from 'classnames' ;
4
- import { mapToCssModules , tagPropType } from './Shared/helper.js' ;
5
-
6
- const getExpandClass = expand => {
7
- if ( expand === false ) {
8
- return false ;
9
- } else if ( expand === true || expand === 'xs' ) {
10
- return 'navbar-expand' ;
11
- }
12
- return `navbar-expand-${ expand } ` ;
13
- } ;
1
+ import React from 'react'
2
+ import PropTypes from 'prop-types'
3
+ import classNames from 'classnames'
4
+ import { mapToCssModules , tagPropType } from './Shared/helper.js'
14
5
15
6
//component - CoreUI / CNavbar
16
7
17
- const CNavbar = props => {
8
+ const CNavbar = props => {
18
9
19
10
const {
20
11
tag : Tag ,
@@ -28,25 +19,24 @@ const CNavbar = props=>{
28
19
sticky,
29
20
color,
30
21
...attributes
31
- } = props ;
22
+ } = props
32
23
33
24
//render
34
25
35
26
const classes = mapToCssModules ( classNames (
36
- className ,
37
- 'navbar' ,
38
- getExpandClass ( expandable ) ,
27
+ 'navbar' , className ,
39
28
light ? 'navbar-light' : 'navbar-dark' ,
40
29
{
30
+ [ `navbar-expand${ expandable === true ? '' : `-${ expandable } ` } ` ] : expandable ,
41
31
[ `bg-${ color } ` ] : color ,
42
32
[ `fixed-${ fixed } ` ] : fixed ,
43
- [ ` sticky-${ sticky } ` ] : sticky ,
33
+ ' sticky-top' : sticky
44
34
}
45
- ) , cssModule ) ;
35
+ ) , cssModule )
46
36
47
37
return (
48
- < Tag { ...attributes } className = { classes } ref = { innerRef } />
49
- ) ;
38
+ < Tag className = { classes } { ...attributes } ref = { innerRef } />
39
+ )
50
40
51
41
}
52
42
@@ -58,14 +48,13 @@ CNavbar.propTypes = {
58
48
innerRef : PropTypes . oneOfType ( [ PropTypes . object , PropTypes . func , PropTypes . string ] ) ,
59
49
light : PropTypes . bool ,
60
50
color : PropTypes . string ,
61
- fixed : PropTypes . string ,
62
- sticky : PropTypes . string ,
51
+ fixed : PropTypes . oneOf ( [ '' , 'top' , 'bottom' ] ) ,
52
+ sticky : PropTypes . bool ,
63
53
expandable : PropTypes . oneOfType ( [ PropTypes . bool , PropTypes . string ] ) ,
64
54
} ;
65
55
66
56
CNavbar . defaultProps = {
67
- tag : 'nav' ,
68
- expandable : false ,
57
+ tag : 'nav'
69
58
} ;
70
59
71
60
export default CNavbar ;
0 commit comments