forked from github/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGHAEReleaseNotes.tsx
95 lines (89 loc) · 2.87 KB
/
GHAEReleaseNotes.tsx
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
import { useState } from 'react'
import cx from 'classnames'
import dayjs from 'dayjs'
import { GHAEReleaseNotePatch } from './GHAEReleaseNotePatch'
import { GHAEReleaseNotesContextT } from './types'
import { MarkdownContent } from 'components/ui/MarkdownContent'
import styles from './PatchNotes.module.scss'
type GitHubAEProps = {
context: GHAEReleaseNotesContextT
}
export function GHAEReleaseNotes({ context }: GitHubAEProps) {
const { releaseNotes, releases, currentVersion } = context
const [focusedPatch, setFocusedPatch] = useState('')
return (
<div className="d-flex">
<article className="min-width-0 flex-1">
<div className="d-flex flex-items-center flex-justify-between color-bg-default px-5 py-2">
<h1 id="title-h1" className="f4 py-3 m-0">
{currentVersion.planTitle} release notes
</h1>
</div>
<MarkdownContent data-search="article-body">
{releaseNotes.map((patch) => {
return (
<GHAEReleaseNotePatch
key={patch.version}
patch={patch}
currentVersion={currentVersion}
didEnterView={() => setFocusedPatch(patch.version)}
/>
)
})}
</MarkdownContent>
</article>
<aside
className={cx(
'position-sticky d-none d-md-block border-left no-print color-bg-default flex-shrink-0',
styles.aside
)}
>
<nav className="height-full overflow-auto">
<MarkdownContent>
<ul className="list-style-none pl-0 text-bold">
{releases.map((release) => {
return (
<CollapsibleReleaseSection
key={release.version}
release={release}
focusedPatch={focusedPatch}
/>
)
})}
</ul>
</MarkdownContent>
</nav>
</aside>
</div>
)
}
const CollapsibleReleaseSection = ({
release,
focusedPatch,
}: {
release: GHAEReleaseNotesContextT['releases'][0]
focusedPatch: string
}) => {
return (
<li key={release.version} className="border-bottom">
<ul className="list-style-none py-4 px-0 my-0">
{release.patches.map((patch) => {
const isActive = patch.release === focusedPatch
return (
<li key={patch.release} className={cx('px-3 my-0', isActive && 'color-bg-accent')}>
<a
href={`#${patch.release}`}
className="d-flex flex-items-center flex-justify-between"
>
{patch.release}
<span className="color-fg-muted text-mono text-small text-normal">
{dayjs(patch.date).format('MMMM DD, YYYY')}
</span>
</a>
</li>
)
})}
</ul>
</li>
)
}