2016-09-21 18:18:54 -06:00
|
|
|
import React from 'react';
|
2016-09-27 15:12:48 -06:00
|
|
|
import marked from 'marked';
|
2016-09-21 18:18:54 -06:00
|
|
|
|
|
|
|
import {Button} from './Button';
|
2016-09-27 15:12:48 -06:00
|
|
|
import {FixedPage} from './FixedPage';
|
2016-09-21 18:18:54 -06:00
|
|
|
|
2016-11-15 21:57:10 -07:00
|
|
|
// A component for the site header
|
2016-09-21 18:18:54 -06:00
|
|
|
export class Header extends React.Component {
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
this.state = {
|
|
|
|
loggedIn: false,
|
|
|
|
lockedOut: false
|
|
|
|
}
|
2016-09-27 15:12:48 -06:00
|
|
|
|
|
|
|
this.aboutText = '# About \nGet this later.';
|
2016-09-21 18:18:54 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
logUserIn() {
|
|
|
|
this.setState({
|
|
|
|
loggedIn: true
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
logUserOut() {
|
|
|
|
this.setState({
|
|
|
|
loggedIn: false
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
lockUserOut() {
|
|
|
|
this.setState({
|
|
|
|
loggedIn: false,
|
|
|
|
lockedOut: true
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
unlockUser() {
|
|
|
|
this.setState({
|
|
|
|
lockedOut: false
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
showAccountButtons() {
|
|
|
|
var buttons;
|
|
|
|
|
|
|
|
if (this.state.loggedIn) {
|
|
|
|
buttons = [
|
|
|
|
<Button key='accountbutton1'
|
|
|
|
id='accountSettings'
|
|
|
|
action={() => this.lockUserOut()}
|
|
|
|
label='Account Settings' />,
|
|
|
|
<Button key='accountbutton2'
|
|
|
|
id='logoutLink'
|
|
|
|
action={() => this.logUserOut()}
|
|
|
|
label='Log Out' />
|
|
|
|
];
|
|
|
|
} else if (this.state.lockedOut) {
|
|
|
|
buttons = [
|
|
|
|
<Button key='accountbutton3'
|
|
|
|
id='logoutLink'
|
|
|
|
action={() => this.unlockUser()}
|
|
|
|
label='Can't Log In' />
|
|
|
|
];
|
|
|
|
} else {
|
|
|
|
buttons = [
|
|
|
|
<Button key='accountbutton4'
|
|
|
|
id='loginLink'
|
|
|
|
action={() => this.logUserIn()}
|
|
|
|
label='Log In/Create Account' />
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
return <div className='button-group'>{buttons}</div>;
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<header>
|
2016-09-27 15:12:48 -06:00
|
|
|
|
2016-09-21 18:18:54 -06:00
|
|
|
<div id="headerPadder">
|
2016-09-27 15:12:48 -06:00
|
|
|
|
2016-09-21 18:18:54 -06:00
|
|
|
<a href="/" id="siteLogo">Lexiconga Dictionary Builder</a>
|
2016-09-27 15:12:48 -06:00
|
|
|
|
2016-09-21 18:18:54 -06:00
|
|
|
<div className='button-group'>
|
2016-09-27 15:12:48 -06:00
|
|
|
|
|
|
|
<FixedPage id='aboutButton' buttonText='About Lexiconga'>
|
|
|
|
<div dangerouslySetInnerHTML={{__html: marked(this.aboutText)}} />
|
|
|
|
</FixedPage>
|
|
|
|
|
2016-09-21 18:18:54 -06:00
|
|
|
</div>
|
2016-09-27 15:12:48 -06:00
|
|
|
|
2016-09-21 18:18:54 -06:00
|
|
|
{this.showAccountButtons()}
|
2016-09-27 15:12:48 -06:00
|
|
|
|
2016-09-21 18:18:54 -06:00
|
|
|
</div>
|
2016-09-27 15:12:48 -06:00
|
|
|
|
2016-09-21 18:18:54 -06:00
|
|
|
</header>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|