This repository has been archived by the owner on Oct 25, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 45
/
_template.jsx
109 lines (104 loc) · 3 KB
/
_template.jsx
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import React from 'react';
import { RouteHandler, Link, State, Navigation } from 'react-router';
import { Container, Grid, Breakpoint, Span } from 'react-responsive-grid';
import Typography from 'typography';
import sortBy from 'lodash/collection/sortBy';
import { link, templateChildrenPages } from 'gatsby-helpers';
import typography from 'utils/typography';
const { rhythm, fontSizeToPx } = typography;
module.exports = React.createClass({
mixins: [State, Navigation],
handleTopicChange: function(e) {
return this.transitionTo(e.target.value);
},
render: function() {
var childPages, docOptions, docPages;
childPages = templateChildrenPages(__filename, this.props.state).map(function(child) {
return {
title: child.data.title,
order: child.data.order,
path: child.path
};
});
childPages = sortBy(childPages, function(child) {
return child.order;
});
docOptions = childPages.map(function(child) {
return React.createElement("option", {
"key": link(child.path),
"value": link(child.path)
}, child.title);
});
docPages = childPages.map((function(_this) {
return function(child) {
var isActive;
isActive = _this.isActive(link(child.path));
return (
<li
key={child.path}
style={{
marginBottom: rhythm(1/2)
}}
>
<Link
to={link(child.path)}
style={{
textDecoration: 'none'
}}
>
{isActive ? <strong>{child.title}</strong> : child.title }
</Link>
</li>
)
};
})(this));
return (
<div>
<Breakpoint minWidth={700}>
<div>
<div
style={{
overflowY: 'auto',
paddingRight: `calc(${rhythm(1/2)} - 1px)`,
position: 'absolute',
width: `calc(${rhythm(8)} - 1px)`,
borderRight: '1px solid lightgrey'
}}
>
<ul
style={{
listStyle: 'none',
marginLeft: 0,
marginTop: rhythm(1/2)
}}
>
{docPages}
</ul>
</div>
<div
style={{
padding: `0 ${rhythm(1)}`,
paddingLeft: `calc(${rhythm(8)} + ${rhythm(1)})`
}}
>
<RouteHandler typography={typography} {...this.props}/>
</div>
</div>
</Breakpoint>
<Breakpoint maxWidth={700}>
<strong>Topics:</strong>
{' '}
<select
defaultValue={this.props.state.path}
onChange={this.handleTopicChange}
>
{docOptions}
</select>
<br />
<br />
<RouteHandler typography={typography} {...this.props}/>
</Breakpoint>
</div>
);
}
});