Skip to content

Commit

Permalink
render user picture and mobile nav
Browse files Browse the repository at this point in the history
  • Loading branch information
Berkeley Martinez authored and Berkeley Martinez committed Jul 25, 2015
1 parent 81b1c81 commit 9a236d1
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 15 deletions.
10 changes: 8 additions & 2 deletions common/app/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,19 @@ export default contain(
displayName: 'FreeCodeCamp',

propTypes: {
children: PropTypes.node
children: PropTypes.node,
username: PropTypes.string,
points: PropTypes.number,
picture: PropTypes.string
},

render() {
const { username, points, picture } = this.props;
const navProps = { username, points, picture };
return (
<div>
<Nav />
<Nav
{ ...navProps }/>
<Row>
{ this.props.children }
</Row>
Expand Down
50 changes: 37 additions & 13 deletions common/app/components/Nav/Nav.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import React, { PropTypes } from 'react';
import {
Col,
CollapsibleNav,
Nav,
Navbar,
NavItem
Expand Down Expand Up @@ -45,16 +46,34 @@ export default class extends React.Component {

static displayName = 'Nav'
static propTypes = {
signedIn: React.PropTypes.bool
points: PropTypes.number,
picture: PropTypes.string,
signedIn: PropTypes.bool,
username: PropTypes.string
}

renderSignin() {
if (this.props.signedIn) {
renderPoints(username, points) {
if (!username) {
return null;
}
return (
<NavItem
href={ '/' + username }>
[ { points } ]
</NavItem>
);
}

renderSignin(username, picture) {
if (username) {
return (
<NavItem
<div
className='hidden-xs hidden-sm'
eventKey={ 2 }>
Show Picture
</NavItem>
<a href={ '/' + username }>
<img src={ picture } />
</a>
</div>
);
} else {
return (
Expand All @@ -69,19 +88,24 @@ export default class extends React.Component {
}

render() {
const { username, points, picture } = this.props;
return (
<Navbar
brand={ logoElement }
className='nav-height'
fixedTop={ true }
toggleButton={ toggleButton }
toggleNavKey={ 0 }>
<Nav
eventKey={ 0 }
right={ true }>
{ navElements }
{ this.renderSignin() }
</Nav>
<CollapsibleNav eventKey={ 0 }>
<Nav
className='hamburger-dropdown'
navbar={ true }
right={ true }>
{ navElements }
{ this.renderPoints(username, points)}
{ this.renderSignin(username, picture) }
</Nav>
</CollapsibleNav>
</Navbar>
);
}
Expand Down

0 comments on commit 9a236d1

Please sign in to comment.