@primer/gatsby-theme-doctocat 4.4.2 → 4.5.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 +14 -0
- package/package.json +1 -1
- package/src/components/header.js +43 -31
- package/src/components/layout.js +37 -2
- package/src/components/nav-dropdown.js +19 -24
- package/src/components/wrap-root-element.js +6 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @primer/gatsby-theme-doctocat
|
|
2
2
|
|
|
3
|
+
## 4.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`c5156b0`](https://github.com/primer/doctocat/commit/c5156b06c8f72ec267fb186be2705c421462f409) [#602](https://github.com/primer/doctocat/pull/602) Thanks [@mperrotti](https://github.com/mperrotti)! - Add breadcrumb nav to default layout
|
|
8
|
+
|
|
9
|
+
* [`4960db2`](https://github.com/primer/doctocat/commit/4960db2a305fe39a529585036c5943119a0c326e) [#594](https://github.com/primer/doctocat/pull/594) Thanks [@kendallgassner](https://github.com/kendallgassner)! - Add visually hidden header to the top navigation. Utilize the ActionMenu component in top nav.
|
|
10
|
+
|
|
11
|
+
## 4.4.3
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [`5f2f390`](https://github.com/primer/doctocat/commit/5f2f3903e93b6a64743c38fead16eaaa14788c4e) [#586](https://github.com/primer/doctocat/pull/586) Thanks [@camertron](https://github.com/camertron)! - Wrap root node with an SSRProvider
|
|
16
|
+
|
|
3
17
|
## 4.4.2
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/package.json
CHANGED
package/src/components/header.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {MarkGithubIcon, SearchIcon, ThreeBarsIcon} from '@primer/octicons-react'
|
|
2
2
|
import {Box, Button, Link, StyledOcticon, Text, ThemeProvider, useTheme} from '@primer/react'
|
|
3
|
+
import VisuallyHidden from './visually-hidden'
|
|
3
4
|
import {Link as GatsbyLink} from 'gatsby'
|
|
4
5
|
import React from 'react'
|
|
5
6
|
import primerNavItems from '../primer-nav.yml'
|
|
@@ -96,7 +97,7 @@ function Header({isSearchEnabled}) {
|
|
|
96
97
|
</Box>
|
|
97
98
|
<Box>
|
|
98
99
|
<Box sx={{display: ['none', null, null, 'block']}}>
|
|
99
|
-
<PrimerNavItems items={primerNavItems} />
|
|
100
|
+
<PrimerNavItems siteMetadata={siteMetadata} items={primerNavItems} />
|
|
100
101
|
</Box>
|
|
101
102
|
<Box sx={{display: ['flex', null, null, 'none']}}>
|
|
102
103
|
{isSearchEnabled ? (
|
|
@@ -137,39 +138,50 @@ Header.defaultProps = {
|
|
|
137
138
|
isSearchEnabled: true
|
|
138
139
|
}
|
|
139
140
|
|
|
140
|
-
function PrimerNavItems({items}) {
|
|
141
|
+
function PrimerNavItems({siteMetadata, items}) {
|
|
141
142
|
return (
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
143
|
+
<>
|
|
144
|
+
<VisuallyHidden>
|
|
145
|
+
<h3 aria-labelledby="site-header">{siteMetadata.header.title} </h3>
|
|
146
|
+
</VisuallyHidden>
|
|
147
|
+
<Box
|
|
148
|
+
as={'nav'}
|
|
149
|
+
sx={{display: 'flex', alignItems: 'center', justifyContent: 'space-between', color: 'fg.default', gap: 2}}
|
|
150
|
+
>
|
|
151
|
+
{items.map((item, index) => {
|
|
152
|
+
if (item.children) {
|
|
153
|
+
return (
|
|
154
|
+
<Box key={index}>
|
|
155
|
+
<NavDropdown title={item.title}>
|
|
156
|
+
{item.children.map(child => (
|
|
157
|
+
<NavDropdownItem key={child.title} href={child.url}>
|
|
158
|
+
{child.title}
|
|
159
|
+
</NavDropdownItem>
|
|
160
|
+
))}
|
|
161
|
+
</NavDropdown>
|
|
162
|
+
</Box>
|
|
163
|
+
)
|
|
164
|
+
}
|
|
165
|
+
|
|
145
166
|
return (
|
|
146
|
-
<
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
167
|
+
<Link
|
|
168
|
+
key={index}
|
|
169
|
+
href={item.url}
|
|
170
|
+
sx={{
|
|
171
|
+
display: 'block',
|
|
172
|
+
color: 'fg.default',
|
|
173
|
+
fontSize: 2,
|
|
174
|
+
fontWeight: 'bold',
|
|
175
|
+
ml: 2,
|
|
176
|
+
mr: 2
|
|
177
|
+
}}
|
|
178
|
+
>
|
|
179
|
+
{item.title}
|
|
180
|
+
</Link>
|
|
155
181
|
)
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
<Link
|
|
160
|
-
key={index}
|
|
161
|
-
href={item.url}
|
|
162
|
-
sx={{
|
|
163
|
-
display: 'block',
|
|
164
|
-
color: 'inherit',
|
|
165
|
-
ml: 4
|
|
166
|
-
}}
|
|
167
|
-
>
|
|
168
|
-
{item.title}
|
|
169
|
-
</Link>
|
|
170
|
-
)
|
|
171
|
-
})}
|
|
172
|
-
</Box>
|
|
182
|
+
})}
|
|
183
|
+
</Box>
|
|
184
|
+
</>
|
|
173
185
|
)
|
|
174
186
|
}
|
|
175
187
|
|
package/src/components/layout.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import componentMetadata from '@primer/component-metadata'
|
|
2
|
-
import {Box, Heading, Text} from '@primer/react'
|
|
2
|
+
import {Box, Breadcrumbs, Heading, Text} from '@primer/react'
|
|
3
3
|
import React from 'react'
|
|
4
4
|
import Head from './head'
|
|
5
5
|
import Header, {HEADER_HEIGHT} from './header'
|
|
@@ -14,8 +14,33 @@ import LookbookLink from './lookbook-link'
|
|
|
14
14
|
import StorybookLink from './storybook-link'
|
|
15
15
|
import FigmaLink from './figma-link'
|
|
16
16
|
import TableOfContents from './table-of-contents'
|
|
17
|
+
import navItems from '../nav.yml'
|
|
17
18
|
|
|
18
|
-
|
|
19
|
+
const getPageAncestry = (url, object) => {
|
|
20
|
+
const result = []
|
|
21
|
+
const buildArray = (node, path) => {
|
|
22
|
+
if (node.url === path) {
|
|
23
|
+
result.push({title: node.title, url: node.url})
|
|
24
|
+
} else if (node.children) {
|
|
25
|
+
for (const child of node.children) {
|
|
26
|
+
buildArray(child, path)
|
|
27
|
+
if (result.length > 0) {
|
|
28
|
+
result.unshift({title: node.title, url: node.url})
|
|
29
|
+
break
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
for (const node of object) {
|
|
35
|
+
buildArray(node, url)
|
|
36
|
+
if (result.length > 0) {
|
|
37
|
+
break
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return result
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function Layout({children, pageContext, path}) {
|
|
19
44
|
let {
|
|
20
45
|
title,
|
|
21
46
|
description,
|
|
@@ -42,6 +67,7 @@ function Layout({children, pageContext}) {
|
|
|
42
67
|
title ||= component.displayName
|
|
43
68
|
description ||= component.description
|
|
44
69
|
}
|
|
70
|
+
const breadcrumbData = getPageAncestry(path, navItems).filter(item => item.url)
|
|
45
71
|
|
|
46
72
|
return (
|
|
47
73
|
<Box sx={{flexDirection: 'column', minHeight: '100vh', display: 'flex'}}>
|
|
@@ -81,6 +107,15 @@ function Layout({children, pageContext}) {
|
|
|
81
107
|
) : null}
|
|
82
108
|
<Box sx={{width: '100%', maxWidth: '960px'}}>
|
|
83
109
|
<Box as="main" id="skip-nav" sx={{mb: 4}}>
|
|
110
|
+
<Breadcrumbs sx={{mb: 4}}>
|
|
111
|
+
{breadcrumbData.length > 1
|
|
112
|
+
? breadcrumbData.map(item => (
|
|
113
|
+
<Breadcrumbs.Item key={item.url} href={item.url} selected={path === item.url}>
|
|
114
|
+
{item.title}
|
|
115
|
+
</Breadcrumbs.Item>
|
|
116
|
+
))
|
|
117
|
+
: null}
|
|
118
|
+
</Breadcrumbs>
|
|
84
119
|
<Box sx={{alignItems: 'center', display: 'flex'}}>
|
|
85
120
|
<Heading as="h1">{title}</Heading>{' '}
|
|
86
121
|
</Box>
|
|
@@ -1,36 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {TriangleDownIcon} from '@primer/octicons-react'
|
|
1
|
+
import {ActionMenu, ActionList, themeGet, useDetails} from '@primer/react'
|
|
3
2
|
import React from 'react'
|
|
4
3
|
import styled from 'styled-components'
|
|
5
4
|
|
|
6
5
|
function NavDropdown({title, children}) {
|
|
7
6
|
const {getDetailsProps} = useDetails({closeOnOutsideClick: true})
|
|
8
7
|
return (
|
|
9
|
-
<
|
|
10
|
-
<
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
{children}
|
|
27
|
-
</Box>
|
|
28
|
-
</Box>
|
|
29
|
-
</Details>
|
|
8
|
+
<ActionMenu {...getDetailsProps()}>
|
|
9
|
+
<ActionMenu.Button
|
|
10
|
+
variant="invisible"
|
|
11
|
+
sx={{
|
|
12
|
+
fontSize: 2,
|
|
13
|
+
color: 'fg.default',
|
|
14
|
+
':hover:not([disabled])': {
|
|
15
|
+
backgroundColor: 'canvas.subtle'
|
|
16
|
+
}
|
|
17
|
+
}}
|
|
18
|
+
>
|
|
19
|
+
{title}
|
|
20
|
+
</ActionMenu.Button>
|
|
21
|
+
<ActionMenu.Overlay width="auto">
|
|
22
|
+
<ActionList>{children}</ActionList>
|
|
23
|
+
</ActionMenu.Overlay>
|
|
24
|
+
</ActionMenu>
|
|
30
25
|
)
|
|
31
26
|
}
|
|
32
27
|
|
|
33
|
-
export const NavDropdownItem = styled.
|
|
28
|
+
export const NavDropdownItem = styled(ActionList.LinkItem)`
|
|
34
29
|
display: block;
|
|
35
30
|
padding: ${themeGet('space.2')};
|
|
36
31
|
color: inherit;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {SSRProvider} from '@react-aria/ssr'
|
|
1
2
|
import {MDXProvider} from '@mdx-js/react'
|
|
2
3
|
import {ThemeProvider} from '@primer/react'
|
|
3
4
|
import Link from './link'
|
|
@@ -52,9 +53,11 @@ const components = {
|
|
|
52
53
|
|
|
53
54
|
function wrapRootElement({element}) {
|
|
54
55
|
return (
|
|
55
|
-
<
|
|
56
|
-
<
|
|
57
|
-
|
|
56
|
+
<SSRProvider>
|
|
57
|
+
<MDXProvider components={components}>
|
|
58
|
+
<ThemeProvider>{element}</ThemeProvider>
|
|
59
|
+
</MDXProvider>
|
|
60
|
+
</SSRProvider>
|
|
58
61
|
)
|
|
59
62
|
}
|
|
60
63
|
|