2017-09-09 16:38:18 +00:00
|
|
|
import React, { Component } from 'react'
|
|
|
|
import PropTypes from 'prop-types'
|
2017-03-16 21:58:56 +00:00
|
|
|
import { Link } from 'react-router'
|
|
|
|
|
2017-03-17 05:32:01 +00:00
|
|
|
import Sprite from '../common/Sprite'
|
|
|
|
|
2017-03-16 21:58:56 +00:00
|
|
|
class MobileHeader extends Component {
|
|
|
|
static propTypes = {
|
|
|
|
unreadNotificationsCount: PropTypes.number,
|
|
|
|
currentUser: PropTypes.object,
|
|
|
|
mobileTitle: PropTypes.string,
|
|
|
|
mobileTitleWidth: PropTypes.number,
|
|
|
|
onTitleClick: PropTypes.func
|
|
|
|
}
|
|
|
|
|
|
|
|
constructor(props) {
|
|
|
|
super(props)
|
|
|
|
this.state = {open: false}
|
|
|
|
}
|
|
|
|
|
|
|
|
toggle = () => {
|
|
|
|
this.setState({open: !this.state.open})
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2017-03-17 05:32:01 +00:00
|
|
|
const { unreadNotificationsCount, currentUser, mobileTitle,
|
|
|
|
mobileTitleWidth, onTitleClick, serverData } = this.props
|
2017-03-16 21:58:56 +00:00
|
|
|
const { open } = this.state
|
|
|
|
return <div>
|
|
|
|
<div id="mobile_header">
|
|
|
|
<div id="header_content" style={{width: `${mobileTitleWidth}px`}} onClick={onTitleClick}>
|
|
|
|
{mobileTitle}
|
|
|
|
</div>
|
|
|
|
<div id="menu_icon" onClick={this.toggle}>
|
|
|
|
{unreadNotificationsCount > 0 && <div className="unread-notifications-dot"></div>}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{open && <div id="mobile_menu">
|
|
|
|
{currentUser && <ul onClick={this.toggle}>
|
|
|
|
<li className="mobileMenuUser">
|
|
|
|
<Link to={`/explore/mapper/${currentUser.id}`}>
|
|
|
|
<img src={currentUser.get('image')} width="32" height="32" />
|
|
|
|
<span>{currentUser.get('name')}</span>
|
|
|
|
</Link>
|
|
|
|
</li>
|
2017-03-17 05:32:01 +00:00
|
|
|
<li>
|
|
|
|
<a href="/maps/new">
|
|
|
|
<Sprite src={serverData['map_control_sprite.png']}
|
|
|
|
width={32} height={32} xIndex={4} yIndex={0} />
|
|
|
|
New Map
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<Link to="/explore/mine">
|
|
|
|
<Sprite src={serverData['exploremaps_sprite.png']}
|
|
|
|
width={32} height={32} xIndex={1} yIndex={0} />
|
|
|
|
My Maps
|
|
|
|
</Link>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<Link to="/explore/shared">
|
|
|
|
<Sprite src={serverData['exploremaps_sprite.png']}
|
|
|
|
width={32} height={32} xIndex={4} yIndex={0} />
|
|
|
|
Shared With Me
|
|
|
|
</Link>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<Link to="/explore/starred">
|
|
|
|
<Sprite src={serverData['exploremaps_sprite.png']}
|
|
|
|
width={32} height={32} xIndex={3} yIndex={0} />
|
|
|
|
Starred By Me
|
|
|
|
</Link>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<Link to="/explore/active">
|
|
|
|
<Sprite src={serverData['exploremaps_sprite.png']}
|
|
|
|
width={32} height={32} xIndex={0} yIndex={0} />
|
|
|
|
All Maps
|
|
|
|
</Link>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<a href={`/users/${currentUser.id}/edit`}>
|
|
|
|
<Sprite src={serverData['user_sprite.png']}
|
|
|
|
width={32} height={32} xIndex={0} yIndex={0} />
|
|
|
|
Account
|
|
|
|
</a>
|
|
|
|
</li>
|
2017-03-16 21:58:56 +00:00
|
|
|
<li className="notifications">
|
2017-03-17 05:32:01 +00:00
|
|
|
<a href="/notifications">
|
|
|
|
<Sprite src={serverData['map_control_sprite.png']}
|
|
|
|
width={32} height={32} xIndex={0} yIndex={0} />
|
|
|
|
Notifications
|
|
|
|
</a>
|
2017-03-16 21:58:56 +00:00
|
|
|
{unreadNotificationsCount > 0 && <div className="unread-notifications-dot"></div>}
|
|
|
|
</li>
|
2017-03-17 05:32:01 +00:00
|
|
|
<li>
|
|
|
|
<a id="Logout" href="/logout">
|
|
|
|
<Sprite src={serverData['user_sprite.png']}
|
|
|
|
width={32} height={32} xIndex={0} yIndex={3} />
|
|
|
|
Sign Out
|
|
|
|
</a>
|
|
|
|
</li>
|
2017-03-16 21:58:56 +00:00
|
|
|
</ul>}
|
|
|
|
{!currentUser && <ul onClick={this.toggle}>
|
|
|
|
<li><a href="/">Home</a></li>
|
|
|
|
<li><Link to="/explore/active">All Maps</Link></li>
|
|
|
|
<li><Link to="/explore/featured">Featured Maps</Link></li>
|
|
|
|
<li><a href="/request">Request Invite</a></li>
|
|
|
|
<li><a href="/login">Login</a></li>
|
|
|
|
</ul>}
|
|
|
|
</div>}
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default MobileHeader
|