@primer/gatsby-theme-doctocat 3.2.1 → 4.0.1

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 CHANGED
@@ -1,5 +1,45 @@
1
1
  # @primer/gatsby-theme-doctocat
2
2
 
3
+ ## 4.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`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
8
+ - Added support for Figma links in frontmatter
9
+
10
+ * [`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
11
+
12
+ ## 4.0.0
13
+
14
+ ### Major Changes
15
+
16
+ - [`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
17
+
18
+ * [`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.
19
+
20
+ ```diff
21
+ # nav.yml
22
+ – title: Components
23
+ - url: /components
24
+ children:
25
+ — title: Avatar
26
+ url: /Avatar
27
+ ```
28
+
29
+ ### Patch Changes
30
+
31
+ - [`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
32
+
33
+ ## 3.3.0
34
+
35
+ ### Minor Changes
36
+
37
+ - [`82bd051`](https://github.com/primer/doctocat/commit/82bd051ab35e5939a9ad5a3e89c26e2a63ce5df2) [#376](https://github.com/primer/doctocat/pull/376) Thanks [@vdepizzol](https://github.com/vdepizzol)! - New visual styles for Do/Dont components
38
+
39
+ ### Patch Changes
40
+
41
+ - [`0d35f17`](https://github.com/primer/doctocat/commit/0d35f17a34ebfc468e15a23783a55379b8f0e125) [#402](https://github.com/primer/doctocat/pull/402) Thanks [@ichelsea](https://github.com/ichelsea)! - Added underlines to links in markdown documents
42
+
3
43
  ## 3.2.1
4
44
 
5
45
  ### Patch Changes
@@ -183,4 +223,4 @@
183
223
 
184
224
  - [`5fb29c9`](https://github.com/primer/doctocat/commit/5fb29c9000dd2a26919f661d969142fa1938d329) [#187](https://github.com/primer/doctocat/pull/187) Thanks [@mvasilkov](https://github.com/mvasilkov)! - Fix typo in an internal import
185
225
 
186
- * [`cab38c3`](https://github.com/primer/doctocat/commit/cab38c38eb00a9645991147b28a47a535dcd1d41) [#190](https://github.com/primer/doctocat/pull/190) Thanks [@colebemis](https://github.com/colebemis)! - Update the navigation dropdown icon from a `chrevon` to a `caret` to follow our [progressive disclosure guidelines](https://primer.style/design/ui-patterns/progressive-disclosure#progressive-disclosure-ui-patterns)
226
+ * [`cab38c3`](https://github.com/primer/doctocat/commit/cab38c38eb00a9645991147b28a47a535dcd1d41) [#190](https://github.com/primer/doctocat/pull/190) Thanks [@colebemis](https://github.com/colebemis)! - Update the navigation dropdown icon from a `chevron` to a `caret` to follow our [progressive disclosure guidelines](https://primer.style/design/ui-patterns/progressive-disclosure#progressive-disclosure-ui-patterns)
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 && !process.env.NOW_GITHUB_DEPLOYMENT && !process.env.VERCEL_GITHUB_DEPLOYMENT) {
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 || process.env.NOW_GITHUB_DEPLOYMENT || process.env.VERCEL_GITHUB_DEPLOYMENT) {
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.2.1",
3
+ "version": "4.0.1",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "scripts": {
@@ -15,9 +15,9 @@
15
15
  "eslint-config-prettier": "^8.3.0",
16
16
  "eslint-plugin-jsx-a11y": "^6.4.1",
17
17
  "eslint-plugin-prettier": "^4.0.0",
18
- "eslint-plugin-primer-react": "0.7.3",
18
+ "eslint-plugin-primer-react": "0.7.4",
19
19
  "eslint-plugin-react": "^7.26.1",
20
- "gatsby": "^2.24.52",
20
+ "gatsby": "^2.32.13",
21
21
  "prettier": "^2.4.1",
22
22
  "react": "^16.13.1",
23
23
  "react-dom": "^16.13.1"
@@ -33,18 +33,18 @@
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
- "@primer/octicons-react": "^16.0.0",
36
+ "@primer/octicons-react": "^16.3.1",
37
+ "@primer/react": "^35.2.2",
38
38
  "@styled-system/theme-get": "^5.0.12",
39
- "@testing-library/jest-dom": "^4.1.0",
39
+ "@testing-library/jest-dom": "^5.16.2",
40
40
  "@testing-library/react": "^9.1.3",
41
41
  "axios": "^0.21.2",
42
42
  "babel-jest": "^24.9.0",
43
43
  "copy-to-clipboard": "^3.2.0",
44
- "date-fns": "^2.0.1",
44
+ "date-fns": "^2.28.0",
45
45
  "details-element-polyfill": "^2.4.0",
46
46
  "downshift": "^3.2.10",
47
- "find-up": "^4.1.0",
47
+ "find-up": "^6.3.0",
48
48
  "framer-motion": "^1.4.2",
49
49
  "fuse.js": "^3.4.5",
50
50
  "gatsby-plugin-catch-links": "^2.1.2",
@@ -66,12 +66,12 @@
66
66
  "pluralize": "^8.0.0",
67
67
  "preval.macro": "^3.0.0",
68
68
  "prism-react-renderer": "^1.2.0",
69
- "prismjs": "^1.25.0",
69
+ "prismjs": "^1.27.0",
70
70
  "react-addons-text-content": "^0.0.4",
71
71
  "react-element-to-jsx-string": "^14.0.3",
72
72
  "react-focus-on": "^3.3.0",
73
- "react-frame-component": "^4.1.1",
74
- "react-helmet": "^5.2.1",
73
+ "react-frame-component": "^5.2.1",
74
+ "react-helmet": "^6.1.0",
75
75
  "react-live": "^2.1.2",
76
76
  "react-measure": "^2.3.0",
77
77
  "read-pkg-up": "^6.0.0",
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
+ })
@@ -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 <LiveCode code={code} language={language} noinline={noinline} metastring={metastring} />
14
+ return (
15
+ <LiveCode code={code} highlight={highlight} language={language} noinline={noinline} metastring={metastring} />
16
+ )
15
17
  }
16
18
 
17
19
  return (
@@ -1,5 +1,4 @@
1
- import {Box, StyledOcticon, Text} from '@primer/react'
2
- import {CheckCircleFillIcon, XCircleFillIcon} from '@primer/octicons-react'
1
+ import {Box, Text} from '@primer/react'
3
2
  import React from 'react'
4
3
 
5
4
  export function DoDontContainer({stacked, children}) {
@@ -15,22 +14,48 @@ DoDontContainer.defaultProps = {
15
14
  }
16
15
 
17
16
  export function Do(props) {
18
- return <DoDontBase {...props} title="Do" icon={CheckCircleFillIcon} iconBg="success.fg" />
17
+ return <DoDontBase {...props} title="Do" bg="success.fg" borderColor="success.muted" />
19
18
  }
20
19
 
21
20
  export function Dont(props) {
22
- return <DoDontBase {...props} title="Don't" icon={XCircleFillIcon} iconBg="danger.fg" />
21
+ return <DoDontBase {...props} title="Dont" bg="danger.fg" borderColor="danger.muted" />
23
22
  }
24
23
 
25
- function DoDontBase({children, title, icon: Icon, iconBg}) {
24
+ function DoDontBase({children, title, bg, borderColor, indented}) {
26
25
  return (
27
26
  <Box sx={{display: 'flex', flexDirection: 'column'}}>
28
- <Box sx={{display: 'flex', alignSelf: 'start', flexDirection: 'row', alignItems: 'center', mb: '2'}}>
29
- <StyledOcticon icon={Icon} sx={{color: iconBg}} />
30
- <Text sx={{fontWeight: 'bold', color: 'fg.default', ml: 2}}>{title}</Text>
27
+ <Box
28
+ sx={{
29
+ display: 'flex',
30
+ alignSelf: 'start',
31
+ flexDirection: 'row',
32
+ alignItems: 'center',
33
+ mb: '2',
34
+ backgroundColor: bg,
35
+ borderRadius: '2',
36
+ color: 'fg.onEmphasis',
37
+ paddingX: '2'
38
+ }}
39
+ >
40
+ <Text sx={{fontWeight: 'bold', fontSize: '1', color: 'fg.onEmphasis'}}>{title}</Text>
31
41
  </Box>
32
42
  <Box sx={{'& *:last-child': {mb: 0}, img: {maxWidth: '100%'}, display: 'flex', flexDirection: 'column'}}>
33
- {children}
43
+ {indented ? (
44
+ <Box
45
+ as="blockquote"
46
+ sx={{
47
+ margin: '0',
48
+ borderLeftWidth: '4px',
49
+ borderLeftStyle: 'solid',
50
+ borderLeftColor: borderColor,
51
+ paddingLeft: '3'
52
+ }}
53
+ >
54
+ {children}
55
+ </Box>
56
+ ) : (
57
+ children
58
+ )}
34
59
  </Box>
35
60
  </Box>
36
61
  )
@@ -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
@@ -8,10 +8,12 @@ import Sidebar from './sidebar'
8
8
  import SourceLink from './source-link'
9
9
  import StatusLabel from './status-label'
10
10
  import StorybookLink from './storybook-link'
11
+ import FigmaLink from './figma-link'
11
12
  import TableOfContents from './table-of-contents'
12
13
 
13
14
  function Layout({children, pageContext}) {
14
- let {title, description, status, source, storybook, additionalContributors, componentId} = pageContext.frontmatter
15
+ let {title, description, figma, status, source, storybook, additionalContributors, componentId} =
16
+ pageContext.frontmatter
15
17
 
16
18
  if (!additionalContributors) {
17
19
  additionalContributors = []
@@ -56,8 +58,10 @@ function Layout({children, pageContext}) {
56
58
  }}
57
59
  css={{gridArea: 'table-of-contents', overflow: 'auto'}}
58
60
  >
59
- <Text sx={{display: 'inline-block', fontWeight: 'bold', mb: 1}}>On this page</Text>
60
- <TableOfContents items={pageContext.tableOfContents.items} />
61
+ <Text sx={{display: 'inline-block', fontWeight: 'bold', pl: 3}} id="toc-heading">
62
+ On this page
63
+ </Text>
64
+ <TableOfContents aria-labelledby="toc-heading" items={pageContext.tableOfContents.items} />
61
65
  </Box>
62
66
  ) : null}
63
67
  <Box sx={{width: '100%', maxWidth: '960px'}}>
@@ -82,6 +86,7 @@ function Layout({children, pageContext}) {
82
86
  >
83
87
  {source ? <SourceLink href={source} /> : null}
84
88
  {storybook ? <StorybookLink href={storybook} /> : null}
89
+ {figma ? <FigmaLink href={figma} /> : null}
85
90
  </Box>
86
91
  ) : null}
87
92
  </Box>
@@ -97,14 +102,14 @@ function Layout({children, pageContext}) {
97
102
  borderRadius: 2
98
103
  }}
99
104
  >
100
- <Box sx={{p: 3}}>
105
+ <Box sx={{px: 3, py: 2}}>
101
106
  <Box
102
107
  sx={{flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', display: 'flex'}}
103
108
  >
104
109
  <Text sx={{fontWeight: 'bold'}}>On this page</Text>
105
110
  </Box>
106
111
  </Box>
107
- <Box sx={{p: 3, borderTop: '1px solid', borderColor: 'border.muted'}}>
112
+ <Box sx={{borderTop: '1px solid', borderColor: 'border.muted'}}>
108
113
  <TableOfContents items={pageContext.tableOfContents.items} />
109
114
  </Box>
110
115
  </Box>
@@ -0,0 +1,10 @@
1
+ import styled from 'styled-components'
2
+ import themeGet from '@styled-system/theme-get'
3
+
4
+ const Link = styled.a`
5
+ text-decoration: underline;
6
+ text-underline-offset: 25%;
7
+ color: ${themeGet('colors.accent.fg')};
8
+ `
9
+
10
+ export default Link
@@ -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 LiveCode({code, language, noinline, metastring}) {
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 handleChange = updatedLiveCode => setLiveCode(updatedLiveCode)
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
- <LiveEditor
70
- onChange={handleChange}
71
- theme={githubTheme}
72
- ignoreTabKey={true}
73
- padding={theme.space[3]}
74
- style={{
75
- fontFamily: theme.fonts.mono,
76
- fontSize: '85%',
77
- borderBottomLeftRadius: theme.radii[2],
78
- borderBottomRightRadius: theme.radii[2],
79
- border: '1px solid',
80
- borderTop: 0,
81
- borderColor: theme.colors.border.default
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>
@@ -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, my: 4}}
89
+ sx={{display: 'inline-block', color: 'inherit', fontFamily: 'mono', mx: 4, mt: 4}}
90
90
  >
91
91
  {siteMetadata.title}
92
92
  </Link>
93
- <NavItems items={navItems} />
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 {Link as GatsbyLink} from 'gatsby'
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
- const NavLink = styled(Link)`
21
- &.active {
22
- font-weight: ${themeGet('fontWeights.bold')};
23
- color: ${themeGet('colors.fg.default')};
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
- <Box
32
- key={item.title}
33
- sx={{
34
- borderWidth: 0,
35
- borderRadius: 0,
36
- borderTopWidth: 1,
37
- borderStyle: 'solid',
38
- borderColor: 'border.muted',
39
- p: 4
40
- }}
41
- >
42
- <Box sx={{display: 'flex', flexDirection: 'column'}}>
43
- <NavLink
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
- <Box
77
- sx={{
78
- borderWidth: 0,
79
- borderTopWidth: 1,
80
- borderRadius: 0,
81
- borderStyle: 'solid',
82
- borderColor: 'border.default',
83
- p: 4
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.default'
52
+ borderColor: 'border.subtle',
53
+ px: 2
54
54
  }}
55
55
  >
56
56
  <Box sx={{flexDirection: 'column', display: 'flex'}}>
@@ -4,7 +4,7 @@ import React from 'react'
4
4
 
5
5
  function SourceLink({href}) {
6
6
  return (
7
- <Link href={href}>
7
+ <Link href={href} target="_blank">
8
8
  <MarkGithubIcon />
9
9
  <Text sx={{ml: 2, display: 'inline-block'}}>View source</Text>
10
10
  </Link>
@@ -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 storybook</Text>
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({items, depth}) {
4
+ function TableOfContents({'aria-labelledby': ariaLabelledBy, items}) {
5
5
  return (
6
- <Box as="ul" sx={{m: 0, p: 0, listStyle: 'none'}}>
6
+ <NavList aria-labelledby={ariaLabelledBy}>
7
7
  {items.map(item => (
8
- <Box as="li" key={item.url} sx={{pl: depth > 0 ? 3 : 0}}>
9
- {item.title ? (
10
- <Link
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
- </Box>
12
+ </NavList>
26
13
  )
27
14
  }
28
15
 
29
- TableOfContents.defaultProps = {
30
- depth: 0
31
- }
32
-
33
16
  export default TableOfContents
@@ -28,6 +28,7 @@ const Table = styled.table`
28
28
 
29
29
  img {
30
30
  background-color: transparent;
31
+ vertical-align: middle;
31
32
  }
32
33
  `
33
34
 
@@ -1,5 +1,6 @@
1
1
  import {MDXProvider} from '@mdx-js/react'
2
- import {Link, ThemeProvider} from '@primer/react'
2
+ import {ThemeProvider} from '@primer/react'
3
+ import Link from './link'
3
4
  import React from 'react'
4
5
  import mdxComponents from '../mdx-components'
5
6
  import Blockquote from './blockquote'
@@ -20,6 +20,8 @@
20
20
  url: https://primer.style/css
21
21
  - title: React
22
22
  url: https://primer.style/react
23
+ - title: React Brand
24
+ url: https://primer.style/brand
23
25
  - title: ViewComponents
24
26
  url: https://primer.style/view-components
25
27
  - title: Contribute
@@ -3,7 +3,7 @@ import debounce from 'lodash.debounce'
3
3
  ;(function searchWorker() {
4
4
  let fuse = null
5
5
 
6
- // [MKT]: I landed on the debouce wait value of 50 based mostly on
6
+ // [MKT]: I landed on the debounce wait value of 50 based mostly on
7
7
  // experimentation. With both `leading` and `trailing` set to `true`, this
8
8
  // feels pretty snappy.
9
9
  //