@primer/gatsby-theme-doctocat 3.3.0 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +36 -0
- package/gatsby-node.js +2 -2
- package/package.json +2 -2
- package/setup-tests.js +9 -0
- package/src/components/code.js +4 -2
- package/src/components/do-dont.js +1 -1
- package/src/components/figma-link.js +32 -0
- package/src/components/layout.js +13 -6
- package/src/components/live-code.js +54 -17
- package/src/components/lookbook-link.js +28 -0
- package/src/components/nav-drawer.js +5 -3
- package/src/components/nav-items.js +36 -71
- package/src/components/sidebar.js +4 -4
- package/src/components/source-link.js +1 -1
- package/src/components/storybook-link.js +2 -2
- package/src/components/table-of-contents.js +7 -24
- package/src/components/table.js +1 -0
- package/src/primer-nav.yml +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,41 @@
|
|
|
1
1
|
# @primer/gatsby-theme-doctocat
|
|
2
2
|
|
|
3
|
+
## 4.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`8a4cd71`](https://github.com/primer/doctocat/commit/8a4cd719954443991fbb53e642e62c04839fc7ac) [#476](https://github.com/primer/doctocat/pull/476) Thanks [@jonrohan](https://github.com/jonrohan)! - Adding support for a Lookbook link
|
|
8
|
+
|
|
9
|
+
## 4.0.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`1e22900`](https://github.com/primer/doctocat/commit/1e229008d374b8b56d19ce33f315256c4301efb4) [#434](https://github.com/primer/doctocat/pull/434) Thanks [@rezrah](https://github.com/rezrah)! - - Updated external links in frontmatter to open in new tab
|
|
14
|
+
- Added support for Figma links in frontmatter
|
|
15
|
+
|
|
16
|
+
* [`9585e40`](https://github.com/primer/doctocat/commit/9585e40d62b0bfcb8aff6d98cdd490b5058f6748) [#475](https://github.com/primer/doctocat/pull/475) Thanks [@JoshBowdenConcepts](https://github.com/JoshBowdenConcepts)! - Adding Primer Brand link to the main navigation
|
|
17
|
+
|
|
18
|
+
## 4.0.0
|
|
19
|
+
|
|
20
|
+
### Major Changes
|
|
21
|
+
|
|
22
|
+
- [`1022d1c`](https://github.com/primer/doctocat/commit/1022d1c92588f1e4fed4bdacec30fd5d11256412) [#362](https://github.com/primer/doctocat/pull/362) Thanks [@siddharthkp](https://github.com/siddharthkp)! - Drop support for node 12
|
|
23
|
+
|
|
24
|
+
* [`5f4426c`](https://github.com/primer/doctocat/commit/5f4426cc0cec6201600241bc753e5c7c9bf188a6) [#427](https://github.com/primer/doctocat/pull/427) Thanks [@colebemis](https://github.com/colebemis)! - Items in [`nav.yml`](https://primer.style/doctocat/usage/customization#side-navigation) that contain `children` no longer render as links, meaning the `url` property will be ignored.
|
|
25
|
+
|
|
26
|
+
```diff
|
|
27
|
+
# nav.yml
|
|
28
|
+
– title: Components
|
|
29
|
+
- url: /components
|
|
30
|
+
children:
|
|
31
|
+
— title: Avatar
|
|
32
|
+
url: /Avatar
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Patch Changes
|
|
36
|
+
|
|
37
|
+
- [`facde5a`](https://github.com/primer/doctocat/commit/facde5a56119b160f98b8b01302e3508392c2146) [#330](https://github.com/primer/doctocat/pull/330) Thanks [@siddharthkp](https://github.com/siddharthkp)! - Vertically-center align images in table
|
|
38
|
+
|
|
3
39
|
## 3.3.0
|
|
4
40
|
|
|
5
41
|
### Minor Changes
|
package/gatsby-node.js
CHANGED
|
@@ -30,7 +30,7 @@ exports.createPages = async ({graphql, actions}, themeOptions) => {
|
|
|
30
30
|
}
|
|
31
31
|
`)
|
|
32
32
|
|
|
33
|
-
if (!process.env.GITHUB_TOKEN
|
|
33
|
+
if (!process.env.GITHUB_TOKEN) {
|
|
34
34
|
console.error(`Non-deploy build and no GITHUB_TOKEN environment variable set; skipping GitHub API calls`)
|
|
35
35
|
}
|
|
36
36
|
|
|
@@ -48,7 +48,7 @@ exports.createPages = async ({graphql, actions}, themeOptions) => {
|
|
|
48
48
|
const editUrl = getEditUrl(repo, fileRelativePath, defaultBranch)
|
|
49
49
|
|
|
50
50
|
let contributors = []
|
|
51
|
-
if (process.env.GITHUB_TOKEN
|
|
51
|
+
if (process.env.GITHUB_TOKEN) {
|
|
52
52
|
contributors = await fetchContributors(repo, fileRelativePath, process.env.GITHUB_TOKEN)
|
|
53
53
|
}
|
|
54
54
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@primer/gatsby-theme-doctocat",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"scripts": {
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"@mdx-js/mdx": "^1.0.21",
|
|
34
34
|
"@mdx-js/react": "^1.0.21",
|
|
35
35
|
"@primer/component-metadata": "^0.4.0",
|
|
36
|
-
"@primer/react": "^34.5.0",
|
|
37
36
|
"@primer/octicons-react": "^16.3.1",
|
|
37
|
+
"@primer/react": "^35.2.2",
|
|
38
38
|
"@styled-system/theme-get": "^5.0.12",
|
|
39
39
|
"@testing-library/jest-dom": "^5.16.2",
|
|
40
40
|
"@testing-library/react": "^9.1.3",
|
package/setup-tests.js
CHANGED
|
@@ -1 +1,10 @@
|
|
|
1
1
|
import '@testing-library/jest-dom/extend-expect'
|
|
2
|
+
|
|
3
|
+
// JSDOM doesn't mock ResizeObserver
|
|
4
|
+
// Copied from https://github.com/primer/react/blob/3fdae477d8067c5131d316548ce5b08aa1017355/src/utils/test-helpers.tsx
|
|
5
|
+
global.ResizeObserver = jest.fn().mockImplementation(() => {
|
|
6
|
+
return {
|
|
7
|
+
observe: jest.fn(),
|
|
8
|
+
disconnect: jest.fn()
|
|
9
|
+
}
|
|
10
|
+
})
|
package/src/components/code.js
CHANGED
|
@@ -6,12 +6,14 @@ import Prism from '../prism'
|
|
|
6
6
|
import ClipboardCopy from './clipboard-copy'
|
|
7
7
|
import LiveCode from './live-code'
|
|
8
8
|
|
|
9
|
-
function Code({className, children, live, noinline, metastring}) {
|
|
9
|
+
function Code({className, children, live, highlight, noinline, metastring}) {
|
|
10
10
|
const language = className ? className.replace(/language-/, '') : ''
|
|
11
11
|
const code = children.trim()
|
|
12
12
|
|
|
13
13
|
if (live) {
|
|
14
|
-
return
|
|
14
|
+
return (
|
|
15
|
+
<LiveCode code={code} highlight={highlight} language={language} noinline={noinline} metastring={metastring} />
|
|
16
|
+
)
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
return (
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {Link, Text} from '@primer/react'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
4
|
+
function SourceLink({href}) {
|
|
5
|
+
return (
|
|
6
|
+
<Link href={href} target="_blank">
|
|
7
|
+
<FigmaLogo />
|
|
8
|
+
<Text sx={{ml: 2, display: 'inline-block'}}>View Figma</Text>
|
|
9
|
+
</Link>
|
|
10
|
+
)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function FigmaLogo() {
|
|
14
|
+
return (
|
|
15
|
+
<svg
|
|
16
|
+
width={16}
|
|
17
|
+
height={16}
|
|
18
|
+
aria-hidden="true"
|
|
19
|
+
style={{verticalAlign: 'text-bottom'}}
|
|
20
|
+
fill="none"
|
|
21
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
22
|
+
viewBox="0 0 172 247"
|
|
23
|
+
>
|
|
24
|
+
<g stroke="currentColor" strokeWidth="15.081">
|
|
25
|
+
<path d="M164 46.5c0 21.263-17.237 38.5-38.5 38.5H86V8h39.5C146.763 8 164 25.237 164 46.5ZM8 46.5C8 67.763 25.237 85 46.5 85H86V8H46.5C25.237 8 8 25.237 8 46.5ZM8 123.501c0 21.263 17.237 38.5 38.5 38.5H86v-77H46.5c-21.263 0-38.5 17.237-38.5 38.5Z" />
|
|
26
|
+
<path d="M8 200.5C8 221.763 25.485 239 46.748 239 68.288 239 86 221.539 86 200v-38H46.5C25.237 162 8 179.237 8 200.5ZM86 123.501c0 21.263 17.237 38.5 38.5 38.5h1c21.263 0 38.5-17.237 38.5-38.5s-17.237-38.5-38.5-38.5h-1c-21.263 0-38.5 17.237-38.5 38.5Z" />
|
|
27
|
+
</g>
|
|
28
|
+
</svg>
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default SourceLink
|
package/src/components/layout.js
CHANGED
|
@@ -7,11 +7,14 @@ import PageFooter from './page-footer'
|
|
|
7
7
|
import Sidebar from './sidebar'
|
|
8
8
|
import SourceLink from './source-link'
|
|
9
9
|
import StatusLabel from './status-label'
|
|
10
|
+
import LookbookLink from './lookbook-link'
|
|
10
11
|
import StorybookLink from './storybook-link'
|
|
12
|
+
import FigmaLink from './figma-link'
|
|
11
13
|
import TableOfContents from './table-of-contents'
|
|
12
14
|
|
|
13
15
|
function Layout({children, pageContext}) {
|
|
14
|
-
let {title, description, status, source, storybook, additionalContributors, componentId} =
|
|
16
|
+
let {title, description, figma, status, source, storybook, lookbook, additionalContributors, componentId} =
|
|
17
|
+
pageContext.frontmatter
|
|
15
18
|
|
|
16
19
|
if (!additionalContributors) {
|
|
17
20
|
additionalContributors = []
|
|
@@ -56,8 +59,10 @@ function Layout({children, pageContext}) {
|
|
|
56
59
|
}}
|
|
57
60
|
css={{gridArea: 'table-of-contents', overflow: 'auto'}}
|
|
58
61
|
>
|
|
59
|
-
<Text sx={{display: 'inline-block', fontWeight: 'bold',
|
|
60
|
-
|
|
62
|
+
<Text sx={{display: 'inline-block', fontWeight: 'bold', pl: 3}} id="toc-heading">
|
|
63
|
+
On this page
|
|
64
|
+
</Text>
|
|
65
|
+
<TableOfContents aria-labelledby="toc-heading" items={pageContext.tableOfContents.items} />
|
|
61
66
|
</Box>
|
|
62
67
|
) : null}
|
|
63
68
|
<Box sx={{width: '100%', maxWidth: '960px'}}>
|
|
@@ -69,7 +74,7 @@ function Layout({children, pageContext}) {
|
|
|
69
74
|
{status ? <StatusLabel status={status} /> : null}
|
|
70
75
|
</Box>
|
|
71
76
|
{description ? <Box sx={{fontSize: 3, pb: 2}}>{description}</Box> : null}
|
|
72
|
-
{source || storybook ? (
|
|
77
|
+
{source || storybook || lookbook ? (
|
|
73
78
|
<Box
|
|
74
79
|
sx={{
|
|
75
80
|
py: 2,
|
|
@@ -81,7 +86,9 @@ function Layout({children, pageContext}) {
|
|
|
81
86
|
}}
|
|
82
87
|
>
|
|
83
88
|
{source ? <SourceLink href={source} /> : null}
|
|
89
|
+
{lookbook ? <LookbookLink href={lookbook} /> : null}
|
|
84
90
|
{storybook ? <StorybookLink href={storybook} /> : null}
|
|
91
|
+
{figma ? <FigmaLink href={figma} /> : null}
|
|
85
92
|
</Box>
|
|
86
93
|
) : null}
|
|
87
94
|
</Box>
|
|
@@ -97,14 +104,14 @@ function Layout({children, pageContext}) {
|
|
|
97
104
|
borderRadius: 2
|
|
98
105
|
}}
|
|
99
106
|
>
|
|
100
|
-
<Box sx={{
|
|
107
|
+
<Box sx={{px: 3, py: 2}}>
|
|
101
108
|
<Box
|
|
102
109
|
sx={{flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', display: 'flex'}}
|
|
103
110
|
>
|
|
104
111
|
<Text sx={{fontWeight: 'bold'}}>On this page</Text>
|
|
105
112
|
</Box>
|
|
106
113
|
</Box>
|
|
107
|
-
<Box sx={{
|
|
114
|
+
<Box sx={{borderTop: '1px solid', borderColor: 'border.muted'}}>
|
|
108
115
|
<TableOfContents items={pageContext.tableOfContents.items} />
|
|
109
116
|
</Box>
|
|
110
117
|
</Box>
|
|
@@ -8,6 +8,8 @@ import {ThemeContext} from 'styled-components'
|
|
|
8
8
|
import scope from '../live-code-scope'
|
|
9
9
|
import ClipboardCopy from './clipboard-copy'
|
|
10
10
|
import LivePreviewWrapper from './live-preview-wrapper'
|
|
11
|
+
import styled from 'styled-components'
|
|
12
|
+
import themeGet from '@styled-system/theme-get'
|
|
11
13
|
|
|
12
14
|
const languageTransformers = {
|
|
13
15
|
html: html => htmlToJsx(html),
|
|
@@ -39,10 +41,43 @@ const getResolvedScope = metastring => {
|
|
|
39
41
|
return scope
|
|
40
42
|
}
|
|
41
43
|
|
|
42
|
-
function
|
|
44
|
+
function parseHighlightRange(highlight) {
|
|
45
|
+
// Captures numbers separated by a dash: 2-3, 34-5, 2-101
|
|
46
|
+
const numbersWithDash = new RegExp('([0-9]+)-([0-9]+)')
|
|
47
|
+
|
|
48
|
+
const match = numbersWithDash.exec(highlight)
|
|
49
|
+
if (!match) return null
|
|
50
|
+
|
|
51
|
+
return {firstLine: match[1], lastLine: match[2]}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const LineWrapper = styled.div`
|
|
55
|
+
// Using negative and positive nth-child values to select the children.
|
|
56
|
+
pre .token-line:nth-child(n + ${props => props.range.firstLine}):nth-child(-n + ${props => props.range.lastLine}) {
|
|
57
|
+
// 16px is the padding of the react-live <pre> element that wraps the .token-line elements.
|
|
58
|
+
// The margin/padding combo extends the token-line elements so the background color reaches the border.
|
|
59
|
+
margin: 0px -16px;
|
|
60
|
+
padding: 0px 16px;
|
|
61
|
+
background-color: ${themeGet('colors.accent.subtle')};
|
|
62
|
+
// We use box-shadow instead of a border to avoid flickering when toggling the highlighting on/off.
|
|
63
|
+
box-shadow: inset 3px 0px 0px 0px ${themeGet('colors.accent.fg')};
|
|
64
|
+
}
|
|
65
|
+
`
|
|
66
|
+
|
|
67
|
+
function LineHighlighter({enabled, range, children}) {
|
|
68
|
+
if (!enabled || !range) return children
|
|
69
|
+
|
|
70
|
+
return <LineWrapper range={range}>{children}</LineWrapper>
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function LiveCode({code, language, highlight, noinline, metastring}) {
|
|
43
74
|
const theme = React.useContext(ThemeContext)
|
|
44
75
|
const [liveCode, setLiveCode] = useState(code)
|
|
45
|
-
const
|
|
76
|
+
const [pristine, setPristine] = useState(true)
|
|
77
|
+
const handleChange = updatedLiveCode => {
|
|
78
|
+
setLiveCode(updatedLiveCode)
|
|
79
|
+
setPristine(false)
|
|
80
|
+
}
|
|
46
81
|
|
|
47
82
|
return (
|
|
48
83
|
<Box sx={{flexDirection: 'column', mb: 3, display: 'flex'}}>
|
|
@@ -66,21 +101,23 @@ function LiveCode({code, language, noinline, metastring}) {
|
|
|
66
101
|
</LivePreviewWrapper>
|
|
67
102
|
</Box>
|
|
68
103
|
<Box sx={{position: 'relative'}}>
|
|
69
|
-
<
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
104
|
+
<LineHighlighter range={parseHighlightRange(highlight)} enabled={pristine}>
|
|
105
|
+
<LiveEditor
|
|
106
|
+
onChange={handleChange}
|
|
107
|
+
theme={githubTheme}
|
|
108
|
+
ignoreTabKey={true}
|
|
109
|
+
padding={theme.space[3]}
|
|
110
|
+
style={{
|
|
111
|
+
fontFamily: theme.fonts.mono,
|
|
112
|
+
fontSize: '85%',
|
|
113
|
+
borderBottomLeftRadius: theme.radii[2],
|
|
114
|
+
borderBottomRightRadius: theme.radii[2],
|
|
115
|
+
border: '1px solid',
|
|
116
|
+
borderTop: 0,
|
|
117
|
+
borderColor: theme.colors.border.default
|
|
118
|
+
}}
|
|
119
|
+
/>
|
|
120
|
+
</LineHighlighter>
|
|
84
121
|
<Box sx={{top: 0, right: 0, p: 2, position: 'absolute'}}>
|
|
85
122
|
<ClipboardCopy value={liveCode} />
|
|
86
123
|
</Box>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import {Link, Text} from '@primer/react'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
4
|
+
function SourceLink({href}) {
|
|
5
|
+
return (
|
|
6
|
+
<Link href={href} target="_blank">
|
|
7
|
+
<LookbookIcon />
|
|
8
|
+
<Text sx={{ml: 2, display: 'inline-block'}}>View Lookbook</Text>
|
|
9
|
+
</Link>
|
|
10
|
+
)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function LookbookIcon() {
|
|
14
|
+
return (
|
|
15
|
+
<svg
|
|
16
|
+
aria-hidden="true"
|
|
17
|
+
viewBox="0 0 24 24"
|
|
18
|
+
width={16}
|
|
19
|
+
height={16}
|
|
20
|
+
fill="currentColor"
|
|
21
|
+
style={{verticalAlign: 'text-bottom'}}
|
|
22
|
+
>
|
|
23
|
+
<path d="M12.3701 0C12.1793 0 12.0588 0.205201 12.1518 0.371843L17.7026 10.3173C17.766 10.4308 17.766 10.5692 17.7026 10.6827L12.1518 20.6282C12.0588 20.7948 12.1793 21 12.3701 21H17.974C18.1099 21 18.2352 20.9265 18.3014 20.8078L23.9524 10.6827C24.0158 10.5692 24.0158 10.4308 23.9524 10.3172L18.3014 0.192237C18.2352 0.07355 18.1099 0 17.974 0H12.3701ZM11.8433 10.3173C11.9067 10.4308 11.9067 10.5692 11.8433 10.6827L6.16371 20.8589C6.06834 21.0298 5.8225 21.0298 5.72712 20.8589L0.04755 10.6827C-0.0158499 10.5692 -0.01585 10.4308 0.0475497 10.3173L5.72712 0.141121C5.8225 -0.029757 6.06834 -0.0297573 6.16371 0.14112L11.8433 10.3173Z" />
|
|
24
|
+
</svg>
|
|
25
|
+
)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default SourceLink
|
|
@@ -21,7 +21,7 @@ export function useNavDrawerState(breakpoint) {
|
|
|
21
21
|
if (window.innerWidth >= breakpoint) {
|
|
22
22
|
setOpen(false)
|
|
23
23
|
}
|
|
24
|
-
}, [setOpen])
|
|
24
|
+
}, [setOpen, breakpoint])
|
|
25
25
|
|
|
26
26
|
const debouncedOnResize = React.useCallback(debounce(onResize, 250), [onResize])
|
|
27
27
|
|
|
@@ -86,11 +86,13 @@ function NavDrawer({isOpen, onDismiss}) {
|
|
|
86
86
|
<Link
|
|
87
87
|
as={GatsbyLink}
|
|
88
88
|
to="/"
|
|
89
|
-
sx={{display: 'inline-block', color: 'inherit', fontFamily: 'mono', mx: 4,
|
|
89
|
+
sx={{display: 'inline-block', color: 'inherit', fontFamily: 'mono', mx: 4, mt: 4}}
|
|
90
90
|
>
|
|
91
91
|
{siteMetadata.title}
|
|
92
92
|
</Link>
|
|
93
|
-
<
|
|
93
|
+
<Box sx={{px: 2}}>
|
|
94
|
+
<NavItems items={navItems} />
|
|
95
|
+
</Box>
|
|
94
96
|
</Box>
|
|
95
97
|
</ThemeProvider>
|
|
96
98
|
) : null}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {Box, Link, StyledOcticon, themeGet} from '@primer/react'
|
|
2
1
|
import {LinkExternalIcon} from '@primer/octicons-react'
|
|
3
|
-
import {
|
|
2
|
+
import {NavList} from '@primer/react/drafts'
|
|
3
|
+
import {useLocation} from '@reach/router'
|
|
4
|
+
import {Link as GatsbyLink, withPrefix} from 'gatsby'
|
|
4
5
|
import preval from 'preval.macro'
|
|
5
6
|
import React from 'react'
|
|
6
|
-
import styled from 'styled-components'
|
|
7
7
|
|
|
8
8
|
// This code needs to run at build-time so it can access the file system.
|
|
9
9
|
const repositoryUrl = preval`
|
|
@@ -17,81 +17,46 @@ const repositoryUrl = preval`
|
|
|
17
17
|
}
|
|
18
18
|
`
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
function NavItem({href, children}) {
|
|
21
|
+
const location = useLocation()
|
|
22
|
+
const isCurrent = withPrefix(href) === location.pathname
|
|
23
|
+
return (
|
|
24
|
+
<NavList.Item as={GatsbyLink} to={href} aria-current={isCurrent ? 'page' : null}>
|
|
25
|
+
{children}
|
|
26
|
+
</NavList.Item>
|
|
27
|
+
)
|
|
28
|
+
}
|
|
26
29
|
|
|
27
30
|
function NavItems({items}) {
|
|
28
31
|
return (
|
|
29
|
-
|
|
32
|
+
<NavList>
|
|
30
33
|
{items.map(item => (
|
|
31
|
-
<
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
as={GatsbyLink}
|
|
45
|
-
to={item.url}
|
|
46
|
-
activeClassName="active"
|
|
47
|
-
partiallyActive={true}
|
|
48
|
-
sx={{color: 'inherit'}}
|
|
49
|
-
>
|
|
50
|
-
{item.title}
|
|
51
|
-
</NavLink>
|
|
52
|
-
{item.children ? (
|
|
53
|
-
<Box sx={{display: 'flex', flexDirection: 'column', mt: 2}}>
|
|
54
|
-
{item.children.map(child => (
|
|
55
|
-
<NavLink
|
|
56
|
-
key={child.title}
|
|
57
|
-
as={GatsbyLink}
|
|
58
|
-
to={child.url}
|
|
59
|
-
activeClassName="active"
|
|
60
|
-
sx={{
|
|
61
|
-
display: 'block',
|
|
62
|
-
py: 1,
|
|
63
|
-
mt: 2,
|
|
64
|
-
fontSize: 1
|
|
65
|
-
}}
|
|
66
|
-
>
|
|
67
|
-
{child.title}
|
|
68
|
-
</NavLink>
|
|
69
|
-
))}
|
|
70
|
-
</Box>
|
|
71
|
-
) : null}
|
|
72
|
-
</Box>
|
|
73
|
-
</Box>
|
|
34
|
+
<React.Fragment key={item.title}>
|
|
35
|
+
{item.children ? (
|
|
36
|
+
<NavList.Group title={item.title}>
|
|
37
|
+
{item.children.map(child => (
|
|
38
|
+
<NavItem key={child.title} href={child.url}>
|
|
39
|
+
{child.title}
|
|
40
|
+
</NavItem>
|
|
41
|
+
))}
|
|
42
|
+
</NavList.Group>
|
|
43
|
+
) : (
|
|
44
|
+
<NavItem href={item.url}>{item.title}</NavItem>
|
|
45
|
+
)}
|
|
46
|
+
</React.Fragment>
|
|
74
47
|
))}
|
|
75
48
|
{repositoryUrl ? (
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
>
|
|
86
|
-
<Link href={repositoryUrl} sx={{color: 'inherit'}}>
|
|
87
|
-
<Box sx={{display: 'flex', justifyContent: 'space-between', alignItems: 'center'}}>
|
|
88
|
-
GitHub
|
|
89
|
-
<StyledOcticon icon={LinkExternalIcon} sx={{color: 'fg.muted'}} />
|
|
90
|
-
</Box>
|
|
91
|
-
</Link>
|
|
92
|
-
</Box>
|
|
49
|
+
<>
|
|
50
|
+
<NavList.Divider />
|
|
51
|
+
<NavList.Item href={repositoryUrl}>
|
|
52
|
+
GitHub
|
|
53
|
+
<NavList.TrailingVisual>
|
|
54
|
+
<LinkExternalIcon />
|
|
55
|
+
</NavList.TrailingVisual>
|
|
56
|
+
</NavList.Item>
|
|
57
|
+
</>
|
|
93
58
|
) : null}
|
|
94
|
-
|
|
59
|
+
</NavList>
|
|
95
60
|
)
|
|
96
61
|
}
|
|
97
62
|
|
|
@@ -19,7 +19,7 @@ function usePersistentScroll(id) {
|
|
|
19
19
|
if (scrollPosition && ref.current) {
|
|
20
20
|
ref.current.scrollTop = scrollPosition
|
|
21
21
|
}
|
|
22
|
-
}, [])
|
|
22
|
+
}, [id])
|
|
23
23
|
|
|
24
24
|
// Return props to spread onto the scroll container
|
|
25
25
|
return {
|
|
@@ -37,8 +37,7 @@ function Sidebar() {
|
|
|
37
37
|
position: 'sticky',
|
|
38
38
|
top: HEADER_HEIGHT,
|
|
39
39
|
height: `calc(100vh - ${HEADER_HEIGHT}px)`,
|
|
40
|
-
minWidth: 260
|
|
41
|
-
bg: 'canvas.subtle'
|
|
40
|
+
minWidth: 260
|
|
42
41
|
}}
|
|
43
42
|
>
|
|
44
43
|
<Box
|
|
@@ -50,7 +49,8 @@ function Sidebar() {
|
|
|
50
49
|
borderRadius: 0,
|
|
51
50
|
height: '100%',
|
|
52
51
|
borderStyle: 'solid',
|
|
53
|
-
borderColor: 'border.
|
|
52
|
+
borderColor: 'border.subtle',
|
|
53
|
+
px: 2
|
|
54
54
|
}}
|
|
55
55
|
>
|
|
56
56
|
<Box sx={{flexDirection: 'column', display: 'flex'}}>
|
|
@@ -3,9 +3,9 @@ import React from 'react'
|
|
|
3
3
|
|
|
4
4
|
function SourceLink({href}) {
|
|
5
5
|
return (
|
|
6
|
-
<Link href={href}>
|
|
6
|
+
<Link href={href} target="_blank">
|
|
7
7
|
<StorybookIcon />
|
|
8
|
-
<Text sx={{ml: 2, display: 'inline-block'}}>View
|
|
8
|
+
<Text sx={{ml: 2, display: 'inline-block'}}>View Storybook</Text>
|
|
9
9
|
</Link>
|
|
10
10
|
)
|
|
11
11
|
}
|
|
@@ -1,33 +1,16 @@
|
|
|
1
|
-
import {Box, Link} from '@primer/react'
|
|
2
1
|
import React from 'react'
|
|
2
|
+
import {NavList} from '@primer/react/drafts'
|
|
3
3
|
|
|
4
|
-
function TableOfContents({
|
|
4
|
+
function TableOfContents({'aria-labelledby': ariaLabelledBy, items}) {
|
|
5
5
|
return (
|
|
6
|
-
<
|
|
6
|
+
<NavList aria-labelledby={ariaLabelledBy}>
|
|
7
7
|
{items.map(item => (
|
|
8
|
-
<
|
|
9
|
-
{item.title
|
|
10
|
-
|
|
11
|
-
href={item.url}
|
|
12
|
-
sx={{
|
|
13
|
-
display: 'inline-block',
|
|
14
|
-
py: 1,
|
|
15
|
-
fontSize: [2, null, 1],
|
|
16
|
-
color: 'fg.muted'
|
|
17
|
-
}}
|
|
18
|
-
>
|
|
19
|
-
{item.title}
|
|
20
|
-
</Link>
|
|
21
|
-
) : null}
|
|
22
|
-
{item.items ? <TableOfContents items={item.items} depth={depth + 1} /> : null}
|
|
23
|
-
</Box>
|
|
8
|
+
<NavList.Item key={item.title} href={item.url}>
|
|
9
|
+
{item.title}
|
|
10
|
+
</NavList.Item>
|
|
24
11
|
))}
|
|
25
|
-
</
|
|
12
|
+
</NavList>
|
|
26
13
|
)
|
|
27
14
|
}
|
|
28
15
|
|
|
29
|
-
TableOfContents.defaultProps = {
|
|
30
|
-
depth: 0
|
|
31
|
-
}
|
|
32
|
-
|
|
33
16
|
export default TableOfContents
|
package/src/components/table.js
CHANGED
package/src/primer-nav.yml
CHANGED