2018-10-02 16:48:13 -04:00
|
|
|
import React, { Fragment } from 'react';
|
2018-09-09 17:22:44 -04:00
|
|
|
import { NavLink } from 'react-router-dom';
|
2019-05-27 13:26:29 -04:00
|
|
|
import PropTypes from 'prop-types';
|
2018-09-09 17:22:44 -04:00
|
|
|
|
2019-08-14 03:56:00 -04:00
|
|
|
import { Logo } from './components/logo';
|
2018-09-09 17:22:44 -04:00
|
|
|
import './header.css';
|
|
|
|
|
|
|
|
/**
|
2019-05-23 09:41:20 -04:00
|
|
|
* Render the main header using a responsive design
|
2018-09-09 17:22:44 -04:00
|
|
|
*/
|
2019-08-09 13:49:43 -04:00
|
|
|
class Header extends React.Component<any, any> { // TODO: add proper types
|
|
|
|
static propTypes = { // TODO: generate propTypes from TS
|
|
|
|
user: PropTypes.shape({
|
|
|
|
username: PropTypes.string
|
|
|
|
})
|
|
|
|
};
|
2019-08-14 03:45:00 -04:00
|
|
|
|
2019-05-27 11:39:16 -04:00
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
this.state = {collapseMenu: true};
|
|
|
|
this.handleClick = this.handleClick.bind(this);
|
|
|
|
}
|
2019-05-23 09:41:20 -04:00
|
|
|
|
2019-05-27 11:39:16 -04:00
|
|
|
handleClick() {
|
|
|
|
this.setState(state => ({
|
|
|
|
collapseMenu: !state.collapseMenu
|
|
|
|
}));
|
|
|
|
}
|
2019-05-23 09:41:20 -04:00
|
|
|
|
2019-05-27 11:39:16 -04:00
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<header className="main-header">
|
|
|
|
<nav className="navbar navbar-light navbar-expand-md">
|
|
|
|
<span className="navbar-brand">
|
|
|
|
<Logo/>
|
|
|
|
</span>
|
|
|
|
<button className="navbar-toggler navbar-toggler-right" type="button"
|
2019-05-27 11:45:24 -04:00
|
|
|
onClick={this.handleClick} aria-expanded="false" aria-label="Toggle navigation">
|
2019-05-27 11:39:16 -04:00
|
|
|
<span className="navbar-toggler-icon"></span>
|
|
|
|
</button>
|
|
|
|
<div className={this.state.collapseMenu ? 'collapse navbar-collapse' : 'navbar-collapse'}>
|
|
|
|
<ul className="navbar-nav ml-auto">
|
|
|
|
<li className="nav-item">
|
|
|
|
<a className="nav-link" href="https://pages.colouring.london">
|
|
|
|
Hello
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li className="nav-item">
|
|
|
|
<a className="nav-link" href="https://pages.colouring.london/buildingcategories">
|
|
|
|
Data Categories
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li className="nav-item">
|
2019-08-14 06:37:09 -04:00
|
|
|
<NavLink to="/view/categories.html" className="nav-link">
|
|
|
|
View/Edit Maps
|
2019-05-27 11:39:16 -04:00
|
|
|
</NavLink>
|
|
|
|
</li>
|
|
|
|
<li className="nav-item">
|
|
|
|
<a className="nav-link" href="https://pages.colouring.london/about">
|
|
|
|
More about
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li className="nav-item">
|
|
|
|
<a className="nav-link" href="https://pages.colouring.london/whoisinvolved">
|
|
|
|
Who’s Involved?
|
|
|
|
</a>
|
|
|
|
</li>
|
2019-07-07 14:20:17 -04:00
|
|
|
<li className="nav-item">
|
|
|
|
<a className="nav-link" href="https://www.pages.colouring.london/data-ethics">
|
|
|
|
Data Ethics
|
|
|
|
</a>
|
|
|
|
</li>
|
2019-05-27 11:39:16 -04:00
|
|
|
<li className="nav-item">
|
|
|
|
<a className="nav-link" href="https://discuss.colouring.london">
|
|
|
|
Discuss
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
{
|
|
|
|
this.props.user?
|
|
|
|
(
|
|
|
|
<li className="nav-item">
|
|
|
|
<NavLink to="/my-account.html" className="nav-link">
|
|
|
|
My account (Logged in as {this.props.user.username})
|
|
|
|
</NavLink>
|
|
|
|
</li>
|
|
|
|
):
|
|
|
|
(
|
|
|
|
<Fragment>
|
|
|
|
<li className="nav-item">
|
|
|
|
<NavLink to="/login.html" className="nav-link">
|
|
|
|
Log in
|
|
|
|
</NavLink>
|
|
|
|
</li>
|
|
|
|
<li className="nav-item">
|
|
|
|
<NavLink to="/sign-up.html" className="nav-link">
|
|
|
|
Sign up
|
|
|
|
</NavLink>
|
|
|
|
</li>
|
|
|
|
</Fragment>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
</nav>
|
|
|
|
</header>
|
|
|
|
);
|
|
|
|
}
|
2019-05-23 09:41:20 -04:00
|
|
|
}
|
2018-10-02 16:48:13 -04:00
|
|
|
|
2018-09-09 17:22:44 -04:00
|
|
|
export default Header;
|