Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80551 views
1
import React from 'react';
2
import { Link } from 'react-router';
3
import connectToStores from 'flummox/connect';
4
import View from './View';
5
import { rhythm, color, zIndex } from '../theme';
6
import StyleSheet from 'react-style';
7
8
const navColor = color('blue');
9
10
const styles = StyleSheet.create({
11
navWrapper: {
12
backgroundColor: navColor,
13
position: 'fixed',
14
width: '100%',
15
zIndex: zIndex('AppNav'),
16
},
17
18
subNav: {
19
display: 'none',
20
backgroundColor: navColor,
21
position: 'absolute',
22
right: 0,
23
top: '100%',
24
width: '16em',
25
textAlign: 'right',
26
},
27
28
text: {
29
padding: `${rhythm(1 / 4)} ${rhythm(1 / 2)}`,
30
color: '#fff',
31
width: '100%',
32
textDecoration: 'none',
33
border: 'inherit solid 1px',
34
}
35
});
36
37
class AppNav extends React.Component {
38
render() {
39
return (
40
<View style={{ height: rhythm(1.5) }}>
41
<View styles={[styles.navWrapper]}>
42
<View>
43
<AppNavLink title="Flummox" href="/" />
44
</View>
45
<View justifyContent="flex-end" flexGrow>
46
<AppNavLink title="Guides" href="/flummox/docs/guides">
47
<AppNavLink title="Quick Start" href="/flummox/docs/guides/quick-start" />
48
<AppNavLink title="React Integration" href="/flummox/docs/guides/react-integration" />
49
<AppNavLink title="Why FluxComponent > fluxMixin" href="/flummox/docs/guides/why-flux-component-is-better-than-flux-mixin" />
50
</AppNavLink>
51
<AppNavLink title="API" href="/flummox/docs/api">
52
<AppNavLink title="Store" href="/flummox/docs/api/store" />
53
<AppNavLink title="Flux" href="/flummox/docs/api/flux" />
54
<AppNavLink title="Actions" href="/flummox/docs/api/actions" />
55
<AppNavLink title="FluxComponent" href="/flummox/docs/api/fluxcomponent" />
56
<AppNavLink title="Higher-order component" href="/flummox/docs/api/higher-order-component" />
57
<AppNavLink title="fluxMixin" href="/flummox/docs/api/fluxmixin" />
58
</AppNavLink>
59
<AppNavLink title="GitHub" href="https://github.com/acdlite/flummox" />
60
</View>
61
</View>
62
</View>
63
);
64
}
65
}
66
67
AppNav = connectToStores(AppNav, 'docs');
68
69
class AppNavLink extends React.Component {
70
constructor() {
71
super();
72
73
this.state = {
74
hover: false,
75
};
76
}
77
78
render() {
79
const { children, title, href, level, ...props } = this.props;
80
81
let subNav;
82
if (children) {
83
84
const dynamicStyles = {
85
display: this.state.hover ? null : 'none'
86
};
87
88
subNav = (
89
<View
90
flexDirectionColumn
91
styles={[ styles.subNav, dynamicStyles ]}
92
>
93
{children}
94
</View>
95
);
96
}
97
98
const dynamicInlineLinkStyles = {
99
backgroundColor: this.state.hover ? color('darkBlue') : null,
100
borderColor: this.state.hover ? color('blue') : null,
101
};
102
103
return (
104
<View
105
onMouseEnter={() => this.setState({ hover: true })}
106
onMouseLeave={() => this.setState({ hover: false })}
107
{...props}
108
>
109
<a href={href} styles={[styles.text, dynamicInlineLinkStyles]}>
110
{title}
111
</a>
112
{subNav}
113
</View>
114
);
115
}
116
}
117
118
AppNavLink.defaultProps = {
119
level: 1,
120
};
121
122
export default AppNav;
123
124