-
Notifications
You must be signed in to change notification settings - Fork 165
/
TutorialButtons.js
59 lines (54 loc) · 1.25 KB
/
TutorialButtons.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
/** @jsx jsx */
import { jsx } from "theme-ui"
import React from "react" // eslint-disable-line no-unused-vars
import { useDocs } from "docz"
const spacing = "7em"
const Button = ({ href, names, next, alone }) => (
<a
href={href}
sx={{
flexShrink: 0,
flexGrow: 1,
marginLeft: spacing,
display: "flex",
flexDirection: "column",
textAlign: next && !alone ? "right" : "left",
textDecoration: "none",
"&:visited": {
color: "primary",
},
}}
>
<span sx={{ color: "gray" }}>{next ? "Next" : "Previous"}</span>
<span
sx={{
fontWeight: 700,
}}
>
{names[href]}
</span>
</a>
)
export default ({ prev, next }) => {
const names = useDocs().reduce(
(map, val) => ({ ...map, [val.route]: val.name }),
{}
)
return (
<>
<hr sx={{ marginTop: "4em" }}></hr>
<div
sx={{
display: "flex",
flexDirection: "row",
marginLeft: `-${spacing}`,
flexWrap: "wrap",
justifyContent: "flex-start",
}}
>
{prev && <Button alone={!next} names={names} href={prev}></Button>}
{next && <Button next alone={!prev} names={names} href={next}></Button>}
</div>
</>
)
}