Skip to content

Commit

Permalink
Update @edgeandnode/components from v21 to v22 (#92)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
benface and alexandriaroberts authored Mar 25, 2022
1 parent 1be083a commit 07dc479
Show file tree
Hide file tree
Showing 18 changed files with 755 additions and 753 deletions.
23 changes: 0 additions & 23 deletions components/Container.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion components/EditPageLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
useUniqueId,
} from '@edgeandnode/components'

import { NavContext } from '@/layout'
import { NavContext } from '@/layout/NavContext'
import { Link } from '@/components'
import { useI18n } from '@/i18n'

Expand Down
2 changes: 1 addition & 1 deletion components/Heading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as VisuallyHidden from '@radix-ui/react-visually-hidden'
import { useInView } from 'react-intersection-observer'
import { useDebounce } from 'react-use'

import { DocumentContext } from '@/layout'
import { DocumentContext } from '@/layout/DocumentContext'
import { LinkInline } from '@/components'
import { useI18n } from '@/i18n'

Expand Down
12 changes: 6 additions & 6 deletions components/NavTree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ const NavTreeItem = ({
)
}

export const NavTreeGroupContext = createContext(null) as Context<{
active: boolean
open: boolean
} | null>
export const NavTreeGroupContext = createContext({
active: false,
open: false,
})

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

