Skip to content

Commit 07dc479

Browse files
Update @edgeandnode/components from v21 to v22 (#92)
* Remove scroll animation after changing the language or clicking on a link * Update dependencies * Add `Layout` component with sticky header (#88) * imported Layout component * removed container from index file * updated headerSticky prop to true in docs * Fix the build * removed unnecessary div * removed unnecessary div Co-authored-by: Benoît Rouleau <[email protected]> * Update dependencies * SEO / locale fixes * Fix bug where the top half of `NewGDSDivider` is clipped Co-authored-by: Alexandria Roberts <[email protected]>
1 parent 1be083a commit 07dc479

18 files changed

+755
-753
lines changed

components/Container.tsx

Lines changed: 0 additions & 23 deletions
This file was deleted.

components/EditPageLink.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
useUniqueId,
1212
} from '@edgeandnode/components'
1313

14-
import { NavContext } from '@/layout'
14+
import { NavContext } from '@/layout/NavContext'
1515
import { Link } from '@/components'
1616
import { useI18n } from '@/i18n'
1717

components/Heading.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as VisuallyHidden from '@radix-ui/react-visually-hidden'
44
import { useInView } from 'react-intersection-observer'
55
import { useDebounce } from 'react-use'
66

7-
import { DocumentContext } from '@/layout'
7+
import { DocumentContext } from '@/layout/DocumentContext'
88
import { LinkInline } from '@/components'
99
import { useI18n } from '@/i18n'
1010

components/NavTree.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,10 @@ const NavTreeItem = ({
101101
)
102102
}
103103

104-
export const NavTreeGroupContext = createContext(null) as Context<{
105-
active: boolean
106-
open: boolean
107-
} | null>
104+
export const NavTreeGroupContext = createContext({
105+
active: false,
106+
open: false,
107+
})
108108

109109
const NavTreeGroup = ({ active = false, children, ...props }: NavTreeGroupProps) => {
110110
const [open, setOpen] = useState(active)
@@ -121,7 +121,7 @@ const NavTreeGroup = ({ active = false, children, ...props }: NavTreeGroupProps)
121121

122122
const NavTreeGroupHeading = ({ children, buttonProps = {}, ...props }: NavTreeGroupHeadingProps) => {
123123
const { sx: buttonSx, ...buttonOtherProps } = buttonProps
124-
const context = useContext(NavTreeGroupContext)!
124+
const context = useContext(NavTreeGroupContext)
125125
const { t } = useI18n()
126126

127127
return (
@@ -160,7 +160,7 @@ const NavTreeGroupHeading = ({ children, buttonProps = {}, ...props }: NavTreeGr
160160
}
161161

162162
const NavTreeGroupContent = ({ children, ...props }: NavTreeGroupContentProps) => {
163-
const context = useContext(NavTreeGroupContext)!
163+
const context = useContext(NavTreeGroupContext)
164164
return (
165165
<Collapsible.Content
166166
sx={{

components/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
export * from './Blockquote'
22
export * from './Code'
3-
export * from './Container'
43
export * from './Difficulty'
54
export * from './EditPageLink'
65
export * from './Heading'

layout/DocumentContext.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { createContext, Context } from 'react'
2+
3+
export type Frontmatter = {
4+
title?: string
5+
}
6+
7+
export type OutlineItem = {
8+
id: string
9+
title: string
10+
level: 1 | 2 | 3 | 4 | 5 | 6
11+
}
12+
13+
export type DocumentContextProps = {
14+
frontmatter?: Frontmatter
15+
outline: OutlineItem[]
16+
markOutlineItem: (id: string, inOrAboveView: boolean) => void
17+
highlightedOutlineItemId: string | null
18+
}
19+
20+
export const DocumentContext = createContext(null) as Context<DocumentContextProps | null>

layout/Layout.tsx

Lines changed: 0 additions & 50 deletions
This file was deleted.

layout/MDXLayout.tsx

Lines changed: 12 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
1-
import { PropsWithChildren, createContext, Context, useMemo, useCallback } from 'react'
2-
import Head from 'next/head'
1+
import { PropsWithChildren, useMemo, useCallback } from 'react'
2+
import { NextSeo } from 'next-seo'
33
import { MDXProvider } from '@mdx-js/react'
44
import { ThemeUIStyleObject } from 'theme-ui'
55
import { NewGDSDivider, NewGDSDividerProps, Spacing, Flex } from '@edgeandnode/components'
66
import { useSet } from 'react-use'
77

8-
import { NavItem, NavItemPage } from '@/navigation'
9-
import { MDXLayoutNav, MDXLayoutPagination, MDXLayoutOutline } from '@/layout'
8+
import {
9+
NavContext,
10+
NavContextProps,
11+
DocumentContext,
12+
DocumentContextProps,
13+
MDXLayoutNav,
14+
MDXLayoutPagination,
15+
MDXLayoutOutline,
16+
} from '@/layout'
1017
import {
1118
Blockquote,
1219
CodeBlock,
@@ -60,36 +67,6 @@ const mdxStyles = {
6067
},
6168
} as ThemeUIStyleObject
6269

63-
export type NavContextProps = {
64-
pagePath: string
65-
navItems: NavItem[]
66-
pageNavItems: NavItemPage[]
67-
previousPage: NavItemPage | null
68-
currentPage: NavItemPage | null
69-
nextPage: NavItemPage | null
70-
}
71-
72-
export const NavContext = createContext(null) as Context<NavContextProps | null>
73-
74-
export type Frontmatter = {
75-
title?: string
76-
}
77-
78-
export type OutlineItem = {
79-
id: string
80-
title: string
81-
level: 1 | 2 | 3 | 4 | 5 | 6
82-
}
83-
84-
export type DocumentContextProps = {
85-
frontmatter?: Frontmatter
86-
outline: OutlineItem[]
87-
markOutlineItem: (id: string, inOrAboveView: boolean) => void
88-
highlightedOutlineItemId: string | null
89-
}
90-
91-
export const DocumentContext = createContext(null) as Context<DocumentContextProps | null>
92-
9370
export type MDXLayoutProps = PropsWithChildren<
9471
Pick<NavContextProps, 'pagePath' | 'navItems'> & Pick<DocumentContextProps, 'frontmatter' | 'outline'>
9572
>
@@ -154,9 +131,7 @@ export const MDXLayout = ({ pagePath, navItems, frontmatter, outline, children }
154131
return (
155132
<NavContext.Provider value={{ pagePath, navItems, pageNavItems, previousPage, currentPage, nextPage }}>
156133
<DocumentContext.Provider value={{ frontmatter, outline, markOutlineItem, highlightedOutlineItemId }}>
157-
<Head>
158-
<title>{frontmatter?.title ? `${frontmatter.title} - ` : ''}The Graph Docs</title>
159-
</Head>
134+
<NextSeo title={`${frontmatter?.title ? `${frontmatter.title} - ` : ''} The Graph Docs`} />
160135

161136
<div
162137
sx={{

layout/MDXLayoutNav.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ const MobileWrapper = ({ title, children }: PropsWithChildren<{ title?: string }
6969
sx={{ px: Spacing.L_XL, py: '20px' }}
7070
>
7171
<Flex.Column as="span" gap={Spacing.S}>
72-
<Text.S10 color="White64">Docs</Text.S10>
72+
<Text.C10 color="White64">Docs</Text.C10>
7373
<Text size="16px">{title}</Text>
7474
</Flex.Column>
7575
<Flex.Column

layout/MDXLayoutOutline.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ export const MDXLayoutOutline = () => {
3030
</Flex.Row>
3131
<NewGDSDivider sx={{ my: Spacing.XL }} />
3232
<nav sx={{ pr: '16px' }}>
33-
<Text.S10 as="header" color="White64" sx={{ mb: Spacing.M_L }}>
33+
<Text.C10 as="header" color="White64" sx={{ mb: Spacing.M_L }}>
3434
{t('global.pageSections')}
35-
</Text.S10>
35+
</Text.C10>
3636
<Text as="ul" size="14px" color="White48">
3737
{outline.map((outlineItem, outlineItemIndex) => {
3838
if (outlineItem.level > 3) {

0 commit comments

Comments
 (0)