2016-08-01 15:33:41 -04:00
|
|
|
import React, { Component, PropTypes } from 'react'
|
2016-08-05 09:32:16 +08:00
|
|
|
import { objectWithoutProperties } from '../utils'
|
2016-08-01 15:33:41 -04:00
|
|
|
|
2016-08-02 09:36:48 +08:00
|
|
|
const MapLink = props => {
|
2016-08-05 10:13:55 +08:00
|
|
|
const { show, text, href, linkClass } = props
|
|
|
|
const otherProps = objectWithoutProperties(props, ['show', 'text', 'href', 'linkClass'])
|
2016-08-02 09:36:48 +08:00
|
|
|
if (!show) {
|
|
|
|
return null
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<a { ...otherProps } href={href} className={linkClass}>
|
|
|
|
<div className="exploreMapsIcon"></div>
|
2016-08-05 10:13:55 +08:00
|
|
|
{text}
|
2016-08-02 09:36:48 +08:00
|
|
|
</a>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2016-08-01 15:33:41 -04:00
|
|
|
class Header extends Component {
|
|
|
|
render = () => {
|
2016-08-02 09:20:19 +08:00
|
|
|
const { signedIn, section } = this.props
|
|
|
|
|
|
|
|
const activeClass = (title) => {
|
|
|
|
let forClass = "exploreMapsButton"
|
2016-08-01 15:33:41 -04:00
|
|
|
forClass += " " + title + "Maps"
|
|
|
|
if (title == "my" && section == "mine" ||
|
|
|
|
title == section) forClass += " active"
|
|
|
|
return forClass
|
|
|
|
}
|
|
|
|
|
|
|
|
const explore = section == "mine" || section == "active" || section == "shared" || section == "featured"
|
|
|
|
const mapper = section == "mapper"
|
|
|
|
|
|
|
|
return (
|
2016-08-12 05:03:28 +00:00
|
|
|
<div className="exploreMapsBar exploreElement">
|
|
|
|
<div className="exploreMapsMenu">
|
|
|
|
<div className="exploreMapsCenter">
|
|
|
|
<MapLink show={signedIn && explore}
|
|
|
|
href="/explore/mine"
|
|
|
|
linkClass={activeClass("my")}
|
2016-08-16 10:25:07 -04:00
|
|
|
data-router="true"
|
2016-08-12 05:03:28 +00:00
|
|
|
text="My Maps"
|
|
|
|
/>
|
|
|
|
<MapLink show={signedIn && explore}
|
|
|
|
href="/explore/shared"
|
|
|
|
linkClass={activeClass("shared")}
|
2016-08-16 10:25:07 -04:00
|
|
|
data-router="true"
|
2016-08-12 05:03:28 +00:00
|
|
|
text="Shared With Me"
|
|
|
|
/>
|
|
|
|
<MapLink show={explore}
|
|
|
|
href={signedIn ? "/" : "/explore/active"}
|
|
|
|
linkClass={activeClass("active")}
|
2016-08-16 10:25:07 -04:00
|
|
|
data-router="true"
|
2016-08-12 05:03:28 +00:00
|
|
|
text="Recently Active"
|
|
|
|
/>
|
|
|
|
<MapLink show={!signedIn && explore}
|
|
|
|
href="/explore/featured"
|
|
|
|
linkClass={activeClass("featured")}
|
2016-08-16 10:25:07 -04:00
|
|
|
data-router="true"
|
2016-08-12 05:03:28 +00:00
|
|
|
text="Featured Maps"
|
|
|
|
/>
|
|
|
|
|
|
|
|
{mapper ? (
|
|
|
|
<div className='exploreMapsButton active mapperButton'>
|
|
|
|
<img className='exploreMapperImage' width='24' height='24' src={this.props.userAvatar} />
|
|
|
|
<div className='exploreMapperName'>{this.props.userName}’s Maps</div>
|
|
|
|
<div className='clearfloat'></div>
|
|
|
|
</div>
|
|
|
|
) : null }
|
2016-08-01 15:33:41 -04:00
|
|
|
</div>
|
2016-08-12 05:03:28 +00:00
|
|
|
</div>
|
2016-08-01 15:33:41 -04:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-02 09:19:12 +08:00
|
|
|
Header.propTypes = {
|
|
|
|
signedIn: PropTypes.bool.isRequired,
|
|
|
|
section: PropTypes.string.isRequired,
|
|
|
|
userAvatar: PropTypes.string,
|
|
|
|
userName: PropTypes.string
|
|
|
|
}
|
|
|
|
|
2016-08-01 15:33:41 -04:00
|
|
|
export default Header
|