import React, { PropTypes } from 'react'; import ReactDOM from 'react-dom'; import { LinkContainer } from 'react-router-bootstrap'; import { Col, Nav, NavbarBrand, Navbar, NavItem } from 'react-bootstrap'; import navLinks from './links.json'; import FCCNavItem from './NavItem.jsx'; const fCClogo = 'https://s3.amazonaws.com/freecodecamp/freecodecamp_logo.svg'; const logoElement = ( learn to code javascript at Free Code Camp logo ); const toggleButtonChild = ( Menu ); export default class extends React.Component { static displayName = 'Nav'; static contextTypes = { router: PropTypes.object }; static propTypes = { points: PropTypes.number, picture: PropTypes.string, signedIn: PropTypes.bool, username: PropTypes.string, updateNavHeight: PropTypes.func, toggleMapDrawer: PropTypes.func, toggleMainChat: PropTypes.func }; componentDidMount() { const navBar = ReactDOM.findDOMNode(this); this.props.updateNavHeight(navBar.clientHeight); } renderMapLink(isOnMap, toggleMapDrawer) { if (isOnMap) { return (
  • e.preventDefault()} > Map
  • ); } return ( { if (!(e.ctrlKey || e.metaKey)) { e.preventDefault(); toggleMapDrawer(); } }} target='/map' > Map ); } renderChat(toggleMainChat) { return ( { if (!(e.ctrlKey || e.metaKey)) { e.preventDefault(); toggleMainChat(); } }} target='_blank' > Chat ); } renderLinks() { return navLinks.map(({ content, link, react, target }, index) => { if (react) { return ( { content } ); } return ( { content } ); }); } renderPoints(username, points) { if (!username) { return null; } return ( [ { points } ] ); } renderSignin(username, picture) { if (username) { return (
  • ); } else { return ( Sign In ); } } render() { const { username, points, picture, toggleMapDrawer, toggleMainChat } = this.props; const { router } = this.context; const isOnMap = router.isActive('/map'); return ( { logoElement } ); } }