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.
* NavBrand react component implementation * Deprecation of brand attribute of Navbar component Docs and Example * Update examples that were using Navbar brand attribute * Update docs description adding NavBrand component usage, removed documentation for Navbar brand attribute * Update related components used Navbar brand attribute, replacing it with NavBrand component * Update react-bootstrap website header using NavBrand component Navbar Component * Add deprecation warning message in Navbar Component for the brand attribute usage * Change logic rendering for Navbar component based on its child components, using a specific method for NavBrand rendering and the other existing one for other children - passing navbar, toggleNavKey, toggleButton, handleToggle and key to NavBrand for its render functionality * Add functionality needed once brand attribute is totally removed from Navbar component Utils - ValidComponentChildren * Added find functionality, returning children based on condition specified in callback function Tests * Create NavBrand specs * Updated test of Navbar component - assert deprecation warning messages - add new assertions for the NavBrand component used inside Navbar component
- Loading branch information
Konstantinos Leimonis
committed
Sep 27, 2015
1 parent
3edf4a1
commit b5a9f3a
Showing
14 changed files
with
239 additions
and
14 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 |
---|---|---|
|
@@ -31,6 +31,7 @@ | |
"ListGroup", | ||
"ListGroupItem", | ||
"Nav", | ||
"NavBrand", | ||
"Navbar", | ||
"NavDropdown", | ||
"NavItem", | ||
|
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import React, { cloneElement } from 'react'; | ||
import BootstrapMixin from './BootstrapMixin'; | ||
import classNames from 'classnames'; | ||
|
||
const NavBrand = React.createClass({ | ||
mixins: [BootstrapMixin], | ||
|
||
propTypes: { | ||
bsRole: React.PropTypes.string, | ||
navbar: React.PropTypes.bool | ||
}, | ||
|
||
getDefaultProps() { | ||
return { | ||
bsRole: 'brand', | ||
navbar: false | ||
}; | ||
}, | ||
|
||
render() { | ||
let brand; | ||
|
||
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 | ||
}); | ||
} else { | ||
brand = <span {...this.props} className="navbar-brand">{this.props.children}</span>; | ||
} | ||
|
||
return 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import React from 'react'; | ||
import ReactTestUtils from 'react/lib/ReactTestUtils'; | ||
// import Navbar from '../src/Navbar'; | ||
import NavBrand from '../src/NavBrand'; | ||
|
||
describe('Navbrand', () => { | ||
|
||
it('Should create navbrand SPAN element', () => { | ||
let instance = ReactTestUtils.renderIntoDocument( | ||
<NavBrand>Brand</NavBrand> | ||
); | ||
|
||
let brand = React.findDOMNode(instance); | ||
|
||
assert.equal(brand.nodeName, 'SPAN'); | ||
assert.ok(brand.className.match(/\bnavbar-brand\b/)); | ||
assert.equal(brand.innerText, 'Brand'); | ||
}); | ||
|
||
it('Should create navbrand A (link) element', () => { | ||
let instance = ReactTestUtils.renderIntoDocument( | ||
<NavBrand><a href>BrandLink</a></NavBrand> | ||
); | ||
|
||
let brand = React.findDOMNode(instance); | ||
|
||
assert.equal(brand.nodeName, 'A'); | ||
assert.ok(brand.className.match(/\bnavbar-brand\b/)); | ||
assert.equal(brand.innerText, 'BrandLink'); | ||
}); | ||
|
||
}); |
Oops, something went wrong.