Skip to content

Commit

Permalink
Merge branch 'canary' into fix/fixed_warning_unique_key_for_scripts_w…
Browse files Browse the repository at this point in the history
…ith_beforeinteractive
  • Loading branch information
Pavlo Tymchuk authored and Pavlo Tymchuk committed Jul 1, 2021
2 parents 6c42948 + e89b8e4 commit 5c6d1bf
Show file tree
Hide file tree
Showing 239 changed files with 1,552 additions and 943 deletions.
6 changes: 3 additions & 3 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Learn how to add code owners here:
# https://help.github.com/en/articles/about-code-owners

* @timneutkens @ijjk @lfades @divmain @shuding
/docs/ @timneutkens @ijjk @lfades @divmain @shuding @leerob
/examples/ @timneutkens @ijjk @lfades @divmain @shuding @leerob
* @timneutkens @ijjk @shuding @styfle @huozhi @padmaia
/docs/ @timneutkens @ijjk @shuding @styfle @huozhi @padmaia @leerob @lfades
/examples/ @timneutkens @ijjk @shuding @styfle @huozhi @padmaia @leerob @lfades
11 changes: 10 additions & 1 deletion .github/labeler.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,22 @@
"packages/react-refresh-utils/**",
"packages/next-codemod/**"
],
"type: chrome": [
"created-by: Chrome Aurora": [
{ "type": "user", "pattern": "spanicker" },
{ "type": "user", "pattern": "housseindjirdeh" },
{ "type": "user", "pattern": "devknoll" },
{ "type": "user", "pattern": "janicklas-ralph" },
{ "type": "user", "pattern": "atcastle" },
{ "type": "user", "pattern": "Joonpark13" }
],
"created-by: Next.js team": [
{ "type": "user", "pattern": "ijjk" },
{ "type": "user", "pattern": "padmaia" },
{ "type": "user", "pattern": "huozhi" },
{ "type": "user", "pattern": "shuding" },
{ "type": "user", "pattern": "sokra" },
{ "type": "user", "pattern": "styfle" },
{ "type": "user", "pattern": "timneutkens" }
]
}
}
8 changes: 4 additions & 4 deletions .github/workflows/build_test_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
with:
path: ./*
key: ${{ github.sha }}
- run: ./check-pre-compiled.sh
- run: ./scripts/check-pre-compiled.sh
if: ${{needs.build.outputs.docsChange != 'docs only change'}}

testUnit:
Expand Down Expand Up @@ -146,7 +146,7 @@ jobs:
path: ./*
key: ${{ github.sha }}

- run: bash ./test-pnp.sh
- run: bash ./scripts/test-pnp.sh
if: ${{needs.build.outputs.docsChange != 'docs only change'}}

testsPass:
Expand Down Expand Up @@ -251,7 +251,7 @@ jobs:
path: ./*
key: ${{ github.sha }}

- run: ./publish-release.sh
- run: ./scripts/publish-release.sh

prStats:
name: Release Stats
Expand All @@ -263,7 +263,7 @@ jobs:
with:
path: ./*
key: ${{ github.sha }}
- run: ./release-stats.sh
- run: ./scripts/release-stats.sh
- uses: ./.github/actions/next-stats-action
env:
PR_STATS_COMMENT_TOKEN: ${{ secrets.PR_STATS_COMMENT_TOKEN }}
67 changes: 34 additions & 33 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,36 +111,37 @@ stages:
- script: |
node run-tests.js -g 1/1 --timings --azure --type unit
displayName: 'Run tests'
- job: test_chrome_integration
pool:
vmImage: 'windows-2019'
strategy:
matrix:
nodejs-1:
group: 1/4
nodejs-2:
group: 2/4
nodejs-3:
group: 3/4
nodejs-4:
group: 4/4
steps:
- checkout: none
- script: |
wmic datafile where name="C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe" get Version /value
displayName: 'List Chrome version'
- task: NodeTool@0
inputs:
versionSpec: $(node_version)
displayName: 'Install Node.js'
- task: Cache@2
inputs:
# use deterministic cache key that is specific
# to this test run
key: $(Build.SourceVersion)
path: $(System.DefaultWorkingDirectory)
displayName: Cache Build
- script: |
node run-tests.js -g $(group) --timings --azure
displayName: 'Run tests'
# TODO: investigate re-enabling when stability matches running in
# tests in ubuntu environment
# - job: test_chrome_integration
# pool:
# vmImage: 'windows-2019'
# strategy:
# matrix:
# nodejs-1:
# group: 1/4
# nodejs-2:
# group: 2/4
# nodejs-3:
# group: 3/4
# nodejs-4:
# group: 4/4
# steps:
# - checkout: none
# - script: |
# wmic datafile where name="C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe" get Version /value
# displayName: 'List Chrome version'
# - task: NodeTool@0
# inputs:
# versionSpec: $(node_version)
# displayName: 'Install Node.js'
# - task: Cache@2
# inputs:
# # use deterministic cache key that is specific
# # to this test run
# key: $(Build.SourceVersion)
# path: $(System.DefaultWorkingDirectory)
# displayName: Cache Build
# - script: |
# node run-tests.js -g $(group) --timings --azure
# displayName: 'Run tests'
4 changes: 2 additions & 2 deletions docs/api-reference/next.config.js/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module.exports = (phase, { defaultConfig }) => {
}
```

`phase` is the current context in which the configuration is loaded. You can see the [available phases](https://github.com/vercel/next.js/blob/canary/packages/next/next-server/lib/constants.ts#L1-L4). Phases can be imported from `next/constants`:
`phase` is the current context in which the configuration is loaded. You can see the [available phases](https://github.com/vercel/next.js/blob/canary/packages/next/shared/lib/constants.ts#L1-L4). Phases can be imported from `next/constants`:

```js
const { PHASE_DEVELOPMENT_SERVER } = require('next/constants')
Expand All @@ -44,7 +44,7 @@ module.exports = (phase, { defaultConfig }) => {
}
```

The commented lines are the place where you can put the configs allowed by `next.config.js`, which are [defined in this file](https://github.com/vercel/next.js/blob/canary/packages/next/next-server/server/config-shared.ts#L68).
The commented lines are the place where you can put the configs allowed by `next.config.js`, which are [defined in this file](https://github.com/vercel/next.js/blob/canary/packages/next/server/config-shared.ts#L68).

However, none of the configs are required, and it's not necessary to understand what each config does. Instead, search for the features you need to enable or modify in this section and they will show you what to do.

Expand Down
2 changes: 1 addition & 1 deletion docs/basic-features/typescript.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ The `next.config.js` file must be a JavaScript file as it does not get parsed by
// @ts-check

/**
* @type {import('next/dist/next-server/server/config').NextConfig}
* @type {import('next').NextConfig}
**/
const nextConfig = {
/* config options here */
Expand Down
2 changes: 1 addition & 1 deletion examples/layout-component/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Layout component example

This example shows a very common use case when building websites where you need to repeat some sort of layout for all your pages. Our pages are: `home`, `about` and `contact` and they all share the same `<head>` settings, the `<nav>` and the `<footer>`. Further more, the title (and potentially other head elements) can be sent as a prop to the layout component so that it's customizable in all pages.
This example shows a very common use case when building websites where you need to repeat some sort of layout for all your pages. Our pages are: `home`, `about` and `contact` and they all share the same layout and sidebar.

## Preview

Expand Down
35 changes: 6 additions & 29 deletions examples/layout-component/components/layout.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,13 @@
import Link from 'next/link'
import Head from 'next/head'
import styles from './layout.module.css'

export default function Layout({
children,
title = 'This is the default title',
}) {
export default function Layout({ children }) {
return (
<div>
<>
<Head>
<title>{title}</title>
<meta charSet="utf-8" />
<meta name="viewport" content="initial-scale=1.0, width=device-width" />
<title>Layouts Example</title>
</Head>
<header>
<nav>
<Link href="/">
<a>Home</a>
</Link>{' '}
|
<Link href="/about">
<a>About</a>
</Link>{' '}
|
<Link href="/contact">
<a>Contact</a>
</Link>
</nav>
</header>

{children}

<footer>{'I`m here to stay'}</footer>
</div>
<main className={styles.main}>{children}</main>
</>
)
}
9 changes: 9 additions & 0 deletions examples/layout-component/components/layout.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.main {
display: flex;
height: calc(100vh - 64px);
background-color: white;
}

.main > section {
padding: 32px;
}
19 changes: 19 additions & 0 deletions examples/layout-component/components/sidebar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import Link from 'next/link'
import styles from './sidebar.module.css'

export default function Sidebar() {
return (
<nav className={styles.nav}>
<input className={styles.input} placeholder="Search..." />
<Link href="/">
<a>Home</a>
</Link>
<Link href="/about">
<a>About</a>
</Link>
<Link href="/contact">
<a>Contact</a>
</Link>
</nav>
)
}
39 changes: 39 additions & 0 deletions examples/layout-component/components/sidebar.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
.nav {
height: 100%;
display: flex;
flex-direction: column;
width: 250px;
background-color: #fafafa;
padding: 32px;
border-right: 1px solid #eaeaea;
}

.nav > a {
margin: 8px 0;
text-decoration: none;
background: white;
border-radius: 4px;
font-size: 14px;
padding: 12px 16px;
text-transform: uppercase;
font-weight: 600;
letter-spacing: 0.025em;
color: #333;
border: 1px solid #eaeaea;
transition: all 0.125s ease;
}

.nav > a:hover {
background-color: #eaeaea;
}

.input {
margin: 32px 0;
text-decoration: none;
background: white;
border-radius: 4px;
border: 1px solid #eaeaea;
font-size: 14px;
padding: 8px 16px;
height: 28px;
}
12 changes: 12 additions & 0 deletions examples/layout-component/global.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#__next {
display: flex;
flex-direction: column;
min-height: 100vh;
}

body {
margin: 0;
font-size: 24px;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica,
Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
}
8 changes: 8 additions & 0 deletions examples/layout-component/pages/_app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import '../global.css'

export default function MyApp({ Component, pageProps }) {
// Use the layout defined at the page level, if available
const getLayout = Component.getLayout || ((page) => page)

return getLayout(<Component {...pageProps} />)
}
37 changes: 34 additions & 3 deletions examples/layout-component/pages/about.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,40 @@
import Layout from '../components/layout'
import Sidebar from '../components/sidebar'

export default function About() {
return (
<Layout title="About us">
<div>About us</div>
</Layout>
<section>
<h2>Layout Example (About)</h2>
<p>
This example adds a property <code>getLayout</code> to your page,
allowing you to return a React component for the layout. This allows you
to define the layout on a per-page basis. Since we're returning a
function, we can have complex nested layouts if desired.
</p>
<p>
When navigating between pages, we want to persist page state (input
values, scroll position, etc) for a Single-Page Application (SPA)
experience.
</p>
<p>
This layout pattern will allow for state persistence because the React
component tree is persisted between page transitions. To preserve state,
we need to prevent the React component tree from being discarded between
page transitions.
</p>
<h3>Try It Out</h3>
<p>
To visualize this, try tying in the search input in the{' '}
<code>Sidebar</code> and then changing routes. You'll notice the input
state is persisted.
</p>
</section>
)
}

About.getLayout = (page) => (
<Layout>
<Sidebar />
{page}
</Layout>
)
37 changes: 34 additions & 3 deletions examples/layout-component/pages/contact.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,40 @@
import Layout from '../components/layout'
import Sidebar from '../components/sidebar'

export default function Contact() {
return (
<Layout title="Contact us">
<div>Contact</div>
</Layout>
<section>
<h2>Layout Example (Contact)</h2>
<p>
This example adds a property <code>getLayout</code> to your page,
allowing you to return a React component for the layout. This allows you
to define the layout on a per-page basis. Since we're returning a
function, we can have complex nested layouts if desired.
</p>
<p>
When navigating between pages, we want to persist page state (input
values, scroll position, etc) for a Single-Page Application (SPA)
experience.
</p>
<p>
This layout pattern will allow for state persistence because the React
component tree is persisted between page transitions. To preserve state,
we need to prevent the React component tree from being discarded between
page transitions.
</p>
<h3>Try It Out</h3>
<p>
To visualize this, try tying in the search input in the{' '}
<code>Sidebar</code> and then changing routes. You'll notice the input
state is persisted.
</p>
</section>
)
}

Contact.getLayout = (page) => (
<Layout>
<Sidebar />
{page}
</Layout>
)
Loading

0 comments on commit 5c6d1bf

Please sign in to comment.