forked from react-bootstrap/react-bootstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fixed] Show toggle button when using NavBrand
Also simplified the rendering code a bit.
- Loading branch information
Showing
3 changed files
with
125 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,32 @@ | ||
import React, { cloneElement } from 'react'; | ||
import BootstrapMixin from './BootstrapMixin'; | ||
import classNames from 'classnames'; | ||
import React from 'react'; | ||
|
||
const NavBrand = React.createClass({ | ||
mixins: [BootstrapMixin], | ||
|
||
propTypes: { | ||
bsRole: React.PropTypes.string, | ||
navbar: React.PropTypes.bool | ||
}, | ||
|
||
getDefaultProps() { | ||
return { | ||
bsRole: 'brand', | ||
navbar: false | ||
}; | ||
}, | ||
|
||
class NavBrand extends React.Component { | ||
render() { | ||
let brand; | ||
const {className, children, ...props} = this.props; | ||
|
||
if (React.isValidElement(this.props.children)) { | ||
brand = cloneElement(this.props.children, { | ||
className: classNames(this.props.children.props.className, 'navbar-brand'), | ||
bsRole: this.props.bsRole, | ||
navbar: this.props.navbar | ||
if (React.isValidElement(children)) { | ||
return React.cloneElement(children, { | ||
className: classNames( | ||
children.props.className, className, 'navbar-brand' | ||
) | ||
}); | ||
} else { | ||
brand = <span {...this.props} className="navbar-brand">{this.props.children}</span>; | ||
} | ||
|
||
return brand; | ||
return ( | ||
<span {...props} className={classNames(className, 'navbar-brand')}> | ||
{children} | ||
</span> | ||
); | ||
} | ||
} | ||
|
||
NavBrand.propTypes = { | ||
bsRole: React.PropTypes.string | ||
}; | ||
|
||
}); | ||
NavBrand.defaultProps = { | ||
bsRole: 'brand' | ||
}; | ||
|
||
export default NavBrand; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters