-
Notifications
You must be signed in to change notification settings - Fork 398
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
133 additions
and
4 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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import React, { PropTypes } from 'react'; | ||
import { Link } from 'react-router'; | ||
|
||
import 'core/components/NavBar/styles.scss'; | ||
|
||
export const NavBarItem = ({ children }) => <span className="NavBarItem">{children}</span>; | ||
NavBarItem.propTypes = { | ||
children: PropTypes.node, | ||
}; | ||
|
||
export const NavBarLink = ({ children, ...props }) => ( | ||
<NavBarItem> | ||
<Link {...props} className="NavBarLink">{children}</Link> | ||
</NavBarItem> | ||
); | ||
NavBarLink.propTypes = { | ||
children: PropTypes.node, | ||
}; | ||
|
||
export const NavBar = ({ children }) => <div className="NavBar">{children}</div>; | ||
NavBar.propTypes = { | ||
children: PropTypes.node, | ||
}; |
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,29 @@ | ||
.NavBar { | ||
align-items: center; | ||
justify-content: space-between; | ||
background: #444; | ||
display: flex; | ||
height: 50px; | ||
padding: 0 10px; | ||
width: 100%; | ||
} | ||
|
||
.NavBarLink { | ||
background: transparent; | ||
border: none; | ||
border-radius: 4px; | ||
color: #fff; | ||
display: block; | ||
height: 30px; | ||
line-height: 30px; | ||
min-width: 50px; | ||
padding: 0 10px; | ||
text-decoration: none; | ||
transition: 200ms; | ||
|
||
&:hover { | ||
background-color: #fff; | ||
color: #444; | ||
cursor: pointer; | ||
} | ||
} |
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,17 @@ | ||
import React, { PropTypes } from 'react'; | ||
|
||
import { | ||
NavBar, | ||
NavBarLink, | ||
} from 'core/components/NavBar'; | ||
|
||
const SearchNavBar = () => ( | ||
<NavBar> | ||
<NavBarLink to="/search">Search</NavBarLink> | ||
</NavBar> | ||
); | ||
SearchNavBar.propTypes = { | ||
logout: PropTypes.func.isRequired, | ||
}; | ||
|
||
export default SearchNavBar; |
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,33 @@ | ||
import React from 'react'; | ||
import { shallowRender } from 'tests/client/helpers'; | ||
import { Link } from 'react-router'; | ||
|
||
import { NavBar, NavBarItem, NavBarLink } from 'core/components/NavBar'; | ||
|
||
describe('<NavBarItem />', () => { | ||
it('wraps its children in a span', () => { | ||
const root = shallowRender(<NavBarItem>Foo</NavBarItem>); | ||
assert.equal(root.props.className, 'NavBarItem'); | ||
assert.equal(root.type, 'span'); | ||
assert.equal(root.props.children, 'Foo'); | ||
}); | ||
}); | ||
|
||
describe('<NavBarLink />', () => { | ||
it('wraps its children in a span', () => { | ||
const root = shallowRender(<NavBarLink to="/bar">Baileys Taproom</NavBarLink>); | ||
assert.equal(root.type, NavBarItem); | ||
assert.equal(root.props.children.type, Link); | ||
assert.equal(root.props.children.props.to, '/bar'); | ||
assert.equal(root.props.children.props.children, 'Baileys Taproom'); | ||
}); | ||
}); | ||
|
||
describe('<NavBar />', () => { | ||
it('wraps its children in a div', () => { | ||
const root = shallowRender(<NavBar>Navigate places!</NavBar>); | ||
assert.equal(root.type, 'div'); | ||
assert.equal(root.props.className, 'NavBar'); | ||
assert.equal(root.props.children, 'Navigate places!'); | ||
}); | ||
}); |
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,16 @@ | ||
import React from 'react'; | ||
import { shallowRender } from 'tests/client/helpers'; | ||
|
||
import { NavBar, NavBarLink } from 'core/components/NavBar'; | ||
import SearchNavBar from 'search/components/NavBar'; | ||
|
||
describe('<SearchNavBar />', () => { | ||
it('renders a link to Search', () => { | ||
const root = shallowRender(<SearchNavBar />); | ||
assert.equal(root.type, NavBar); | ||
const link = root.props.children; | ||
assert.equal(link.type, NavBarLink); | ||
assert.equal(link.props.to, '/search'); | ||
assert.equal(link.props.children, 'Search'); | ||
}); | ||
}); |
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