| 
									
										
										
										
											2015-07-24 21:54:19 -07:00
										 |  |  | import React, { PropTypes } from 'react'; | 
					
						
							| 
									
										
										
										
											2015-07-23 22:58:44 -07:00
										 |  |  | import { | 
					
						
							|  |  |  |   Col, | 
					
						
							| 
									
										
										
										
											2015-07-24 21:54:19 -07:00
										 |  |  |   CollapsibleNav, | 
					
						
							| 
									
										
										
										
											2015-07-23 22:58:44 -07:00
										 |  |  |   Nav, | 
					
						
							|  |  |  |   Navbar, | 
					
						
							|  |  |  |   NavItem | 
					
						
							|  |  |  | } from 'react-bootstrap'; | 
					
						
							| 
									
										
										
										
											2015-07-03 19:50:18 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | import navLinks from './links.json'; | 
					
						
							| 
									
										
										
										
											2015-07-03 19:34:20 -07:00
										 |  |  | import FCCNavItem from './NavItem.jsx'; | 
					
						
							| 
									
										
										
										
											2015-06-04 10:53:01 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-03 19:50:18 -07:00
										 |  |  | const fCClogo = 'https://s3.amazonaws.com/freecodecamp/freecodecamp_logo.svg'; | 
					
						
							|  |  |  | const navElements = navLinks.map((navItem, index) => { | 
					
						
							|  |  |  |   return ( | 
					
						
							|  |  |  |     <NavItem | 
					
						
							|  |  |  |       eventKey={ index + 1 } | 
					
						
							| 
									
										
										
										
											2015-07-23 15:41:01 -07:00
										 |  |  |       href={ navItem.link } | 
					
						
							|  |  |  |       key={ index }> | 
					
						
							| 
									
										
										
										
											2015-07-03 19:50:18 -07:00
										 |  |  |       { navItem.content } | 
					
						
							|  |  |  |     </NavItem> | 
					
						
							|  |  |  |   ); | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const logoElement = ( | 
					
						
							|  |  |  |   <a href='/'> | 
					
						
							|  |  |  |     <img | 
					
						
							|  |  |  |       alt='learn to code javascript at Free Code Camp logo' | 
					
						
							|  |  |  |       className='img-responsive nav-logo' | 
					
						
							|  |  |  |       src={ fCClogo } /> | 
					
						
							|  |  |  |   </a> | 
					
						
							|  |  |  | ); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-23 22:58:44 -07:00
										 |  |  | const toggleButton = ( | 
					
						
							|  |  |  |   <button className='hamburger'> | 
					
						
							|  |  |  |     <Col xs={ 12 }> | 
					
						
							|  |  |  |       <span className='hamburger-text'>Menu</span> | 
					
						
							|  |  |  |     </Col> | 
					
						
							|  |  |  |   </button> | 
					
						
							|  |  |  | ); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-17 21:04:28 -07:00
										 |  |  | export default class extends React.Component { | 
					
						
							|  |  |  |   constructor(props) { | 
					
						
							|  |  |  |     super(props); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2015-06-04 10:53:01 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-17 21:04:28 -07:00
										 |  |  |   static displayName = 'Nav' | 
					
						
							|  |  |  |   static propTypes = { | 
					
						
							| 
									
										
										
										
											2015-07-24 21:54:19 -07:00
										 |  |  |     points: PropTypes.number, | 
					
						
							|  |  |  |     picture: PropTypes.string, | 
					
						
							|  |  |  |     signedIn: PropTypes.bool, | 
					
						
							|  |  |  |     username: PropTypes.string | 
					
						
							| 
									
										
										
										
											2015-06-17 21:04:28 -07:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2015-06-04 10:53:01 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-24 21:54:19 -07:00
										 |  |  |   renderPoints(username, points) { | 
					
						
							|  |  |  |     if (!username) { | 
					
						
							|  |  |  |       return null; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return ( | 
					
						
							|  |  |  |       <NavItem | 
					
						
							|  |  |  |         href={ '/' + username }> | 
					
						
							|  |  |  |         [ { points } ] | 
					
						
							|  |  |  |       </NavItem> | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   renderSignin(username, picture) { | 
					
						
							|  |  |  |     if (username) { | 
					
						
							| 
									
										
										
										
											2015-06-04 10:53:01 -07:00
										 |  |  |       return ( | 
					
						
							| 
									
										
										
										
											2015-07-24 21:54:19 -07:00
										 |  |  |         <div | 
					
						
							|  |  |  |           className='hidden-xs hidden-sm' | 
					
						
							| 
									
										
										
										
											2015-06-04 10:53:01 -07:00
										 |  |  |           eventKey={ 2 }> | 
					
						
							| 
									
										
										
										
											2015-07-24 21:54:19 -07:00
										 |  |  |           <a href={ '/' + username }> | 
					
						
							| 
									
										
										
										
											2015-07-28 11:18:11 -07:00
										 |  |  |             <img | 
					
						
							|  |  |  |               className='profile-picture float-right' | 
					
						
							|  |  |  |               src={ picture } /> | 
					
						
							| 
									
										
										
										
											2015-07-24 21:54:19 -07:00
										 |  |  |           </a> | 
					
						
							|  |  |  |         </div> | 
					
						
							| 
									
										
										
										
											2015-06-04 10:53:01 -07:00
										 |  |  |       ); | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |       return ( | 
					
						
							| 
									
										
										
										
											2015-07-03 19:34:20 -07:00
										 |  |  |         <FCCNavItem | 
					
						
							| 
									
										
										
										
											2015-06-29 09:50:25 -07:00
										 |  |  |           className='btn signup-btn signup-btn-nav' | 
					
						
							| 
									
										
										
										
											2015-06-04 10:53:01 -07:00
										 |  |  |           eventKey={ 2 } | 
					
						
							| 
									
										
										
										
											2015-06-17 21:04:28 -07:00
										 |  |  |           href='/login'> | 
					
						
							|  |  |  |           Sign In | 
					
						
							| 
									
										
										
										
											2015-07-03 19:34:20 -07:00
										 |  |  |         </FCCNavItem> | 
					
						
							| 
									
										
										
										
											2015-06-04 10:53:01 -07:00
										 |  |  |       ); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2015-06-17 21:04:28 -07:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2015-06-04 10:53:01 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-17 21:04:28 -07:00
										 |  |  |   render() { | 
					
						
							| 
									
										
										
										
											2015-07-24 21:54:19 -07:00
										 |  |  |     const { username, points, picture } = this.props; | 
					
						
							| 
									
										
										
										
											2015-06-04 10:53:01 -07:00
										 |  |  |     return ( | 
					
						
							|  |  |  |       <Navbar | 
					
						
							| 
									
										
										
										
											2015-07-03 19:50:18 -07:00
										 |  |  |         brand={ logoElement } | 
					
						
							| 
									
										
										
										
											2015-06-17 21:04:28 -07:00
										 |  |  |         className='nav-height' | 
					
						
							| 
									
										
										
										
											2015-06-04 10:53:01 -07:00
										 |  |  |         fixedTop={ true } | 
					
						
							| 
									
										
										
										
											2015-07-23 22:58:44 -07:00
										 |  |  |         toggleButton={ toggleButton } | 
					
						
							| 
									
										
										
										
											2015-06-17 21:04:28 -07:00
										 |  |  |         toggleNavKey={ 0 }> | 
					
						
							| 
									
										
										
										
											2015-07-24 21:54:19 -07:00
										 |  |  |         <CollapsibleNav eventKey={ 0 }> | 
					
						
							|  |  |  |           <Nav | 
					
						
							|  |  |  |             className='hamburger-dropdown' | 
					
						
							|  |  |  |             navbar={ true } | 
					
						
							|  |  |  |             right={ true }> | 
					
						
							|  |  |  |             { navElements } | 
					
						
							|  |  |  |             { this.renderPoints(username, points)} | 
					
						
							|  |  |  |             { this.renderSignin(username, picture) } | 
					
						
							|  |  |  |           </Nav> | 
					
						
							|  |  |  |         </CollapsibleNav> | 
					
						
							| 
									
										
										
										
											2015-06-04 10:53:01 -07:00
										 |  |  |       </Navbar> | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2015-06-17 21:04:28 -07:00
										 |  |  | } |