Skip to content

Commit f918355

Browse files
authored
Merge branch 'main' into translate-learn-your-first-component
2 parents 97d0ccf + daa4e36 commit f918355

File tree

238 files changed

+4137
-4362
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

238 files changed

+4137
-4362
lines changed

.github/labeler.yml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
beta:
2+
- beta/**/*

.github/workflows/analyze.yml

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: Analyze Bundle
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main # change this if your default branch is named differently
8+
workflow_dispatch:
9+
10+
jobs:
11+
analyze:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
16+
- name: Set up node
17+
uses: actions/setup-node@v1
18+
with:
19+
node-version: "14.x"
20+
21+
- name: Install dependencies
22+
uses: bahmutov/npm-install@v1.6.0
23+
with:
24+
working-directory: 'beta'
25+
26+
- name: Restore next build
27+
uses: actions/cache@v2
28+
id: restore-build-cache
29+
env:
30+
cache-name: cache-next-build
31+
with:
32+
path: beta/.next/cache
33+
# change this if you prefer a more strict cache
34+
key: ${{ runner.os }}-build-${{ env.cache-name }}
35+
36+
- name: Build next.js app
37+
# change this if your site requires a custom build command
38+
run: ./node_modules/.bin/next build
39+
working-directory: beta
40+
41+
# Here's the first place where next-bundle-analysis' own script is used
42+
# This step pulls the raw bundle stats for the current bundle
43+
- name: Analyze bundle
44+
run: npx -p nextjs-bundle-analysis report
45+
working-directory: beta
46+
47+
- name: Upload bundle
48+
uses: actions/upload-artifact@v2
49+
with:
50+
path: beta/.next/analyze/__bundle_analysis.json
51+
name: bundle_analysis.json
52+
53+
- name: Download base branch bundle stats
54+
uses: dawidd6/action-download-artifact@v2
55+
if: success() && github.event.number
56+
with:
57+
workflow: bundle_analysis_upload.yml
58+
branch: ${{ github.event.pull_request.base.ref }}
59+
name: bundle_analysis.json
60+
path: beta/.next/analyze/base/bundle
61+
62+
# And here's the second place - this runs after we have both the current and
63+
# base branch bundle stats, and will compare them to determine what changed.
64+
# There are two configurable arguments that come from package.json:
65+
#
66+
# - budget: optional, set a budget (bytes) against which size changes are measured
67+
# it's set to 350kb here by default, as informed by the following piece:
68+
# https://infrequently.org/2021/03/the-performance-inequality-gap/
69+
#
70+
# - red-status-percentage: sets the percent size increase where you get a red
71+
# status indicator, defaults to 20%
72+
#
73+
# Either of these arguments can be changed or removed by editing the `nextBundleAnalysis`
74+
# entry in your package.json file.
75+
- name: Compare with base branch bundle
76+
if: success() && github.event.number
77+
run: ls -laR .next/analyze/base && npx -p nextjs-bundle-analysis compare
78+
working-directory: beta
79+
80+
- name: Upload analysis comment
81+
uses: actions/upload-artifact@v2
82+
with:
83+
name: analysis_comment.txt
84+
path: beta/.next/analyze/__bundle_analysis_comment.txt
85+
86+
- name: Save PR number
87+
run: echo ${{ github.event.number }} > ./pr_number
88+
89+
- name: Upload PR number
90+
uses: actions/upload-artifact@v2
91+
with:
92+
name: pr_number
93+
path: ./pr_number
94+
95+
# The actual commenting happens in the other action, matching the guidance in
96+
# https://securitylab.github.com/research/github-actions-preventing-pwn-requests/

.github/workflows/analyze_comment.yml

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Analyze Bundle (Comment)
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Analyze Bundle"]
6+
types:
7+
- completed
8+
9+
jobs:
10+
comment:
11+
runs-on: ubuntu-latest
12+
if: >
13+
${{ github.event.workflow_run.event == 'pull_request' &&
14+
github.event.workflow_run.conclusion == 'success' }}
15+
steps:
16+
- name: Download base branch bundle stats
17+
uses: dawidd6/action-download-artifact@v2
18+
with:
19+
workflow: analyze.yml
20+
run_id: ${{ github.event.workflow_run.id }}
21+
name: analysis_comment.txt
22+
path: analysis_comment.txt
23+
24+
- name: Download PR number
25+
uses: dawidd6/action-download-artifact@v2
26+
with:
27+
workflow: analyze.yml
28+
run_id: ${{ github.event.workflow_run.id }}
29+
name: pr_number
30+
path: pr_number
31+
32+
- name: Get comment body
33+
id: get-comment-body
34+
if: success()
35+
run: |
36+
pr_number=$(cat pr_number/pr_number)
37+
body=$(cat analysis_comment.txt/__bundle_analysis_comment.txt)
38+
body="## Size Changes
39+
<details>
40+
41+
${body}
42+
43+
</details>"
44+
body="${body//'%'/'%25'}"
45+
body="${body//$'\n'/'%0A'}"
46+
body="${body//$'\r'/'%0D'}"
47+
echo ::set-output name=body::$body
48+
echo ::set-output name=pr-number::$pr_number
49+
50+
- name: Find Comment
51+
uses: peter-evans/find-comment@v1
52+
if: success()
53+
id: fc
54+
with:
55+
issue-number: ${{ steps.get-comment-body.outputs.pr-number }}
56+
body-includes: "<!-- __NEXTJS_BUNDLE -->"
57+
58+
- name: Create Comment
59+
uses: peter-evans/create-or-update-comment@v1.4.4
60+
if: success() && steps.fc.outputs.comment-id == 0
61+
with:
62+
issue-number: ${{ steps.get-comment-body.outputs.pr-number }}
63+
body: ${{ steps.get-comment-body.outputs.body }}
64+
65+
- name: Update Comment
66+
uses: peter-evans/create-or-update-comment@v1.4.4
67+
if: success() && steps.fc.outputs.comment-id != 0
68+
with:
69+
issue-number: ${{ steps.get-comment-body.outputs.pr-number }}
70+
body: ${{ steps.get-comment-body.outputs.body }}
71+
comment-id: ${{ steps.fc.outputs.comment-id }}
72+
edit-mode: replace

