|
1 | 1 | import React from "react"
|
2 |
| -import { Pane, majorScale, Link } from "evergreen-ui" |
| 2 | +import { |
| 3 | + Pane, |
| 4 | + majorScale, |
| 5 | + Link, |
| 6 | + Heading, |
| 7 | + GitRepoIcon, |
| 8 | + ManualIcon, |
| 9 | + Text, |
| 10 | + minorScale, |
| 11 | +} from "evergreen-ui" |
3 | 12 | import analyticsEventSections from "./example-sections/constants"
|
4 | 13 |
|
5 | 14 | const TableOfContents: React.FC<{
|
6 | 15 | onContentClick: (index: number) => void
|
7 | 16 | }> = ({ onContentClick }) => {
|
| 17 | + const handleClickExternalLink = (link: string) => { |
| 18 | + window.open(link, "_blank") |
| 19 | + } |
8 | 20 | return (
|
9 |
| - <Pane |
10 |
| - display="flex" |
11 |
| - flexDirection="column" |
12 |
| - paddingY={majorScale(4)} |
13 |
| - borderBottom |
14 |
| - > |
15 |
| - {analyticsEventSections.map((eventSection, i) => { |
16 |
| - const { title, type } = eventSection |
17 |
| - return ( |
18 |
| - <Link |
19 |
| - key={i} |
| 21 | + <Pane> |
| 22 | + <Pane |
| 23 | + width={majorScale(24)} |
| 24 | + marginLeft={majorScale(8)} |
| 25 | + position="sticky" |
| 26 | + top={majorScale(4)} |
| 27 | + > |
| 28 | + <Pane |
| 29 | + display="flex" |
| 30 | + flexDirection="column" |
| 31 | + alignItems="flex-start" |
| 32 | + justifyContent="center" |
| 33 | + paddingBottom={majorScale(5)} |
| 34 | + > |
| 35 | + <Pane |
| 36 | + marginBottom={minorScale(3)} |
| 37 | + display="flex" |
| 38 | + alignItems="center" |
20 | 39 | cursor="pointer"
|
21 |
| - onClick={() => { |
22 |
| - onContentClick(i) |
23 |
| - }} |
24 |
| - marginTop={i === 0 ? undefined : majorScale(1)} |
25 |
| - marginLeft={type === "header" ? undefined : majorScale(2)} |
| 40 | + onClick={() => |
| 41 | + handleClickExternalLink( |
| 42 | + "https://github.com/segmentio/react-example" |
| 43 | + ) |
| 44 | + } |
26 | 45 | >
|
27 |
| - {title} |
28 |
| - </Link> |
29 |
| - ) |
30 |
| - })} |
| 46 | + <GitRepoIcon marginRight={minorScale(1)} color="muted" /> |
| 47 | + <Text color="muted">Github Repository</Text> |
| 48 | + </Pane> |
| 49 | + <Pane |
| 50 | + display="flex" |
| 51 | + alignItems="center" |
| 52 | + cursor="pointer" |
| 53 | + onClick={() => handleClickExternalLink("https://segment.com/docs/")} |
| 54 | + > |
| 55 | + <ManualIcon marginRight={minorScale(1)} color="muted" /> |
| 56 | + <Text color="muted">Segment Documentation</Text> |
| 57 | + </Pane> |
| 58 | + </Pane> |
| 59 | + <Pane |
| 60 | + display="flex" |
| 61 | + flexDirection="column" |
| 62 | + paddingTop={majorScale(5)} |
| 63 | + borderTop |
| 64 | + > |
| 65 | + <Heading size={400} marginBottom={majorScale(1)}> |
| 66 | + On this site |
| 67 | + </Heading> |
| 68 | + {analyticsEventSections.map((eventSection, i) => { |
| 69 | + const { title, type } = eventSection |
| 70 | + return ( |
| 71 | + <Link |
| 72 | + key={i} |
| 73 | + cursor="pointer" |
| 74 | + onClick={() => { |
| 75 | + onContentClick(i) |
| 76 | + }} |
| 77 | + marginTop={i === 0 ? undefined : majorScale(1)} |
| 78 | + marginLeft={ |
| 79 | + type === "header" || type === "page header" |
| 80 | + ? undefined |
| 81 | + : majorScale(2) |
| 82 | + } |
| 83 | + color="neutral" |
| 84 | + > |
| 85 | + {title} |
| 86 | + </Link> |
| 87 | + ) |
| 88 | + })} |
| 89 | + </Pane> |
| 90 | + </Pane> |
31 | 91 | </Pane>
|
32 | 92 | )
|
33 | 93 | }
|
|
0 commit comments