@primer/gatsby-theme-doctocat 2.0.0 → 3.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/.eslintrc.json +25 -0
- package/CHANGELOG.md +44 -0
- package/babel.config.js +1 -1
- package/gatsby-config.js +10 -13
- package/gatsby-node.js +52 -42
- package/jest.config.js +1 -1
- package/package.json +16 -5
- package/src/components/__tests__/contributors.test.js +13 -15
- package/src/components/__tests__/page-footer.test.js +2 -6
- package/src/components/clipboard-copy.js +2 -2
- package/src/components/code.js +4 -15
- package/src/components/contributors.js +4 -12
- package/src/components/details.js +1 -1
- package/src/components/do-dont.js +7 -36
- package/src/components/drawer.js +3 -10
- package/src/components/head.js +1 -3
- package/src/components/header.js +13 -35
- package/src/components/heading.js +1 -1
- package/src/components/hero-layout.js +3 -5
- package/src/components/hero.js +1 -1
- package/src/components/image-container.js +2 -4
- package/src/components/layout.js +25 -44
- package/src/components/live-code.js +7 -20
- package/src/components/mobile-search.js +14 -35
- package/src/components/nav-drawer.js +15 -66
- package/src/components/nav-dropdown.js +3 -10
- package/src/components/nav-items.js +11 -20
- package/src/components/note.js +6 -6
- package/src/components/page-footer.js +5 -7
- package/src/components/search-results.js +2 -2
- package/src/components/search.js +14 -23
- package/src/components/sidebar.js +11 -12
- package/src/components/skip-link.js +1 -1
- package/src/components/status-label.js +2 -6
- package/src/components/table-of-contents.js +3 -5
- package/src/components/wrap-root-element.js +3 -1
- package/src/github.js +33 -44
- package/src/mdx-components.js +2 -0
- package/src/prism.js +16 -16
- package/src/search.worker.js +11 -8
- package/src/use-search.js +6 -7
- package/coverage/clover.xml +0 -421
- package/coverage/coverage-final.json +0 -50
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -79
- package/coverage/lcov-report/index.html +0 -125
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -170
- package/coverage/lcov-report/src/components/blockquote.js.html +0 -136
- package/coverage/lcov-report/src/components/caption.js.html +0 -103
- package/coverage/lcov-report/src/components/clipboard-copy.js.html +0 -184
- package/coverage/lcov-report/src/components/code.js.html +0 -280
- package/coverage/lcov-report/src/components/container.js.html +0 -115
- package/coverage/lcov-report/src/components/contributors.js.html +0 -238
- package/coverage/lcov-report/src/components/description-list.js.html +0 -142
- package/coverage/lcov-report/src/components/details.js.html +0 -283
- package/coverage/lcov-report/src/components/do-dont.js.html +0 -283
- package/coverage/lcov-report/src/components/drawer.js.html +0 -247
- package/coverage/lcov-report/src/components/frame.js.html +0 -184
- package/coverage/lcov-report/src/components/head.js.html +0 -151
- package/coverage/lcov-report/src/components/header.js.html +0 -628
- package/coverage/lcov-report/src/components/heading.js.html +0 -325
- package/coverage/lcov-report/src/components/hero-layout.js.html +0 -205
- package/coverage/lcov-report/src/components/hero.js.html +0 -154
- package/coverage/lcov-report/src/components/horizontal-rule.js.html +0 -115
- package/coverage/lcov-report/src/components/image-container.js.html +0 -121
- package/coverage/lcov-report/src/components/image.js.html +0 -109
- package/coverage/lcov-report/src/components/index.html +0 -740
- package/coverage/lcov-report/src/components/inline-code.js.html +0 -115
- package/coverage/lcov-report/src/components/layout.js.html +0 -493
- package/coverage/lcov-report/src/components/list.js.html +0 -157
- package/coverage/lcov-report/src/components/live-code.js.html +0 -367
- package/coverage/lcov-report/src/components/live-preview-wrapper.js.html +0 -130
- package/coverage/lcov-report/src/components/mobile-search.js.html +0 -505
- package/coverage/lcov-report/src/components/nav-drawer.js.html +0 -595
- package/coverage/lcov-report/src/components/nav-dropdown.js.html +0 -235
- package/coverage/lcov-report/src/components/nav-items.js.html +0 -367
- package/coverage/lcov-report/src/components/note.js.html +0 -190
- package/coverage/lcov-report/src/components/page-footer.js.html +0 -166
- package/coverage/lcov-report/src/components/paragraph.js.html +0 -103
- package/coverage/lcov-report/src/components/search-results.js.html +0 -241
- package/coverage/lcov-report/src/components/search.js.html +0 -373
- package/coverage/lcov-report/src/components/sidebar.js.html +0 -253
- package/coverage/lcov-report/src/components/skip-link.js.html +0 -214
- package/coverage/lcov-report/src/components/source-link.js.html +0 -127
- package/coverage/lcov-report/src/components/status-label.js.html +0 -160
- package/coverage/lcov-report/src/components/storybook-link.js.html +0 -169
- package/coverage/lcov-report/src/components/table-of-contents.js.html +0 -184
- package/coverage/lcov-report/src/components/table.js.html +0 -181
- package/coverage/lcov-report/src/components/text-input.js.html +0 -112
- package/coverage/lcov-report/src/components/wrap-page-element.js.html +0 -148
- package/coverage/lcov-report/src/components/wrap-root-element.js.html +0 -247
- package/coverage/lcov-report/src/github.js.html +0 -301
- package/coverage/lcov-report/src/index.html +0 -185
- package/coverage/lcov-report/src/live-code-scope.js.html +0 -88
- package/coverage/lcov-report/src/prism.js.html +0 -160
- package/coverage/lcov-report/src/search.worker.js.html +0 -175
- package/coverage/lcov-report/src/use-search.js.html +0 -307
- package/coverage/lcov-report/src/use-site-metadata.js.html +0 -136
- package/coverage/lcov.info +0 -1094
package/src/components/header.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Box,
|
|
3
|
-
Button,
|
|
4
|
-
Link,
|
|
5
|
-
Sticky,
|
|
6
|
-
StyledOcticon,
|
|
7
|
-
Text,
|
|
8
|
-
ThemeProvider,
|
|
9
|
-
useTheme,
|
|
10
|
-
} from '@primer/components'
|
|
1
|
+
import {Box, Button, Link, Sticky, StyledOcticon, Text, ThemeProvider, useTheme} from '@primer/components'
|
|
11
2
|
import {MarkGithubIcon, SearchIcon, ThreeBarsIcon} from '@primer/octicons-react'
|
|
12
3
|
import {Link as GatsbyLink} from 'gatsby'
|
|
13
4
|
import React from 'react'
|
|
@@ -22,9 +13,7 @@ export const HEADER_HEIGHT = 66
|
|
|
22
13
|
|
|
23
14
|
function Header({isSearchEnabled}) {
|
|
24
15
|
const {theme} = useTheme()
|
|
25
|
-
const [isNavDrawerOpen, setIsNavDrawerOpen] = useNavDrawerState(
|
|
26
|
-
theme.breakpoints[2],
|
|
27
|
-
)
|
|
16
|
+
const [isNavDrawerOpen, setIsNavDrawerOpen] = useNavDrawerState(theme.breakpoints[2])
|
|
28
17
|
const [isMobileSearchOpen, setIsMobileSearchOpen] = React.useState(false)
|
|
29
18
|
const siteMetadata = useSiteMetadata()
|
|
30
19
|
return (
|
|
@@ -44,7 +33,7 @@ function Header({isSearchEnabled}) {
|
|
|
44
33
|
sx={{
|
|
45
34
|
color: 'accent.fg',
|
|
46
35
|
mr: 3,
|
|
47
|
-
lineHeight: 'condensedUltra'
|
|
36
|
+
lineHeight: 'condensedUltra'
|
|
48
37
|
}}
|
|
49
38
|
>
|
|
50
39
|
<StyledOcticon icon={MarkGithubIcon} size="medium" />
|
|
@@ -59,8 +48,8 @@ function Header({isSearchEnabled}) {
|
|
|
59
48
|
siteMetadata.shortName ? 'none' : 'inline-block',
|
|
60
49
|
null,
|
|
61
50
|
null,
|
|
62
|
-
'inline-block'
|
|
63
|
-
]
|
|
51
|
+
'inline-block'
|
|
52
|
+
]
|
|
64
53
|
}}
|
|
65
54
|
>
|
|
66
55
|
Primer
|
|
@@ -68,12 +57,7 @@ function Header({isSearchEnabled}) {
|
|
|
68
57
|
|
|
69
58
|
{siteMetadata.shortName ? (
|
|
70
59
|
<>
|
|
71
|
-
<Text
|
|
72
|
-
display={['none', null, null, 'inline-block']}
|
|
73
|
-
color="accent.fg"
|
|
74
|
-
fontFamily="mono"
|
|
75
|
-
mx={2}
|
|
76
|
-
>
|
|
60
|
+
<Text display={['none', null, null, 'inline-block']} color="accent.fg" fontFamily="mono" mx={2}>
|
|
77
61
|
/
|
|
78
62
|
</Text>
|
|
79
63
|
<Link
|
|
@@ -81,7 +65,7 @@ function Header({isSearchEnabled}) {
|
|
|
81
65
|
to="/"
|
|
82
66
|
sx={{
|
|
83
67
|
color: 'accent.fg',
|
|
84
|
-
fontFamily: 'mono'
|
|
68
|
+
fontFamily: 'mono'
|
|
85
69
|
}}
|
|
86
70
|
>
|
|
87
71
|
{siteMetadata.shortName}
|
|
@@ -107,15 +91,12 @@ function Header({isSearchEnabled}) {
|
|
|
107
91
|
aria-expanded={isMobileSearchOpen}
|
|
108
92
|
onClick={() => setIsMobileSearchOpen(true)}
|
|
109
93
|
sx={{
|
|
110
|
-
ml: 3
|
|
94
|
+
ml: 3
|
|
111
95
|
}}
|
|
112
96
|
>
|
|
113
97
|
<SearchIcon />
|
|
114
98
|
</Button>
|
|
115
|
-
<MobileSearch
|
|
116
|
-
isOpen={isMobileSearchOpen}
|
|
117
|
-
onDismiss={() => setIsMobileSearchOpen(false)}
|
|
118
|
-
/>
|
|
99
|
+
<MobileSearch isOpen={isMobileSearchOpen} onDismiss={() => setIsMobileSearchOpen(false)} />
|
|
119
100
|
</>
|
|
120
101
|
) : null}
|
|
121
102
|
<Button
|
|
@@ -123,15 +104,12 @@ function Header({isSearchEnabled}) {
|
|
|
123
104
|
aria-expanded={isNavDrawerOpen}
|
|
124
105
|
onClick={() => setIsNavDrawerOpen(true)}
|
|
125
106
|
sx={{
|
|
126
|
-
ml: 3
|
|
107
|
+
ml: 3
|
|
127
108
|
}}
|
|
128
109
|
>
|
|
129
110
|
<ThreeBarsIcon />
|
|
130
111
|
</Button>
|
|
131
|
-
<NavDrawer
|
|
132
|
-
isOpen={isNavDrawerOpen}
|
|
133
|
-
onDismiss={() => setIsNavDrawerOpen(false)}
|
|
134
|
-
/>
|
|
112
|
+
<NavDrawer isOpen={isNavDrawerOpen} onDismiss={() => setIsNavDrawerOpen(false)} />
|
|
135
113
|
</Box>
|
|
136
114
|
</Box>
|
|
137
115
|
</Box>
|
|
@@ -141,7 +119,7 @@ function Header({isSearchEnabled}) {
|
|
|
141
119
|
}
|
|
142
120
|
|
|
143
121
|
Header.defaultProps = {
|
|
144
|
-
isSearchEnabled: true
|
|
122
|
+
isSearchEnabled: true
|
|
145
123
|
}
|
|
146
124
|
|
|
147
125
|
function PrimerNavItems({items}) {
|
|
@@ -169,7 +147,7 @@ function PrimerNavItems({items}) {
|
|
|
169
147
|
sx={{
|
|
170
148
|
display: 'block',
|
|
171
149
|
color: 'inherit',
|
|
172
|
-
ml: 4
|
|
150
|
+
ml: 4
|
|
173
151
|
}}
|
|
174
152
|
>
|
|
175
153
|
{item.title}
|
|
@@ -15,10 +15,10 @@ function HeroLayout({children, pageContext}) {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
return (
|
|
18
|
-
<Flex flexDirection
|
|
18
|
+
<Flex sx={{flexDirection: 'column', minHeight: '100vh'}}>
|
|
19
19
|
<Head />
|
|
20
20
|
<Header />
|
|
21
|
-
<Flex flex
|
|
21
|
+
<Flex sx={{flex: '1 1 auto', flexDirection: 'row'}}>
|
|
22
22
|
<Box display={['none', null, null, 'block']}>
|
|
23
23
|
<Sidebar />
|
|
24
24
|
</Box>
|
|
@@ -28,9 +28,7 @@ function HeroLayout({children, pageContext}) {
|
|
|
28
28
|
{children}
|
|
29
29
|
<PageFooter
|
|
30
30
|
editUrl={pageContext.editUrl}
|
|
31
|
-
contributors={pageContext.contributors.concat(
|
|
32
|
-
additionalContributors.map(login => ({login})),
|
|
33
|
-
)}
|
|
31
|
+
contributors={pageContext.contributors.concat(additionalContributors.map(login => ({login})))}
|
|
34
32
|
/>
|
|
35
33
|
</Container>
|
|
36
34
|
</Box>
|
package/src/components/hero.js
CHANGED
|
@@ -10,7 +10,7 @@ function Hero() {
|
|
|
10
10
|
<ThemeProvider colorMode="night" nightScheme="dark_dimmed">
|
|
11
11
|
<Box bg="canvas.default" py={6}>
|
|
12
12
|
<Container>
|
|
13
|
-
<Heading as="h1" color
|
|
13
|
+
<Heading as="h1" sx={{color: 'accent.fg', fontSize: 7, m: 0}}>
|
|
14
14
|
{title}
|
|
15
15
|
</Heading>
|
|
16
16
|
<Text as="p" m={0} color="fg.default" fontSize={4}>
|
|
@@ -3,10 +3,8 @@ import React from 'react'
|
|
|
3
3
|
|
|
4
4
|
function ImageContainer({children}) {
|
|
5
5
|
return (
|
|
6
|
-
<BorderBox
|
|
7
|
-
<Flex
|
|
8
|
-
{children}
|
|
9
|
-
</Flex>
|
|
6
|
+
<BorderBox sx={{p: 6, bg: 'gray.1'}}>
|
|
7
|
+
<Flex sx={{img: {maxWidth: '100%'}, justifyContent: 'center'}}>{children}</Flex>
|
|
10
8
|
</BorderBox>
|
|
11
9
|
)
|
|
12
10
|
}
|
package/src/components/layout.js
CHANGED
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
import componentMetadata from '@primer/component-metadata'
|
|
2
|
-
import {
|
|
3
|
-
BorderBox,
|
|
4
|
-
Box,
|
|
5
|
-
Flex,
|
|
6
|
-
Grid,
|
|
7
|
-
Heading,
|
|
8
|
-
Position,
|
|
9
|
-
Text,
|
|
10
|
-
} from '@primer/components'
|
|
2
|
+
import {BorderBox, Box, Flex, Grid, Heading, Position, Text} from '@primer/components'
|
|
11
3
|
import React from 'react'
|
|
12
4
|
import Head from './head'
|
|
13
5
|
import Header, {HEADER_HEIGHT} from './header'
|
|
@@ -19,15 +11,7 @@ import StorybookLink from './storybook-link'
|
|
|
19
11
|
import TableOfContents from './table-of-contents'
|
|
20
12
|
|
|
21
13
|
function Layout({children, pageContext}) {
|
|
22
|
-
let {
|
|
23
|
-
title,
|
|
24
|
-
description,
|
|
25
|
-
status,
|
|
26
|
-
source,
|
|
27
|
-
storybook,
|
|
28
|
-
additionalContributors,
|
|
29
|
-
componentId,
|
|
30
|
-
} = pageContext.frontmatter
|
|
14
|
+
let {title, description, status, source, storybook, additionalContributors, componentId} = pageContext.frontmatter
|
|
31
15
|
|
|
32
16
|
if (!additionalContributors) {
|
|
33
17
|
additionalContributors = []
|
|
@@ -42,10 +26,10 @@ function Layout({children, pageContext}) {
|
|
|
42
26
|
}
|
|
43
27
|
|
|
44
28
|
return (
|
|
45
|
-
<Flex flexDirection
|
|
29
|
+
<Flex sx={{flexDirection: 'column', minHeight: '100vh'}}>
|
|
46
30
|
<Head title={title} description={description} />
|
|
47
31
|
<Header />
|
|
48
|
-
<Flex flex
|
|
32
|
+
<Flex css={{zIndex: 0}} sx={{flex: '1 1 auto', flexDirection: 'row'}}>
|
|
49
33
|
<Box display={['none', null, null, 'block']}>
|
|
50
34
|
<Sidebar />
|
|
51
35
|
</Box>
|
|
@@ -56,17 +40,21 @@ function Layout({children, pageContext}) {
|
|
|
56
40
|
p={[4, 5, 6, 7]}
|
|
57
41
|
sx={{
|
|
58
42
|
justifyContent: 'center',
|
|
59
|
-
flexDirection: 'row-reverse'
|
|
43
|
+
flexDirection: 'row-reverse'
|
|
60
44
|
}}
|
|
61
45
|
>
|
|
62
46
|
{pageContext.tableOfContents.items ? (
|
|
63
47
|
<Position
|
|
64
|
-
sx={{
|
|
65
|
-
|
|
48
|
+
sx={{
|
|
49
|
+
width: 220,
|
|
50
|
+
flex: '0 0 auto',
|
|
51
|
+
marginLeft: 6,
|
|
52
|
+
display: ['none', null, 'block'],
|
|
53
|
+
position: 'sticky',
|
|
54
|
+
top: HEADER_HEIGHT + 48,
|
|
55
|
+
maxHeight: `calc(100vh - ${HEADER_HEIGHT}px - 48px)`
|
|
56
|
+
}}
|
|
66
57
|
css={{gridArea: 'table-of-contents', overflow: 'auto'}}
|
|
67
|
-
position="sticky"
|
|
68
|
-
top={HEADER_HEIGHT + 24}
|
|
69
|
-
maxHeight={`calc(100vh - ${HEADER_HEIGHT}px - 24px)`}
|
|
70
58
|
>
|
|
71
59
|
<Text display="inline-block" fontWeight="bold" mb={1}>
|
|
72
60
|
On this page
|
|
@@ -77,7 +65,7 @@ function Layout({children, pageContext}) {
|
|
|
77
65
|
<Box width="100%" maxWidth="960px">
|
|
78
66
|
<Box mb={4}>
|
|
79
67
|
<Flex sx={{alignItems: 'center'}}>
|
|
80
|
-
<Heading as="h1"
|
|
68
|
+
<Heading as="h1" sx={{mr: 2}}>
|
|
81
69
|
{title}
|
|
82
70
|
</Heading>{' '}
|
|
83
71
|
{status ? <StatusLabel status={status} /> : null}
|
|
@@ -89,11 +77,13 @@ function Layout({children, pageContext}) {
|
|
|
89
77
|
) : null}
|
|
90
78
|
{source || storybook ? (
|
|
91
79
|
<Grid
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
80
|
+
sx={{
|
|
81
|
+
py: 2,
|
|
82
|
+
gridGap: [1, null, 3],
|
|
83
|
+
gridAutoFlow: ['row', null, 'column'],
|
|
84
|
+
gridAutoColumns: 'max-content',
|
|
85
|
+
gridAutoRows: 'max-content'
|
|
86
|
+
}}
|
|
97
87
|
>
|
|
98
88
|
{source ? <SourceLink href={source} /> : null}
|
|
99
89
|
{storybook ? <StorybookLink href={storybook} /> : null}
|
|
@@ -102,17 +92,10 @@ function Layout({children, pageContext}) {
|
|
|
102
92
|
</Box>
|
|
103
93
|
{pageContext.tableOfContents.items ? (
|
|
104
94
|
<BorderBox
|
|
105
|
-
|
|
106
|
-
mb={5}
|
|
107
|
-
borderColor="border.muted"
|
|
108
|
-
bg="canvas.subtle"
|
|
95
|
+
sx={{display: ['block', null, 'none'], mb: 5, borderColor: 'border.muted', bg: 'canvas.subtle'}}
|
|
109
96
|
>
|
|
110
97
|
<Box p={3}>
|
|
111
|
-
<Flex
|
|
112
|
-
flexDirection="row"
|
|
113
|
-
justifyContent="space-between"
|
|
114
|
-
alignItems="center"
|
|
115
|
-
>
|
|
98
|
+
<Flex sx={{flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center'}}>
|
|
116
99
|
<Text fontWeight="bold">On this page</Text>
|
|
117
100
|
</Flex>
|
|
118
101
|
</Box>
|
|
@@ -124,9 +107,7 @@ function Layout({children, pageContext}) {
|
|
|
124
107
|
{children}
|
|
125
108
|
<PageFooter
|
|
126
109
|
editUrl={pageContext.editUrl}
|
|
127
|
-
contributors={pageContext.contributors.concat(
|
|
128
|
-
additionalContributors.map((login) => ({login})),
|
|
129
|
-
)}
|
|
110
|
+
contributors={pageContext.contributors.concat(additionalContributors.map(login => ({login})))}
|
|
130
111
|
/>
|
|
131
112
|
</Box>
|
|
132
113
|
</Box>
|
|
@@ -11,7 +11,7 @@ import LivePreviewWrapper from './live-preview-wrapper'
|
|
|
11
11
|
|
|
12
12
|
const languageTransformers = {
|
|
13
13
|
html: html => htmlToJsx(html),
|
|
14
|
-
jsx: jsx => wrapWithFragment(jsx)
|
|
14
|
+
jsx: jsx => wrapWithFragment(jsx)
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
function htmlToJsx(html) {
|
|
@@ -40,19 +40,14 @@ function LiveCode({code, language, noinline}) {
|
|
|
40
40
|
const handleChange = updatedLiveCode => setLiveCode(updatedLiveCode)
|
|
41
41
|
|
|
42
42
|
return (
|
|
43
|
-
<Flex flexDirection
|
|
44
|
-
<LiveProvider
|
|
45
|
-
scope={scope}
|
|
46
|
-
code={liveCode}
|
|
47
|
-
transformCode={languageTransformers[language]}
|
|
48
|
-
noInline={noinline}
|
|
49
|
-
>
|
|
43
|
+
<Flex sx={{flexDirection: 'column', mb: 3}}>
|
|
44
|
+
<LiveProvider scope={scope} code={liveCode} transformCode={languageTransformers[language]} noInline={noinline}>
|
|
50
45
|
<Flex
|
|
51
46
|
sx={{
|
|
52
47
|
border: '1px solid',
|
|
53
48
|
borderColor: 'border.default',
|
|
54
49
|
borderTopRightRadius: 2,
|
|
55
|
-
borderTopLeftRadius: 2
|
|
50
|
+
borderTopLeftRadius: 2
|
|
56
51
|
}}
|
|
57
52
|
>
|
|
58
53
|
<LivePreviewWrapper>
|
|
@@ -72,22 +67,14 @@ function LiveCode({code, language, noinline}) {
|
|
|
72
67
|
borderBottomRightRadius: theme.radii[2],
|
|
73
68
|
border: '1px solid',
|
|
74
69
|
borderTop: 0,
|
|
75
|
-
borderColor: theme.colors.border.default
|
|
70
|
+
borderColor: theme.colors.border.default
|
|
76
71
|
}}
|
|
77
72
|
/>
|
|
78
|
-
<Absolute
|
|
73
|
+
<Absolute sx={{top: 0, right: 0, p: 2}}>
|
|
79
74
|
<ClipboardCopy value={liveCode} />
|
|
80
75
|
</Absolute>
|
|
81
76
|
</Relative>
|
|
82
|
-
<Text
|
|
83
|
-
as={LiveError}
|
|
84
|
-
m={0}
|
|
85
|
-
p={3}
|
|
86
|
-
fontFamily="mono"
|
|
87
|
-
fontSize={1}
|
|
88
|
-
color="fg.onEmphasis"
|
|
89
|
-
bg="danger.emphasis"
|
|
90
|
-
/>
|
|
77
|
+
<Text as={LiveError} m={0} p={3} fontFamily="mono" fontSize={1} color="fg.onEmphasis" bg="danger.emphasis" />
|
|
91
78
|
</LiveProvider>
|
|
92
79
|
</Flex>
|
|
93
80
|
)
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import {Absolute, Box, Button, Fixed, Flex} from '@primer/components'
|
|
2
|
+
import {XIcon} from '@primer/octicons-react'
|
|
3
3
|
import Downshift from 'downshift'
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import {AnimatePresence, motion} from 'framer-motion'
|
|
5
|
+
import {navigate} from 'gatsby'
|
|
6
6
|
import React from 'react'
|
|
7
|
-
import {
|
|
7
|
+
import {FocusOn} from 'react-focus-on'
|
|
8
8
|
import useSearch from '../use-search'
|
|
9
9
|
import TextInput from './text-input'
|
|
10
10
|
import SearchResults from './search-results'
|
|
@@ -38,19 +38,14 @@ function MobileSearch({isOpen, onDismiss}) {
|
|
|
38
38
|
<AnimatePresence>
|
|
39
39
|
{isOpen ? (
|
|
40
40
|
<FocusOn returnFocus={true} onEscapeKey={() => handleDismiss()}>
|
|
41
|
-
<Fixed
|
|
41
|
+
<Fixed sx={{top: 0, left: 0, right: 0, bottom: 0, zIndex: 1}}>
|
|
42
42
|
<Absolute
|
|
43
43
|
as={motion.div}
|
|
44
44
|
initial={{opacity: 0}}
|
|
45
45
|
animate={{opacity: 1}}
|
|
46
46
|
exit={{opacity: 0}}
|
|
47
|
-
top={0}
|
|
48
|
-
left={0}
|
|
49
|
-
right={0}
|
|
50
|
-
bottom={0}
|
|
51
|
-
bg="primer.canvas.backdrop"
|
|
52
|
-
zIndex={-1}
|
|
53
47
|
onClick={handleDismiss}
|
|
48
|
+
sx={{top: 0, left: 0, right: 0, bottom: 0, bg: 'primer.canvas.backdrop', zIndex: -1}}
|
|
54
49
|
/>
|
|
55
50
|
<Downshift
|
|
56
51
|
inputValue={query}
|
|
@@ -65,26 +60,14 @@ function MobileSearch({isOpen, onDismiss}) {
|
|
|
65
60
|
itemToString={item => (item ? item.title : '')}
|
|
66
61
|
stateReducer={stateReducer}
|
|
67
62
|
>
|
|
68
|
-
{({
|
|
69
|
-
getInputProps,
|
|
70
|
-
getItemProps,
|
|
71
|
-
getMenuProps,
|
|
72
|
-
getRootProps,
|
|
73
|
-
isOpen: isMenuOpen,
|
|
74
|
-
highlightedIndex,
|
|
75
|
-
}) => (
|
|
63
|
+
{({getInputProps, getItemProps, getMenuProps, getRootProps, isOpen: isMenuOpen, highlightedIndex}) => (
|
|
76
64
|
<Flex
|
|
77
65
|
{...getRootProps({
|
|
78
66
|
flexDirection: 'column',
|
|
79
|
-
height: isMenuOpen ? '100%' : 'auto'
|
|
67
|
+
height: isMenuOpen ? '100%' : 'auto'
|
|
80
68
|
})}
|
|
81
69
|
>
|
|
82
|
-
<Flex
|
|
83
|
-
bg="canvas.default"
|
|
84
|
-
color="fg.default"
|
|
85
|
-
p={3}
|
|
86
|
-
flex="0 0 auto"
|
|
87
|
-
>
|
|
70
|
+
<Flex sx={{bg: 'canvas.default', color: 'fg.default', p: 3, flex: '0 0 auto'}}>
|
|
88
71
|
<motion.div
|
|
89
72
|
initial={{scaleX: 0.1}}
|
|
90
73
|
animate={{scaleX: 1}}
|
|
@@ -95,15 +78,11 @@ function MobileSearch({isOpen, onDismiss}) {
|
|
|
95
78
|
<TextInput
|
|
96
79
|
{...getInputProps({
|
|
97
80
|
placeholder: `Search`,
|
|
98
|
-
width: '100%'
|
|
81
|
+
sx: {width: '100%'}
|
|
99
82
|
})}
|
|
100
83
|
/>
|
|
101
84
|
</motion.div>
|
|
102
|
-
<Button
|
|
103
|
-
aria-label="Cancel"
|
|
104
|
-
onClick={handleDismiss}
|
|
105
|
-
sx={{ml: 3}}
|
|
106
|
-
>
|
|
85
|
+
<Button aria-label="Cancel" onClick={handleDismiss} sx={{ml: 3}}>
|
|
107
86
|
<XIcon />
|
|
108
87
|
</Button>
|
|
109
88
|
</Flex>
|
|
@@ -118,8 +97,8 @@ function MobileSearch({isOpen, onDismiss}) {
|
|
|
118
97
|
flex: '1 1 auto',
|
|
119
98
|
style: {
|
|
120
99
|
overflow: 'auto',
|
|
121
|
-
WebkitOverflowScrolling: 'touch'
|
|
122
|
-
}
|
|
100
|
+
WebkitOverflowScrolling: 'touch'
|
|
101
|
+
}
|
|
123
102
|
})}
|
|
124
103
|
>
|
|
125
104
|
<SearchResults
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BorderBox,
|
|
3
|
-
Flex,
|
|
4
|
-
Link,
|
|
5
|
-
Text,
|
|
6
|
-
Button,
|
|
7
|
-
ThemeProvider,
|
|
8
|
-
} from '@primer/components'
|
|
1
|
+
import {BorderBox, Flex, Link, Text, Button, ThemeProvider} from '@primer/components'
|
|
9
2
|
import {ChevronDownIcon, ChevronUpIcon, XIcon} from '@primer/octicons-react'
|
|
10
3
|
import {Link as GatsbyLink} from 'gatsby'
|
|
11
4
|
import debounce from 'lodash.debounce'
|
|
@@ -30,9 +23,7 @@ export function useNavDrawerState(breakpoint) {
|
|
|
30
23
|
}
|
|
31
24
|
}, [setOpen])
|
|
32
25
|
|
|
33
|
-
const debouncedOnResize = React.useCallback(debounce(onResize, 250), [
|
|
34
|
-
onResize,
|
|
35
|
-
])
|
|
26
|
+
const debouncedOnResize = React.useCallback(debounce(onResize, 250), [onResize])
|
|
36
27
|
|
|
37
28
|
React.useEffect(() => {
|
|
38
29
|
if (isOpen) {
|
|
@@ -53,35 +44,13 @@ function NavDrawer({isOpen, onDismiss}) {
|
|
|
53
44
|
return (
|
|
54
45
|
<Drawer isOpen={isOpen} onDismiss={onDismiss}>
|
|
55
46
|
<Flex
|
|
56
|
-
flexDirection="column"
|
|
57
|
-
height="100%"
|
|
58
|
-
bg="canvas.default"
|
|
59
47
|
style={{overflow: 'auto', WebkitOverflowScrolling: 'touch'}}
|
|
48
|
+
sx={{flexDirection: 'column', height: '100%', bg: 'canvas.default'}}
|
|
60
49
|
>
|
|
61
|
-
<Flex
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
bg="canvas.default"
|
|
66
|
-
>
|
|
67
|
-
<BorderBox
|
|
68
|
-
borderWidth={0}
|
|
69
|
-
borderRadius={0}
|
|
70
|
-
borderBottomWidth={1}
|
|
71
|
-
borderColor="border.muted"
|
|
72
|
-
>
|
|
73
|
-
<Flex
|
|
74
|
-
py={3}
|
|
75
|
-
pl={4}
|
|
76
|
-
pr={3}
|
|
77
|
-
alignItems="center"
|
|
78
|
-
justifyContent="space-between"
|
|
79
|
-
>
|
|
80
|
-
<Link
|
|
81
|
-
href="https://primer.style"
|
|
82
|
-
fontFamily="mono"
|
|
83
|
-
color="inherit"
|
|
84
|
-
>
|
|
50
|
+
<Flex sx={{flexDirection: 'column', flex: '0 0 auto', color: 'fg.default', bg: 'canvas.default'}}>
|
|
51
|
+
<BorderBox sx={{borderWidth: 0, borderRadius: 0, borderBottomWidth: 1, borderColor: 'border.muted'}}>
|
|
52
|
+
<Flex sx={{py: 3, pl: 4, pr: 3, alignItems: 'center', justifyContent: 'space-between'}}>
|
|
53
|
+
<Link href="https://primer.style" sx={{fontFamily: 'mono', color: 'inherit'}}>
|
|
85
54
|
Primer
|
|
86
55
|
</Link>
|
|
87
56
|
<Button aria-label="Close" onClick={onDismiss}>
|
|
@@ -89,26 +58,17 @@ function NavDrawer({isOpen, onDismiss}) {
|
|
|
89
58
|
</Button>
|
|
90
59
|
</Flex>
|
|
91
60
|
</BorderBox>
|
|
92
|
-
<Flex flexDirection
|
|
61
|
+
<Flex sx={{flexDirection: 'column'}}>
|
|
93
62
|
<PrimerNavItems items={primerNavItems} />
|
|
94
63
|
</Flex>
|
|
95
64
|
</Flex>
|
|
96
65
|
{navItems.length > 0 ? (
|
|
97
66
|
<ThemeProvider colorMode="day">
|
|
98
|
-
<Flex
|
|
99
|
-
flexDirection="column"
|
|
100
|
-
flex="1 0 auto"
|
|
101
|
-
color="fg.default"
|
|
102
|
-
bg="canvas.default"
|
|
103
|
-
>
|
|
67
|
+
<Flex sx={{flexDirection: 'column', flex: '1 0 auto', color: 'fg.default', bg: 'canvas.default'}}>
|
|
104
68
|
<Link
|
|
105
69
|
as={GatsbyLink}
|
|
106
70
|
to="/"
|
|
107
|
-
display
|
|
108
|
-
color="inherit"
|
|
109
|
-
fontFamily="mono"
|
|
110
|
-
mx={4}
|
|
111
|
-
my={4}
|
|
71
|
+
sx={{display: 'inline-block', color: 'inherit', fontFamily: 'mono', mx: 4, my: 4}}
|
|
112
72
|
>
|
|
113
73
|
{siteMetadata.title}
|
|
114
74
|
</Link>
|
|
@@ -126,32 +86,21 @@ function PrimerNavItems({items}) {
|
|
|
126
86
|
return (
|
|
127
87
|
<BorderBox
|
|
128
88
|
key={item.title}
|
|
129
|
-
|
|
130
|
-
borderRadius={0}
|
|
131
|
-
borderTopWidth={index !== 0 ? 1 : 0}
|
|
132
|
-
borderColor="border.muted"
|
|
133
|
-
p={4}
|
|
89
|
+
sx={{borderWidth: 0, borderRadius: 0, borderTopWidth: index !== 0 ? 1 : 0, borderColor: 'border.muted', p: 4}}
|
|
134
90
|
>
|
|
135
91
|
{item.children ? (
|
|
136
92
|
<Details key={index}>
|
|
137
93
|
{({open, toggle}) => (
|
|
138
94
|
<>
|
|
139
95
|
<summary onClick={toggle} style={{cursor: 'pointer'}}>
|
|
140
|
-
<Flex alignItems
|
|
96
|
+
<Flex sx={{alignItems: 'center', justifyContent: 'space-between'}}>
|
|
141
97
|
<Text>{item.title}</Text>
|
|
142
98
|
{open ? <ChevronUpIcon /> : <ChevronDownIcon />}
|
|
143
99
|
</Flex>
|
|
144
100
|
</summary>
|
|
145
|
-
<Flex flexDirection
|
|
101
|
+
<Flex sx={{flexDirection: 'column', mt: 2}}>
|
|
146
102
|
{item.children.map(child => (
|
|
147
|
-
<Link
|
|
148
|
-
key={child.title}
|
|
149
|
-
href={child.url}
|
|
150
|
-
py={1}
|
|
151
|
-
mt={2}
|
|
152
|
-
fontSize={1}
|
|
153
|
-
color="inherit"
|
|
154
|
-
>
|
|
103
|
+
<Link key={child.title} href={child.url} sx={{py: 1, mt: 2, fontSize: 1, color: 'inherit'}}>
|
|
155
104
|
{child.title}
|
|
156
105
|
</Link>
|
|
157
106
|
))}
|
|
@@ -160,7 +109,7 @@ function PrimerNavItems({items}) {
|
|
|
160
109
|
)}
|
|
161
110
|
</Details>
|
|
162
111
|
) : (
|
|
163
|
-
<Link key={index} href={item.url} color
|
|
112
|
+
<Link key={index} href={item.url} sx={{color: 'inherit', display: 'block'}}>
|
|
164
113
|
{item.title}
|
|
165
114
|
</Link>
|
|
166
115
|
)}
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
Details,
|
|
4
|
-
StyledOcticon,
|
|
5
|
-
Text,
|
|
6
|
-
themeGet,
|
|
7
|
-
useDetails
|
|
8
|
-
} from '@primer/components'
|
|
9
|
-
import { TriangleDownIcon } from '@primer/octicons-react'
|
|
1
|
+
import {Box, Details, StyledOcticon, Text, themeGet, useDetails} from '@primer/components'
|
|
2
|
+
import {TriangleDownIcon} from '@primer/octicons-react'
|
|
10
3
|
import React from 'react'
|
|
11
4
|
import styled from 'styled-components'
|
|
12
5
|
|
|
@@ -16,7 +9,7 @@ function NavDropdown({title, children}) {
|
|
|
16
9
|
<Details {...getDetailsProps()}>
|
|
17
10
|
<summary style={{cursor: 'pointer'}}>
|
|
18
11
|
<Text>{title}</Text>
|
|
19
|
-
<StyledOcticon icon={TriangleDownIcon}
|
|
12
|
+
<StyledOcticon icon={TriangleDownIcon} sx={{ml: 1}} />
|
|
20
13
|
</summary>
|
|
21
14
|
<Box position="absolute">
|
|
22
15
|
<Box
|