Add learn button to navbar
This commit is contained in:
@ -12,6 +12,7 @@ import {
|
|||||||
import navLinks from './links.json';
|
import navLinks from './links.json';
|
||||||
import FCCNavItem from './NavItem.jsx';
|
import FCCNavItem from './NavItem.jsx';
|
||||||
|
|
||||||
|
const win = typeof window !== 'undefined' ? window : {};
|
||||||
const fCClogo = 'https://s3.amazonaws.com/freecodecamp/freecodecamp_logo.svg';
|
const fCClogo = 'https://s3.amazonaws.com/freecodecamp/freecodecamp_logo.svg';
|
||||||
|
|
||||||
const logoElement = (
|
const logoElement = (
|
||||||
@ -31,6 +32,16 @@ const toggleButton = (
|
|||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
function getDashedName() {
|
||||||
|
let challengeDashedName;
|
||||||
|
if (typeof win.localStorage !== 'undefined') {
|
||||||
|
challengeDashedName = win.localStorage.getItem('currentDashedName');
|
||||||
|
}
|
||||||
|
return challengeDashedName && challengeDashedName !== 'undefined' ?
|
||||||
|
challengeDashedName :
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
|
||||||
export default React.createClass({
|
export default React.createClass({
|
||||||
displayName: 'Nav',
|
displayName: 'Nav',
|
||||||
|
|
||||||
@ -68,6 +79,22 @@ export default React.createClass({
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
renderLearnBtn() {
|
||||||
|
return (
|
||||||
|
<NavItem
|
||||||
|
href='#'
|
||||||
|
onClick={ () => {
|
||||||
|
const challengeDashedName = getDashedName();
|
||||||
|
const goTo = challengeDashedName ?
|
||||||
|
'/challenges/' + challengeDashedName :
|
||||||
|
'/map';
|
||||||
|
win.location = goTo;
|
||||||
|
}}>
|
||||||
|
Learn
|
||||||
|
</NavItem>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
renderPoints(username, points) {
|
renderPoints(username, points) {
|
||||||
if (!username) {
|
if (!username) {
|
||||||
return null;
|
return null;
|
||||||
@ -107,6 +134,7 @@ export default React.createClass({
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { username, points, picture } = this.props;
|
const { username, points, picture } = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Navbar
|
<Navbar
|
||||||
className='nav-height'
|
className='nav-height'
|
||||||
@ -119,6 +147,7 @@ export default React.createClass({
|
|||||||
className='hamburger-dropdown'
|
className='hamburger-dropdown'
|
||||||
navbar={ true }
|
navbar={ true }
|
||||||
right={ true }>
|
right={ true }>
|
||||||
|
{ this.renderLearnBtn() }
|
||||||
{ this.renderLinks() }
|
{ this.renderLinks() }
|
||||||
{ this.renderPoints(username, points) }
|
{ this.renderPoints(username, points) }
|
||||||
{ this.renderSignin(username, picture) }
|
{ this.renderSignin(username, picture) }
|
||||||
|
@ -17,4 +17,8 @@
|
|||||||
"content": "Jobs",
|
"content": "Jobs",
|
||||||
"link": "/jobs",
|
"link": "/jobs",
|
||||||
"react": true
|
"react": true
|
||||||
|
},{
|
||||||
|
"content": "Links",
|
||||||
|
"link": "/links"
|
||||||
|
},{
|
||||||
}]
|
}]
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
import React from 'react';
|
|
||||||
|
|
||||||
export default class extends React.Component {
|
|
||||||
constructor(props) {
|
|
||||||
super(props);
|
|
||||||
}
|
|
||||||
static displayName = 'NotFound'
|
|
||||||
static propTypes = {}
|
|
||||||
componentDidMount() {
|
|
||||||
}
|
|
||||||
render() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
22
common/app/components/NotFound/index.jsx
Normal file
22
common/app/components/NotFound/index.jsx
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import React, { PropTypes } from 'react';
|
||||||
|
|
||||||
|
const win = typeof window !== 'undefined' ? window : {};
|
||||||
|
|
||||||
|
function goToServer(path) {
|
||||||
|
win.location = '/' + path;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default React.createClass({
|
||||||
|
displayName: 'NotFound',
|
||||||
|
propTypes: {
|
||||||
|
params: PropTypes.object
|
||||||
|
},
|
||||||
|
componentWillMount() {
|
||||||
|
goToServer(this.props.params.splat);
|
||||||
|
},
|
||||||
|
componentDidMount() {
|
||||||
|
},
|
||||||
|
render() {
|
||||||
|
return <span></span>;
|
||||||
|
}
|
||||||
|
});
|
@ -1,10 +1,15 @@
|
|||||||
import Jobs from './Jobs';
|
import Jobs from './Jobs';
|
||||||
import Hikes from './Hikes';
|
import Hikes from './Hikes';
|
||||||
|
import NotFound from '../components/NotFound/index.jsx';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
path: '/',
|
path: '/',
|
||||||
childRoutes: [
|
childRoutes: [
|
||||||
Jobs,
|
Jobs,
|
||||||
Hikes
|
Hikes,
|
||||||
|
{
|
||||||
|
path: '*',
|
||||||
|
component: NotFound
|
||||||
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user