Skip to content

Commit 0cf2357

Browse files
authored
Add new global header + misc. improvements and fixes (#546)
* Use new `GlobalHeader` component * Uncomment `NPSForm` * Add `ENVIRONMENT` env var * Allow `ENVIRONMENT` on the frontend * Update dependencies * Update dependencies * Revert bad change * Update dependencies * Update dependencies * Update dependencies, including Next to v14 * Re-comment out the NPS form * Update dependencies * `next export` => `output: 'export'` * Try to fix the build * Fix `pnpm dev` * Update dependencies
1 parent 0dd9031 commit 0cf2357

File tree

19 files changed

+2360
-2156
lines changed

19 files changed

+2360
-2156
lines changed

.github/workflows/ci-cd-production.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,13 @@ jobs:
3030
password: ${{ secrets.GITHUB_TOKEN }}
3131

3232
- name: Build and push Docker image
33-
uses: docker/build-push-action@v2
33+
uses: docker/build-push-action@v4
3434
with:
3535
context: . # required to respect .dockerignore
3636
cache-from: type=registry,ref=${{ env.BASE_IMAGE }}:latest
3737
cache-to: type=inline
38+
build-args: |
39+
ENVIRONMENT=production
3840
tags: |
3941
${{ env.BASE_IMAGE }}:${{ github.sha }}
4042
${{ env.BASE_IMAGE }}:latest

.github/workflows/ci-cd-pull-request.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,6 @@ jobs:
3535
with:
3636
context: . # required to respect .dockerignore
3737
cache-from: type=registry,ref=${{ env.BASE_IMAGE }}:latest
38+
build-args: |
39+
ENVIRONMENT=staging
3840
push: false

.github/workflows/ci-cd-staging.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ jobs:
3636
context: . # required to respect .dockerignore
3737
cache-from: type=registry,ref=${{ env.BASE_IMAGE }}:latest
3838
cache-to: type=inline
39+
build-args: |
40+
ENVIRONMENT=staging
3941
tags: |
4042
${{ env.BASE_IMAGE }}:${{ github.sha }}
4143
${{ env.BASE_IMAGE }}:latest

Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
FROM node:18-alpine as builder
22

3+
ARG ENVIRONMENT
4+
ENV ENVIRONMENT=$ENVIRONMENT
5+
36
ENV PNPM_HOME="/usr/bin"
47

58
RUN apk add --no-cache git
@@ -13,7 +16,6 @@ COPY . .
1316
RUN pnpm install --frozen-lockfile --ignore-scripts
1417

1518
RUN pnpm build
16-
RUN pnpm export
1719

1820
## production environment
1921
FROM nginx:1.16.0-alpine

package.json

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,36 +7,34 @@
77
"check": "pnpm typecheck && pnpm lint && pnpm prettier:check",
88
"check:fix": "pnpm typecheck; pnpm lint:fix",
99
"dev": "turbo run dev --parallel",
10-
"docker:build": "DOCKER_BUILDKIT=1 docker build . -t docs --no-cache",
10+
"docker:build": "source .env.local && DOCKER_BUILDKIT=1 docker build . -t docs --no-cache --build-arg ENVIRONMENT=$ENVIRONMENT",
1111
"docker:clean": "docker builder prune",
1212
"docker:up": "docker run --rm -it -p 3000:80 -v \"$(pwd)/nginx.conf:/etc/nginx/nginx.conf\" docs",
13-
"export": "pnpm --filter @graphprotocol/docs export",
1413
"lint": "eslint . --cache --ignore-path .gitignore --max-warnings 0",
1514
"lint:fix": "eslint . --cache --ignore-path .gitignore --fix; pnpm prettier",
1615
"pre-commit": "lint-staged --concurrent false",
1716
"pre-push": "pnpm build",
1817
"prepare": "husky install && chmod +x .husky/*",
1918
"prettier": "pnpm prettier:check --write",
2019
"prettier:check": "prettier --cache --check .",
21-
"start": "pnpm --filter @graphprotocol/docs start",
2220
"test": "turbo run test",
2321
"typecheck": "turbo run typecheck"
2422
},
2523
"devDependencies": {
26-
"@edgeandnode/eslint-config": "^2.0.2",
27-
"eslint": "^8.52.0",
24+
"@edgeandnode/eslint-config": "^2.0.3",
25+
"eslint": "^8.55.0",
2826
"eslint-plugin-mdx": "^2.2.0",
2927
"husky": "^8.0.3",
30-
"lint-staged": "^15.0.2",
31-
"prettier": "^3.0.3",
28+
"lint-staged": "^15.2.0",
29+
"prettier": "^3.1.1",
3230
"prettier-plugin-pkg": "^0.18.0",
3331
"remark-frontmatter": "^5.0.0",
3432
"remark-lint-first-heading-level": "^3.1.2",
3533
"remark-lint-heading-increment": "^3.1.2",
3634
"remark-lint-no-heading-punctuation": "^3.1.2",
3735
"remark-lint-restrict-elements": "workspace:*",
38-
"turbo": "^1.10.16",
39-
"typescript": "^5.2.2"
36+
"turbo": "^1.11.2",
37+
"typescript": "^5.3.3"
4038
},
4139
"lint-staged": {
4240
"**/*.{js,jsx,ts,tsx,mjs,cjs}": "eslint --fix",

packages/nextra-theme/package.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
"typecheck": "tsc --noEmit"
2626
},
2727
"peerDependencies": {
28-
"@edgeandnode/gds": "^2.9.3",
29-
"@edgeandnode/go": "^3.0.3",
28+
"@edgeandnode/gds": "3.0.0-global-header-1701913779061-6ea902d",
29+
"@edgeandnode/go": "4.0.0-global-header-1701913779061-6ea902d",
3030
"@emotion/react": "^11.11",
3131
"next": "^13",
3232
"next-seo": "^6",
@@ -39,23 +39,23 @@
3939
"@radix-ui/react-collapsible": "^1.0.3",
4040
"@radix-ui/react-visually-hidden": "^1.0.3",
4141
"lodash": "^4.17.21",
42-
"react-intersection-observer": "^9.5.2",
43-
"react-use": "^17.4.0"
42+
"react-intersection-observer": "^9.5.3",
43+
"react-use": "^17.4.2"
4444
},
4545
"devDependencies": {
46-
"@edgeandnode/gds": "^2.12.9",
47-
"@edgeandnode/go": "^3.4.2",
46+
"@edgeandnode/gds": "3.0.0-global-header-1701913779061-6ea902d",
47+
"@edgeandnode/go": "4.0.0-global-header-1701913779061-6ea902d",
4848
"@emotion/react": "^11.11.1",
49-
"@types/lodash": "^4.14.200",
50-
"@types/react": "^18.2.34",
51-
"@types/react-dom": "^18.2.14",
52-
"next": "13.5.6",
49+
"@types/lodash": "^4.14.202",
50+
"@types/react": "^18.2.44",
51+
"@types/react-dom": "^18.2.17",
52+
"next": "^14.0.4",
5353
"next-seo": "^6.4.0",
5454
"nextra": "^2.13.2",
5555
"react": "^18.2.0",
5656
"react-dom": "^18.2.0",
5757
"theme-ui": "^0.16.1",
58-
"tsup": "^7.2.0"
58+
"tsup": "^7.3.0"
5959
},
6060
"sideEffects": false
6161
}

