File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ export default class NavsPage extends React.Component {
3333 fixed: PropTypes.string,
3434 color: PropTypes.string,
3535 role: PropTypes.string,
36- toggleable: PropTypes.string,
36+ toggleable: PropTypes.oneOfType([PropTypes.bool, PropTypes. string]) ,
3737 tag: PropTypes.oneOfType([PropTypes.func, PropTypes.string])
3838 // pass in custom element to use
3939}` }
Original file line number Diff line number Diff line change @@ -12,13 +12,23 @@ const propTypes = {
1212 tag : PropTypes . oneOfType ( [ PropTypes . func , PropTypes . string ] ) ,
1313 className : PropTypes . string ,
1414 cssModule : PropTypes . object ,
15- toggleable : PropTypes . string ,
15+ toggleable : PropTypes . oneOfType ( [ PropTypes . bool , PropTypes . string ] ) ,
1616} ;
1717
1818const defaultProps = {
1919 tag : 'nav' ,
2020 role : 'navigation' ,
21- toggleable : '' ,
21+ toggleable : false ,
22+ } ;
23+
24+ const getToggleableClass = ( toggleable ) => {
25+ if ( toggleable === false ) {
26+ return false ;
27+ } else if ( toggleable === true || toggleable === 'xs' ) {
28+ return 'navbar-toggleable' ;
29+ }
30+
31+ return `navbar-toggleable-${ toggleable } ` ;
2232} ;
2333
2434const Navbar = ( props ) => {
@@ -38,7 +48,7 @@ const Navbar = (props) => {
3848 const classes = mapToCssModules ( classNames (
3949 className ,
4050 'navbar' ,
41- toggleable === '' ? 'navbar-toggleable' : `navbar-toggleable- ${ toggleable } ` ,
51+ getToggleableClass ( toggleable ) ,
4252 {
4353 'navbar-light' : light ,
4454 'navbar-inverse' : inverse ,
Original file line number Diff line number Diff line change @@ -6,19 +6,31 @@ describe('Navbar', () => {
66 it ( 'should render .navbar markup' , ( ) => {
77 const wrapper = shallow ( < Navbar /> ) ;
88
9+ expect ( wrapper . html ( ) ) . toBe ( '<nav role="navigation" class="navbar"></nav>' ) ;
10+ } ) ;
11+
12+ it ( 'should render default .navbar-toggleable class' , ( ) => {
13+ const wrapper = shallow ( < Navbar toggleable /> ) ;
14+
915 expect ( wrapper . html ( ) ) . toBe ( '<nav role="navigation" class="navbar navbar-toggleable"></nav>' ) ;
1016 } ) ;
1117
18+ it ( 'should render size based .navbar-toggleable-* classes' , ( ) => {
19+ const wrapper = shallow ( < Navbar toggleable = "md" /> ) ;
20+
21+ expect ( wrapper . html ( ) ) . toBe ( '<nav role="navigation" class="navbar navbar-toggleable-md"></nav>' ) ;
22+ } ) ;
23+
1224 it ( 'should render custom tag' , ( ) => {
1325 const wrapper = shallow ( < Navbar tag = "div" /> ) ;
1426
15- expect ( wrapper . html ( ) ) . toBe ( '<div role="navigation" class="navbar navbar-toggleable "></div>' ) ;
27+ expect ( wrapper . html ( ) ) . toBe ( '<div role="navigation" class="navbar"></div>' ) ;
1628 } ) ;
1729
1830 it ( 'sholid render children' , ( ) => {
1931 const wrapper = shallow ( < Navbar > Children</ Navbar > ) ;
2032
21- expect ( wrapper . html ( ) ) . toBe ( '<nav role="navigation" class="navbar navbar-toggleable ">Children</nav>' ) ;
33+ expect ( wrapper . html ( ) ) . toBe ( '<nav role="navigation" class="navbar">Children</nav>' ) ;
2234 } ) ;
2335
2436 it ( 'should pass additional classNames' , ( ) => {
You can’t perform that action at this time.
0 commit comments