From da63dba533e80f7d666afa7ed8b7ade309980b63 Mon Sep 17 00:00:00 2001 From: Cole Bemis <colebemis@github.com> Date: Tue, 14 Mar 2023 22:06:26 -0600 Subject: [PATCH] Upgrade doctocat version --- package.json | 2 +- .../components/nav-items.js | 80 ++++++++++--------- src/layouts/component-layout.tsx | 12 ++- src/layouts/react-component-layout.tsx | 8 +- yarn.lock | 8 +- 5 files changed, 60 insertions(+), 50 deletions(-) diff --git a/package.json b/package.json index c8aa146..c385e11 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "dependencies": { "@github/prettier-config": "^0.0.6", "@primer/component-metadata": "^0.5.1", - "@primer/gatsby-theme-doctocat": "^4.4.0", + "@primer/gatsby-theme-doctocat": "^4.4.1", "@primer/octicons-react": "^17.3.0", "@primer/react": "35.5.0", "@svgr/webpack": "^6.5.1", diff --git a/src/@primer/gatsby-theme-doctocat/components/nav-items.js b/src/@primer/gatsby-theme-doctocat/components/nav-items.js index 31d002e..9a7ead6 100644 --- a/src/@primer/gatsby-theme-doctocat/components/nav-items.js +++ b/src/@primer/gatsby-theme-doctocat/components/nav-items.js @@ -1,3 +1,4 @@ +import VisuallyHidden from '@primer/gatsby-theme-doctocat/src/components/visually-hidden' import {LinkExternalIcon} from '@primer/octicons-react' import {NavList} from '@primer/react/drafts' import {useLocation} from '@reach/router' @@ -42,43 +43,48 @@ function NavItem({href, children}) { function NavItems({items}) { return ( - <NavList> - {items.map(item => ( - <React.Fragment key={item.title}> - {item.children ? ( - <NavList.Group title={item.title}> - {item.children.map(child => ( - <NavItem key={child.title} href={child.url}> - {child.title} - {child.children ? ( - <NavList.SubNav> - {child.children.map(subChild => ( - <NavItem key={subChild.title} href={subChild.url}> - {subChild.title} - </NavItem> - ))} - </NavList.SubNav> - ) : null} - </NavItem> - ))} - </NavList.Group> - ) : ( - <NavItem href={item.url}>{item.title}</NavItem> - )} - </React.Fragment> - ))} - {repositoryUrl ? ( - <> - <NavList.Divider /> - <NavList.Item href={repositoryUrl}> - GitHub - <NavList.TrailingVisual> - <LinkExternalIcon /> - </NavList.TrailingVisual> - </NavList.Item> - </> - ) : null} - </NavList> + <> + <VisuallyHidden> + <h3 id="nav-heading">Site navigation</h3> + </VisuallyHidden> + <NavList aria-labelledby="nav-heading"> + {items.map(item => ( + <React.Fragment key={item.title}> + {item.children ? ( + <NavList.Group title={item.title}> + {item.children.map(child => ( + <NavItem key={child.title} href={child.url}> + {child.title} + {child.children ? ( + <NavList.SubNav> + {child.children.map(subChild => ( + <NavItem key={subChild.title} href={subChild.url}> + {subChild.title} + </NavItem> + ))} + </NavList.SubNav> + ) : null} + </NavItem> + ))} + </NavList.Group> + ) : ( + <NavItem href={item.url}>{item.title}</NavItem> + )} + </React.Fragment> + ))} + {repositoryUrl ? ( + <> + <NavList.Divider /> + <NavList.Item href={repositoryUrl}> + GitHub + <NavList.TrailingVisual> + <LinkExternalIcon /> + </NavList.TrailingVisual> + </NavList.Item> + </> + ) : null} + </NavList> + </> ) } diff --git a/src/layouts/component-layout.tsx b/src/layouts/component-layout.tsx index e4e0743..ce2f4dd 100644 --- a/src/layouts/component-layout.tsx +++ b/src/layouts/component-layout.tsx @@ -42,9 +42,13 @@ export default function ComponentLayout({pageContext, children, path}) { > {pageContext.tableOfContents.items ? ( <> - <Text sx={{display: 'inline-block', fontWeight: 'bold', pl: 3}} id="toc-heading"> + <Heading + as="h3" + sx={{fontSize: 2, display: 'inline-block', fontWeight: 'bold', pl: 3}} + id="toc-heading" + > On this page - </Text> + </Heading> <TableOfContents aria-labelledby="toc-heading" items={pageContext.tableOfContents.items} /> </> ) : null} @@ -67,9 +71,9 @@ export default function ComponentLayout({pageContext, children, path}) { <Box sx={{flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', display: 'flex'}} > - <Text sx={{fontWeight: 'bold'}} id="toc-heading-narrow"> + <Heading as="h3" sx={{fontSize: 2, fontWeight: 'bold'}} id="toc-heading-narrow"> On this page - </Text> + </Heading> </Box> </Box> <Box sx={{borderTop: '1px solid', borderColor: 'border.muted'}}> diff --git a/src/layouts/react-component-layout.tsx b/src/layouts/react-component-layout.tsx index f42a04c..c31625a 100644 --- a/src/layouts/react-component-layout.tsx +++ b/src/layouts/react-component-layout.tsx @@ -108,9 +108,9 @@ export default function ReactComponentLayout({data}) { display: ['none', null, 'block'], }} > - <Text sx={{display: 'inline-block', fontWeight: 'bold', pl: 3}} id="toc-heading"> + <Heading as="h3" sx={{fontSize: 2, display: 'inline-block', fontWeight: 'bold', pl: 3}} id="toc-heading"> On this page - </Text> + </Heading> <TableOfContents aria-labelledby="toc-heading" items={tableOfContents.items} /> </Box> <Box sx={{minWidth: 0}}> @@ -194,9 +194,9 @@ export default function ReactComponentLayout({data}) { <Box sx={{flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', display: 'flex'}} > - <Text sx={{fontWeight: 'bold'}} id="toc-heading-narrow"> + <Heading as="h3" sx={{fontSize: 2, fontWeight: 'bold'}} id="toc-heading-narrow"> On this page - </Text> + </Heading> </Box> </Box> <Box sx={{borderTop: '1px solid', borderColor: 'border.muted'}}> diff --git a/yarn.lock b/yarn.lock index d7b7d7b..229c121 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1875,10 +1875,10 @@ resolved "https://registry.yarnpkg.com/@primer/component-metadata/-/component-metadata-0.5.1.tgz#2f41dcc0ff9fcc9ad16c9241a20abdf86ba8468b" integrity sha512-+3tuJScHWRifOAyMV+cn1I533j+PcprvPXbKnH1W7N+vhaGyaaHTao8Dkyyhxbhklmumcf8XR+Lz6dK1ojDrCg== -"@primer/gatsby-theme-doctocat@^4.4.0": - version "4.4.0" - resolved "https://registry.yarnpkg.com/@primer/gatsby-theme-doctocat/-/gatsby-theme-doctocat-4.4.0.tgz#d46835087b7db4f49768b82395b6ecfc5f7bdbab" - integrity sha512-Tc+XSXGFLA+S0IsXaZYEsXorZN9jygV7gwEIC2pwma7151ylSQTV+XDm0c2hvsSnTW1sBU/uk0pqsFm6gep4DA== +"@primer/gatsby-theme-doctocat@^4.4.1": + version "4.4.1" + resolved "https://registry.yarnpkg.com/@primer/gatsby-theme-doctocat/-/gatsby-theme-doctocat-4.4.1.tgz#46296d28cac81680ca2c93176e723317dc0ada8a" + integrity sha512-wiPGsSLDv6J+svY8N7o7QHSsIT2YsV5YpaLAT8XtOa9yNPfqzfjR/OHM3M+siH2E2vI9Sv4I322nUpxYIcPBIw== dependencies: "@babel/preset-env" "^7.5.5" "@babel/preset-react" "^7.0.0" -- GitLab