packages/nextra-theme/src/components/Image.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export type ImageProps = Omit<ImgHTMLAttributes<HTMLImageElement>, 'children'>
55
export const Image = ({ src, ...props }: ImageProps) => {
66
// If the URL is internal, automatically prepend the base path
77
if (src?.startsWith('/')) {
8-
src = `${process.env.BASE_PATH}${src}`
8+
src = `${process.env.BASE_PATH ?? ''}${src}`
99
}
1010

1111
return <img src={src} alt="" {...props} />

packages/nextra-theme/src/index.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ export default function NextraLayout({ children, pageOpts, pageProps }: NextraTh
159159
<div
160160
sx={{
161161
display: ['none', null, null, 'block'],
162-
mt: 'calc(-1 * var(--gds-header-height) * var(--gds-header-fixed))',
163162
marginInlineStart: '-8px',
164163
marginInlineEnd: '16px',
165164
}}
@@ -219,7 +218,6 @@ export default function NextraLayout({ children, pageOpts, pageProps }: NextraTh
219218
<div
220219
sx={{
221220
display: ['none', null, null, 'block'],
222-
mt: 'calc(-1 * var(--gds-header-height) * var(--gds-header-fixed))',
223221
marginInlineStart: '32px',
224222
marginInlineEnd: '-8px',
225223
}}

packages/nextra-theme/src/layout/MDXLayoutNav.tsx

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,23 +45,15 @@ const DesktopWrapper = ({ children }: PropsWithChildren<{}>) => {
4545
sx={{
4646
zIndex: 1,
4747
position: 'sticky',
48-
top: 0,
49-
maxHeight: '100vh',
48+
top: 'var(--gds-header-height-visible)',
49+
maxHeight: 'calc(100vh - var(--gds-header-height-visible))',
5050
paddingInlineEnd: Spacing['24px'],
5151
pt: Spacing['32px'],
5252
pb: Spacing['16px'],
5353
overflowY: 'auto',
54-
transform: 'translateY(calc(var(--gds-header-height-visible) * var(--gds-header-fixed)))',
55-
transition: enableTransition ? buildTransition('TRANSFORM', '400ms') : undefined,
5654
}}
5755
>
5856
{children}
59-
<div
60-
sx={{
61-
height: 'var(--gds-header-height-visible)',
62-
transition: enableTransition ? buildTransition('height', '400ms') : undefined,
63-
}}
64-
/>
6557
</div>
6658
)
6759
}

packages/nextra-theme/src/layout/MDXLayoutOutline.tsx

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,11 @@ export const MDXLayoutOutline = () => {
2020
sx={{
2121
zIndex: 1,
2222
position: 'sticky',
23-
top: 0,
24-
maxHeight: '100vh',
23+
top: 'var(--gds-header-height-visible)',
24+
maxHeight: 'calc(100vh - var(--gds-header-height-visible))',
2525
px: Spacing['8px'],
2626
py: Spacing['32px'],
2727
overflowY: 'auto',
28-
transform: 'translateY(calc(var(--gds-header-height-visible) * var(--gds-header-fixed)))',
29-
transition: enableTransition ? buildTransition('TRANSFORM', '400ms') : undefined,
3028
}}
3129
>
3230
<Flex.Row>
@@ -66,12 +64,6 @@ export const MDXLayoutOutline = () => {
6664
</nav>
6765
</>
6866
) : null}
69-
<div
70-
sx={{
71-
height: 'var(--gds-header-height-visible)',
72-
transition: enableTransition ? buildTransition('height', '400ms') : undefined,
73-
}}
74-
/>
7567
</div>
7668
)
7769
}

0 commit comments

Comments
 (0)