forked from gpbl/isomorphic500
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NavBar.js
62 lines (53 loc) · 1.65 KB
/
NavBar.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import React, { PropTypes, Component } from "react";
import { connectToStores } from "fluxible-addons-react";
import { NavLink } from "fluxible-router";
import Logo from "../components/Logo";
import features from "../constants/features";
import LocaleSwitcher from "../components/LocaleSwitcher";
import { FormattedMessage } from "../utils/IntlComponents";
if (process.env.BROWSER) {
require("../style/NavBar.scss");
}
@connectToStores([], context =>
({ route: context.getStore("RouteStore").getCurrentRoute() })
)
export default class NavBar extends Component {
static PropTypes = {
route: PropTypes.object.isRequired
}
render() {
const { route } = this.props;
const currentFeature = route ? route.getIn(["params", "feature"]) : null;
return (
<div className="NavBar">
<div className="NavBar-title">
<NavLink href="/">
<Logo />
</NavLink>
</div>
<div className="NavBar-links">
{
features.map(feature => {
let className = "NavBar-link";
if (currentFeature === feature) {
className = `${className} ${className}--selected`;
}
return (
<NavLink
key={ feature }
className={ className }
routeName="featured"
navParams={ {feature: feature} }>
<FormattedMessage message={ `features.${feature}` } />
</NavLink>
);
})
}
</div>
<div className="NavBar-locales">
<LocaleSwitcher />
</div>
</div>
);
}
}