.github/workflows/beta_site_lint.yml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Beta Site Lint
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
7+
jobs:
8+
lint:
9+
runs-on: ubuntu-latest
10+
11+
name: Lint on node 12.x and ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v1
15+
- name: Use Node.js 12.x
16+
uses: actions/setup-node@v1
17+
with:
18+
node-version: 12.x
19+
20+
- name: Install deps and build (with cache)
21+
uses: bahmutov/npm-install@v1.6.0
22+
with:
23+
working-directory: 'beta'
24+
25+
26+
- name: Lint codebase
27+
run: cd beta && yarn ci-check

.github/workflows/label.yml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# This workflow will triage pull requests and apply a label based on the
2+
# paths that are modified in the pull request.
3+
#
4+
# To use this workflow, you will need to set up a .github/labeler.yml
5+
# file with configuration. For more information, see:
6+
# https://github.com/actions/labeler
7+
8+
name: Labeler
9+
on: [pull_request_target]
10+
11+
jobs:
12+
label:
13+
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
pull-requests: write
18+
19+
steps:
20+
- uses: actions/labeler@v2
21+
with:
22+
repo-token: "${{ secrets.GITHUB_TOKEN }}"

.github/workflows/nodejs.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
node-version: 12.x
1919

2020
- name: Install deps and build (with cache)
21-
uses: bahmutov/npm-install@v1
21+
uses: bahmutov/npm-install@v1.6.0
2222

2323
- name: Lint codebase
2424
run: yarn ci-check

beta/.eslintrc

+3-11
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,10 @@
11
{
2-
"extends": ["react-app", "plugin:jsx-a11y/recommended"],
3-
"plugins": ["jsx-a11y"],
4-
"overrides": [
5-
{
6-
"files": ["**/*.ts?(x)"],
7-
"rules": {
8-
"jsx-a11y/anchor-is-valid": 0
9-
}
10-
}
11-
],
2+
"root": true,
3+
"extends": "next",
124
"env": {
135
"node": true,
146
"commonjs": true,
157
"browser": true,
168
"es6": true
179
}
18-
}
10+
}

beta/.husky/pre-commit

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
cd beta
5+
# yarn generate-ids
6+
# git add -u src/pages/**/*.md
7+
yarn prettier
8+
yarn lint:fix

beta/.prettierrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"bracketSpacing": false,
33
"singleQuote": true,
4-
"jsxBracketSameLine": true,
4+
"bracketSameLine": true,
55
"trailingComma": "es5",
66
"printWidth": 80
77
}

beta/README.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ This repo contains the source code and documentation powering [reactjs.org](http
1616
### Installation
1717

1818
1. `cd reactjs.org` to go into the project root
19-
1. `yarn` to install the website's npm dependencies
19+
1. `cd beta` to open the beta website
20+
3. `yarn` to install the website's npm dependencies
2021

2122
### Running locally
2223

24+
1. Make sure you're in the `beta` folder
2325
1. `yarn dev` to start the development server (powered by [Next.js](https://nextjs.org/))
2426
1. `open http://localhost:3000` to open the site in your favorite browser
2527

@@ -46,7 +48,7 @@ The documentation is divided into several sections with a different tone and pur
4648
### Test the change
4749

4850
1. If possible, test any visual changes in all latest versions of common browsers, on both desktop and mobile.
49-
1. Run `yarn check-all` from the project root. (This will run Prettier, ESLint, and Flow.)
51+
2. Run `yarn check-all` from the `beta` folder. (This will run Prettier, ESLint and validate types.)
5052

5153
### Push it
5254

beta/colors.js

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ module.exports = {
2323
'secondary-button-dark': '#404756', // gray-70
2424

2525
// Gray
26+
'gray-95': '#16181D',
2627
'gray-90': '#23272F',
2728
'gray-80': '#343A46',
2829
'gray-70': '#404756',

beta/next.config.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ module.exports = {
1010
pageExtensions: ['jsx', 'js', 'ts', 'tsx', 'mdx', 'md'],
1111
experimental: {
1212
plugins: true,
13-
reactMode: 'concurrent',
13+
// TODO: this doesn't work because https://github.com/vercel/next.js/issues/30714
14+
// concurrentFeatures: true,
1415
scrollRestoration: true,
1516
},
1617
async redirects() {
@@ -30,6 +31,18 @@ module.exports = {
3031
];
3132
},
3233
webpack: (config, {dev, isServer, ...options}) => {
34+
if (process.env.ANALYZE) {
35+
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer')
36+
config.plugins.push(
37+
new BundleAnalyzerPlugin({
38+
analyzerMode: 'static',
39+
reportFilename: options.isServer
40+
? '../analyze/server.html'
41+
: './analyze/client.html',
42+
})
43+
);
44+
}
45+
3346
// Add our custom markdown loader in order to support frontmatter
3447
// and layout
3548
config.module.rules.push({

0 commit comments

Comments
 (0)