const NavTreeGroupHeading = ({ children, buttonProps = {}, ...props }: NavTreeGroupHeadingProps) => {
const { sx: buttonSx, ...buttonOtherProps } = buttonProps
const context = useContext(NavTreeGroupContext)!
const context = useContext(NavTreeGroupContext)
const { t } = useI18n()

return (
Expand Down Expand Up @@ -160,7 +160,7 @@ const NavTreeGroupHeading = ({ children, buttonProps = {}, ...props }: NavTreeGr
}

const NavTreeGroupContent = ({ children, ...props }: NavTreeGroupContentProps) => {
const context = useContext(NavTreeGroupContext)!
const context = useContext(NavTreeGroupContext)
return (
<Collapsible.Content
sx={{
Expand Down
1 change: 0 additions & 1 deletion components/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export * from './Blockquote'
export * from './Code'
export * from './Container'
export * from './Difficulty'
export * from './EditPageLink'
export * from './Heading'
Expand Down
20 changes: 20 additions & 0 deletions layout/DocumentContext.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { createContext, Context } from 'react'

export type Frontmatter = {
title?: string
}

export type OutlineItem = {
id: string
title: string
level: 1 | 2 | 3 | 4 | 5 | 6
}

export type DocumentContextProps = {
frontmatter?: Frontmatter
outline: OutlineItem[]
markOutlineItem: (id: string, inOrAboveView: boolean) => void
highlightedOutlineItemId: string | null
}

export const DocumentContext = createContext(null) as Context<DocumentContextProps | null>
50 changes: 0 additions & 50 deletions layout/Layout.tsx

This file was deleted.

49 changes: 12 additions & 37 deletions layout/MDXLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
import { PropsWithChildren, createContext, Context, useMemo, useCallback } from 'react'
import Head from 'next/head'
import { PropsWithChildren, useMemo, useCallback } from 'react'
import { NextSeo } from 'next-seo'
import { MDXProvider } from '@mdx-js/react'
import { ThemeUIStyleObject } from 'theme-ui'
import { NewGDSDivider, NewGDSDividerProps, Spacing, Flex } from '@edgeandnode/components'
import { useSet } from 'react-use'

import { NavItem, NavItemPage } from '@/navigation'
import { MDXLayoutNav, MDXLayoutPagination, MDXLayoutOutline } from '@/layout'
import {
NavContext,
NavContextProps,
DocumentContext,
DocumentContextProps,
MDXLayoutNav,
MDXLayoutPagination,
MDXLayoutOutline,
} from '@/layout'
import {
Blockquote,
CodeBlock,
Expand Down Expand Up @@ -60,36 +67,6 @@ const mdxStyles = {
},
} as ThemeUIStyleObject

export type NavContextProps = {
pagePath: string
navItems: NavItem[]
pageNavItems: NavItemPage[]
previousPage: NavItemPage | null
currentPage: NavItemPage | null
nextPage: NavItemPage | null
}

export const NavContext = createContext(null) as Context<NavContextProps | null>

export type Frontmatter = {
title?: string
}

export type OutlineItem = {
id: string
title: string
level: 1 | 2 | 3 | 4 | 5 | 6
}

export type DocumentContextProps = {
frontmatter?: Frontmatter
outline: OutlineItem[]
markOutlineItem: (id: string, inOrAboveView: boolean) => void
highlightedOutlineItemId: string | null
}

export const DocumentContext = createContext(null) as Context<DocumentContextProps | null>

export type MDXLayoutProps = PropsWithChildren<
Pick<NavContextProps, 'pagePath' | 'navItems'> & Pick<DocumentContextProps, 'frontmatter' | 'outline'>
>
Expand Down Expand Up @@ -154,9 +131,7 @@ export const MDXLayout = ({ pagePath, navItems, frontmatter, outline, children }
return (
<NavContext.Provider value={{ pagePath, navItems, pageNavItems, previousPage, currentPage, nextPage }}>
<DocumentContext.Provider value={{ frontmatter, outline, markOutlineItem, highlightedOutlineItemId }}>
<Head>
<title>{frontmatter?.title ? `${frontmatter.title} - ` : ''}The Graph Docs</title>
</Head>
<NextSeo title={`${frontmatter?.title ? `${frontmatter.title} - ` : ''} The Graph Docs`} />

<div
sx={{
Expand Down
2 changes: 1 addition & 1 deletion layout/MDXLayoutNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const MobileWrapper = ({ title, children }: PropsWithChildren<{ title?: string }
sx={{ px: Spacing.L_XL, py: '20px' }}
>
<Flex.Column as="span" gap={Spacing.S}>
<Text.S10 color="White64">Docs</Text.S10>
<Text.C10 color="White64">Docs</Text.C10>
<Text size="16px">{title}</Text>
</Flex.Column>
<Flex.Column
Expand Down
4 changes: 2 additions & 2 deletions layout/MDXLayoutOutline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ export const MDXLayoutOutline = () => {
</Flex.Row>
<NewGDSDivider sx={{ my: Spacing.XL }} />
<nav sx={{ pr: '16px' }}>
<Text.S10 as="header" color="White64" sx={{ mb: Spacing.M_L }}>
<Text.C10 as="header" color="White64" sx={{ mb: Spacing.M_L }}>
{t('global.pageSections')}
</Text.S10>
</Text.C10>
<Text as="ul" size="14px" color="White48">
{outline.map((outlineItem, outlineItemIndex) => {
if (outlineItem.level > 3) {
Expand Down
8 changes: 4 additions & 4 deletions layout/MDXLayoutPagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ export const MDXLayoutPagination = () => {
const { t } = useI18n()

return (
<div sx={{ overflow: 'hidden' }}>
<div>
<NewGDSDivider diamonds />
<Flex.Row justify="space-between" sx={{ mt: Spacing.XL }}>
<Flex.Row justify="space-between" sx={{ mt: Spacing.XL, overflow: 'hidden' }}>
<div>
{previousPage && (
<Link
Expand All @@ -30,7 +30,7 @@ export const MDXLayoutPagination = () => {
<Flex.Column align="start" gap={Spacing.S} sx={{ textAlign: 'left' }}>
<Flex.Row align="center" gap={Spacing.S}>
<Icon.ArrowLeft title="" size="12px" />
<Text.S10>{t('global.previous')}</Text.S10>
<Text.C10>{t('global.previous')}</Text.C10>
</Flex.Row>
<Text
weight="Semibold"
Expand Down Expand Up @@ -67,7 +67,7 @@ export const MDXLayoutPagination = () => {
>
<Flex.Column align="end" gap={Spacing.S} sx={{ textAlign: 'right' }}>
<Flex.Row align="center" gap={Spacing.S}>
<Text.S10>{t('global.next')}</Text.S10>
<Text.C10>{t('global.next')}</Text.C10>
<Icon.ArrowRight title="" size="12px" />
</Flex.Row>
<Text
Expand Down
14 changes: 14 additions & 0 deletions layout/NavContext.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { createContext, Context } from 'react'

import { NavItem, NavItemPage } from '@/navigation'

export type NavContextProps = {
pagePath: string
navItems: NavItem[]
pageNavItems: NavItemPage[]
previousPage: NavItemPage | null
currentPage: NavItemPage | null
nextPage: NavItemPage | null
}

export const NavContext = createContext(null) as Context<NavContextProps | null>
3 changes: 2 additions & 1 deletion layout/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from './Layout'
export * from './DocumentContext'
export * from './NavContext'
export * from './MDXLayout'
export * from './MDXLayoutNav'
export * from './MDXLayoutPagination'
Expand Down
2 changes: 0 additions & 2 deletions nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ http {
rewrite ^/docs/hostedservice/(.*)$ $scheme://$http_host/docs/en/hosted-service/$1 permanent;
rewrite ^/docs/(?!(?:[a-zA-Z][a-zA-Z]|_next|img)(?:/|$))(.*)$ $scheme://$http_host/docs/en/$1 permanent; # Redirect to `/en` if no language in URL and not an asset URL

# TODO: Add support for new localized URLs

location / {
try_files $uri $uri.html $uri/index.html =404;

Expand Down
35 changes: 12 additions & 23 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,26 @@
{
"name": "graph-docs",
"name": "@graphprotocol/docs",
"version": "1.0.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "rm -rf .next && next build",
"start": "next start",
"export": "rm -rf out && next export -o out/docs",
"lint": "yarn lint:eslint && yarn lint:types",
"lint:fix": "yarn lint:eslint --fix && yarn lint:types",
"lint:eslint": "next lint",
"lint:types": "tsc --noEmit",
"prettier": "prettier --write .",
"export": "rm -rf out && next export -o out/docs",
"prettier:check": "prettier --check .",
"prepare": "husky install",
"docker:build": "DOCKER_BUILDKIT=1 docker build . -t docs",
"docker:up": "docker run --rm -it -p 3000:80 -v \"$(pwd)/nginx.conf:/etc/nginx/nginx.conf\" docs"
},
"husky": {
"hooks": {
"pre-push": "yarn build"
}
},
"dependencies": {
"@edgeandnode/components": "^21.0.3",
"@emotion/react": "^11.8.1",
"@emotion/styled": "^11.8.1",
"@mdx-js/loader": "^2.0.0",
"@mdx-js/mdx": "^2.0.0",
"@mdx-js/react": "^2.0.0",
"@edgeandnode/components": "^22.0.0",
"@emotion/react": "^11.8.2",
"@mdx-js/loader": "^2.1.0",
"@mdx-js/react": "^2.1.0",
"@next/mdx": "^12.1.0",
"@radix-ui/react-collapsible": "0.1.6",
"@radix-ui/react-popover": "^0.1.6",
Expand All @@ -47,27 +40,23 @@
"@svgr/webpack": "^6.2.1",
"@types/color": "^3.0.3",
"@types/lodash-es": "^4.17.6",
"@types/node": "^16.11.24",
"@types/react": "^17.0.39",
"@types/node": "^16.11.26",
"@types/react": "^17.0.41",
"acorn": "^8.7.0",
"acorn-jsx": "^5.3.2",
"eslint": "^8.10.0",
"eslint": "^8.11.0",
"eslint-config-next": "^12.1.0",
"husky": "^7.0.4",
"lodash-es": "^4.17.21",
"path": "^0.12.7",
"prettier": "^2.5.1",
"prettier": "^2.6.0",
"remark-frontmatter": "^4.0.1",
"remark-mdx-frontmatter": "^1.1.1",
"serialize-as-code": "^2.0.1",
"typescript": "4.5.5",
"typescript": "4.6.2",
"unist-util-visit": "^4.1.0",
"url": "^0.11.0"
},
"resolutions": {
"@mdx-js/loader": "^2.0.0",
"@mdx-js/mdx": "^2.0.0"
},
"engines": {
"node": ">=16"
}
Expand Down
Loading

0 comments on commit 07dc479

Please sign in to comment.