Adjust Nav styling

This commit is contained in:
Stuart Taylor
2018-04-11 15:42:18 +01:00
committed by Mrugesh Mohapatra
parent d671cba22f
commit e29b79d24e
2 changed files with 29 additions and 85 deletions

View File

@ -0,0 +1,8 @@
#top-nav {
background: #006400;
margin-bottom: 0.45rem;
}
#top-nav img {
margin-bottom: 0;
}

View File

@ -1,55 +1,17 @@
import React, { Component } from 'react'; import React from 'react';
import Link from 'gatsby-link'; import Link from 'gatsby-link';
import Auth from '../../auth'; import './header.css';
const auth = new Auth(); function Header() {
class Header extends Component {
constructor(props) {
super(props);
this.state = {
authenticated: false
};
}
login() {
auth.login();
this.setState({
authenticated: auth.isAuthenticated()
});
}
logout() {
auth.logout();
this.setState({
authenticated: auth.isAuthenticated()
});
}
componentDidMount() {
// this.setState({
// authenticated: auth.isAuthenticated()
// });
}
render() {
return ( return (
<div <header id='top-nav'>
style={{
background: '#006400',
marginBottom: '0.45rem'
}}
>
<div <div
style={{ style={{
margin: '0 auto', margin: '0 auto',
maxWidth: 960 maxWidth: 960
}} }}
> >
<h1 style={{ margin: 0 }}>
<Link <Link
style={{ style={{
color: 'white', color: 'white',
@ -57,43 +19,17 @@ class Header extends Component {
}} }}
to='/' to='/'
> >
freeCodeCamp <img
</Link> alt='Logo - freeCodeCamp | Learn to code'
</h1> src={
{this.state.authenticated ? ( 'https://s3.amazonaws.com/freecodecamp/freecodecamp_logo.svg'
<span>
<a
href='#'
onClick={this.logout.bind(this)}
style={{
boxShadow: 'none',
lineHeight: '37px',
color: '#fff'
}}
>
Log Out
{auth.getUserName() && <span> ({auth.getUserName()})</span>}
</a>
</span>
) : (
<span>
<a
href='#'
onClick={this.login.bind(this)}
style={{
boxShadow: 'none',
lineHeight: '37px',
color: '#fff'
}}
>
Log In
</a>
</span>
)}
</div>
</div>
);
} }
title='freeCodeCamp | Learn to code'
/>
</Link>
</div>
</header>
);
} }
export default Header; export default Header;