Skip to content

Commit d1aca01

Browse files
Merge pull request #197 from reactjs/sync-6bd09fe6
Sync with reactjs.org @ 6bd09fe
2 parents 2307b3a + 1eed806 commit d1aca01

Some content is hidden

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

50 files changed

+2890
-527
lines changed

beta/.eslintrc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
{
22
"root": true,
3-
"extends": "next",
3+
"extends": "next/core-web-vitals",
4+
"rules": {
5+
"no-unused-vars": "warn"
6+
},
47
"env": {
58
"node": true,
69
"commonjs": true,
710
"browser": true,
811
"es6": true
912
}
10-
}
13+
}

beta/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"check-all": "npm-run-all prettier lint:fix tsc"
2323
},
2424
"dependencies": {
25-
"@codesandbox/sandpack-react": "0.13.16-experimental.0",
25+
"@codesandbox/sandpack-react": "v0.14.3-experimental.1",
2626
"@docsearch/css": "3.0.0-alpha.41",
2727
"@docsearch/react": "3.0.0-alpha.41",
2828
"@headlessui/react": "^1.3.0",
@@ -53,7 +53,7 @@
5353
"@typescript-eslint/eslint-plugin": "2.x",
5454
"@typescript-eslint/parser": "2.x",
5555
"asyncro": "^3.0.0",
56-
"autoprefixer": "^10.3.1",
56+
"autoprefixer": "^10.4.2",
5757
"babel-eslint": "10.x",
5858
"eslint": "7.x",
5959
"eslint-config-next": "12.0.3",
@@ -72,7 +72,7 @@
7272
"mdast-util-to-string": "^1.1.0",
7373
"npm-run-all": "^4.1.5",
7474
"patch-package": "^6.2.2",
75-
"postcss": "^8.3.6",
75+
"postcss": "^8.4.5",
7676
"postcss-flexbugs-fixes": "4.2.1",
7777
"postcss-preset-env": "^6.7.0",
7878
"prettier": "^2.5.1",
@@ -86,7 +86,7 @@
8686
"retext": "^7.0.1",
8787
"retext-smartypants": "^4.0.0",
8888
"rss": "^1.2.2",
89-
"tailwindcss": "^2.2.7",
89+
"tailwindcss": "^3.0.22",
9090
"typescript": "^4.0.2",
9191
"unist-util-visit": "^2.0.3",
9292
"webpack-bundle-analyzer": "^4.5.0"

beta/public/images/docs/diagrams/sharing_data_child.dark.svg

Lines changed: 60 additions & 0 deletions
Loading

beta/public/images/docs/diagrams/sharing_data_child.svg

Lines changed: 60 additions & 0 deletions
Loading

beta/public/images/docs/diagrams/sharing_data_child_clicked.dark.svg

Lines changed: 64 additions & 0 deletions
Loading

beta/public/images/docs/diagrams/sharing_data_child_clicked.svg

Lines changed: 64 additions & 0 deletions
Loading

beta/public/images/docs/diagrams/sharing_data_parent.dark.svg

Lines changed: 57 additions & 0 deletions
Loading

beta/public/images/docs/diagrams/sharing_data_parent.svg

Lines changed: 57 additions & 0 deletions
Loading

beta/public/images/docs/diagrams/sharing_data_parent_clicked.dark.svg

Lines changed: 75 additions & 0 deletions
Loading

beta/public/images/docs/diagrams/sharing_data_parent_clicked.svg

Lines changed: 75 additions & 0 deletions
Loading

beta/src/components/Icon/IconArrow.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const IconArrow = React.memo<
1919
fill="currentColor"
2020
{...rest}
2121
className={cn(className, {
22-
'transform rotate-180': displayDirection === 'right',
22+
'rotate-180': displayDirection === 'right',
2323
})}>
2424
<path fill="none" d="M0 0h24v24H0z" />
2525
<path d="M7.828 11H20v2H7.828l5.364 5.364-1.414 1.414L4 12l7.778-7.778 1.414 1.414z" />

beta/src/components/Icon/IconArrowSmall.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ export const IconArrowSmall = React.memo<
1111
}
1212
>(function IconArrowSmall({displayDirection, className, ...rest}) {
1313
const classes = cn(className, {
14-
'transform rotate-180': displayDirection === 'left',
15-
'transform rotate-90': displayDirection === 'down',
14+
'rotate-180': displayDirection === 'left',
15+
'rotate-90': displayDirection === 'down',
1616
});
1717
return (
1818
<svg

beta/src/components/Icon/IconChevron.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ export const IconChevron = React.memo<
1212
>(function IconChevron({className, displayDirection, ...rest}) {
1313
const classes = cn(
1414
{
15-
'transform rotate-0': displayDirection === 'down',
16-
'transform rotate-90': displayDirection === 'left',
17-
'transform rotate-180': displayDirection === 'up',
18-
'transform -rotate-90': displayDirection === 'right',
15+
'rotate-0': displayDirection === 'down',
16+
'rotate-90': displayDirection === 'left',
17+
'rotate-180': displayDirection === 'up',
18+
'-rotate-90': displayDirection === 'right',
1919
},
2020
className
2121
);

beta/src/components/Icon/IconNavArrow.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ export const IconNavArrow = React.memo<
1313
const classes = cn(
1414
'duration-100 ease-in transition',
1515
{
16-
'transform rotate-0': displayDirection === 'down',
17-
'transform -rotate-90': displayDirection === 'right',
18-
'transform rotate-90': displayDirection === 'left',
16+
'rotate-0': displayDirection === 'down',
17+
'-rotate-90': displayDirection === 'right',
18+
'rotate-90': displayDirection === 'left',
1919
},
2020
className
2121
);

beta/src/components/Layout/Sidebar/Sidebar.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export function Sidebar({isMobileOnly}: {isMobileOnly?: boolean}) {
2828
return (
2929
<aside
3030
className={cn(
31-
`lg:flex-grow lg:flex flex-col w-full pt-4 pb-8 lg:pb-0 lg:max-w-xs fixed lg:sticky bg-wash dark:bg-wash-dark z-10 top-0`,
31+
`lg:grow lg:flex flex-col w-full pt-4 pb-8 lg:pb-0 lg:max-w-xs fixed lg:sticky bg-wash dark:bg-wash-dark z-10 top-0`,
3232
isOpen ? 'block z-40' : 'hidden lg:block'
3333
)}
3434
aria-hidden={isHidden}>
@@ -39,7 +39,7 @@ export function Sidebar({isMobileOnly}: {isMobileOnly?: boolean}) {
3939
role="navigation"
4040
ref={menuRef}
4141
style={{'--bg-opacity': '.2'} as React.CSSProperties} // Need to cast here because CSS vars aren't considered valid in TS types (cuz they could be anything)
42-
className="w-full h-screen lg:h-auto flex-grow pr-0 lg:pr-5 pt-6 pb-44 lg:pb-0 lg:py-6 md:pt-4 lg:pt-4 overflow-y-scroll lg:overflow-y-auto scrolling-touch scrolling-gpu">
42+
className="w-full h-screen lg:h-auto grow pr-0 lg:pr-5 pt-6 pb-44 lg:pb-0 lg:py-6 md:pt-4 lg:pt-4 overflow-y-scroll lg:overflow-y-auto scrolling-touch scrolling-gpu">
4343
{isMobileSidebar ? (
4444
<MobileNav />
4545
) : (

beta/src/components/MDX/Challenges/Navigation.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export function Navigation({
8989
{challenges.map(({name, id, order}, index) => (
9090
<button
9191
className={cn(
92-
'py-2 mr-4 text-base border-b-4 duration-100 ease-in transition whitespace-nowrap overflow-ellipsis',
92+
'py-2 mr-4 text-base border-b-4 duration-100 ease-in transition whitespace-nowrap text-ellipsis',
9393
isRecipes &&
9494
currentChallenge.id === id &&
9595
'text-purple-50 border-purple-50 hover:text-purple-50 dark:text-purple-30 dark:border-purple-30 dark:hover:text-purple-30',
@@ -108,6 +108,7 @@ export function Navigation({
108108
<div className="flex z-10 pb-2 pl-2">
109109
<button
110110
onClick={handleScrollLeft}
111+
aria-label="Scroll left"
111112
className={cn(
112113
'bg-secondary-button dark:bg-secondary-button-dark h-8 px-2 rounded-l border-gray-20 border-r',
113114
{
@@ -119,6 +120,7 @@ export function Navigation({
119120
</button>
120121
<button
121122
onClick={handleScrollRight}
123+
aria-label="Scroll right"
122124
className={cn(
123125
'bg-secondary-button dark:bg-secondary-button-dark h-8 px-2 rounded-r-lg',
124126
{

beta/src/components/MDX/Diagram.tsx

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*/
4+
5+
import * as React from 'react';
6+
import Image from 'next/image';
7+
8+
interface DiagramProps {
9+
name: string;
10+
alt: string;
11+
height: number;
12+
width: number;
13+
children: string;
14+
}
15+
16+
export function Diagram({name, alt, height, width, children}: DiagramProps) {
17+
return (
18+
<figure className="flex flex-col px-0 py-5 sm:p-10">
19+
<div className="dark-image">
20+
<Image
21+
src={`/images/docs/diagrams/${name}.dark.svg`}
22+
alt={alt}
23+
height={height}
24+
width={width}
25+
/>
26+
</div>
27+
<div className="light-image">
28+
<Image
29+
src={`/images/docs/diagrams/${name}.svg`}
30+
alt={alt}
31+
height={height}
32+
width={width}
33+
/>
34+
</div>
35+
<figcaption className="p-1 sm:p-4 mt-4 sm:mt-0 text-gray-40 text-base lg:text-lg text-center leading-6">
36+
{children}
37+
</figcaption>
38+
</figure>
39+
);
40+
}
41+
42+
export default Diagram;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*/
4+
5+
import * as React from 'react';
6+
import {ReactNode} from 'react';
7+
8+
interface DiagramGroupProps {
9+
children: ReactNode;
10+
}
11+
12+
export function DiagramGroup({children}: DiagramGroupProps) {
13+
return (
14+
<div className="flex flex-col sm:flex-row px-6 py-2 sm:p-0 space-y-10 sm:space-y-0">
15+
{children}
16+
</div>
17+
);
18+
}
19+
20+
export default DiagramGroup;

beta/src/components/MDX/HomepageHero.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import YouWillLearnCard from 'components/MDX/YouWillLearnCard';
99
function HomepageHero() {
1010
return (
1111
<>
12-
<div className="mt-8 lg:mt-10 mb-0 sm:mt-8 sm:mb-8 lg:mb-6 flex-col sm:flex-row flex flex-grow items-start sm:items-center justify-start mx-auto max-w-4xl">
12+
<div className="mt-8 lg:mt-10 mb-0 sm:mt-8 sm:mb-8 lg:mb-6 flex-col sm:flex-row flex grow items-start sm:items-center justify-start mx-auto max-w-4xl">
1313
<Logo className="text-link dark:text-link-dark w-20 sm:w-28 mr-4 mb-4 sm:mb-0 h-auto" />
1414
<div className="flex flex-wrap">
1515
<h1 className="text-5xl mr-4 -mt-1 flex wrap font-bold leading-tight text-primary dark:text-primary-dark">

beta/src/components/MDX/MDXComponents.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import Link from './Link';
1919
import {PackageImport} from './PackageImport';
2020
import Recap from './Recap';
2121
import Sandpack from './Sandpack';
22+
import Diagram from './Diagram';
23+
import DiagramGroup from './DiagramGroup';
2224
import SimpleCallout from './SimpleCallout';
2325
import TerminalBlock from './TerminalBlock';
2426
import YouWillLearnCard from './YouWillLearnCard';
@@ -369,6 +371,8 @@ export const MDXComponents = {
369371
title: string;
370372
excerpt: string;
371373
}) => <ExpandableExample {...props} type="DeepDive" />,
374+
Diagram,
375+
DiagramGroup,
372376
Gotcha,
373377
HomepageHero,
374378
Illustration,

beta/src/components/MDX/Sandpack/NavigationBar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export function NavigationBar({showDownload}: {showDownload: boolean}) {
5252
{dropdownActive ? <FilesDropdown /> : <FileTabs />}
5353
</div>
5454
<div
55-
className="px-3 flex items-center justify-end flex-grow text-right"
55+
className="px-3 flex items-center justify-end grow text-right"
5656
translate="yes">
5757
{showDownload && <DownloadButton />}
5858
<ResetButton onReset={handleReset} />

beta/src/components/MDX/Sandpack/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const SandpackGlimmer = ({code}: {code: string}) => (
1515
<div className="px-4 lg:px-6">
1616
<div className="sp-tabs"></div>
1717
</div>
18-
<div className="px-3 flex items-center justify-end flex-grow text-right"></div>
18+
<div className="px-3 flex items-center justify-end grow text-right"></div>
1919
</div>
2020
<div className="sp-wrapper">
2121
<div className="sp-layout sp-custom-layout min-h-[216px]">

beta/src/components/Search.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export const Search: React.FC<SearchProps> = ({
106106
type="button"
107107
className="hidden md:flex relative pl-4 pr-0.5 py-1 h-10 bg-secondary-button dark:bg-gray-80 outline-none focus:ring focus:outline-none betterhover:hover:bg-opacity-80 pointer items-center shadow-inner text-left w-full text-gray-30 rounded-lg align-middle text-sm"
108108
onClick={onOpen}>
109-
<IconSearch className="mr-3 align-middle text-gray-30 flex-shrink-0 group-betterhover:hover:text-gray-70" />
109+
<IconSearch className="mr-3 align-middle text-gray-30 shrink-0 group-betterhover:hover:text-gray-70" />
110110
Search
111111
<span className="ml-auto hidden sm:flex item-center">
112112
<Kbd></Kbd>

beta/src/pages/apis/index.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,29 @@ If you use React on the web, you'll also need the same version of [ReactDOM](/ap
3434

3535
## Exports {/*exports*/}
3636

37-
<YouWillLearnCard title="useState" path="/reference/usestate">
37+
<YouWillLearnCard title="useState" path="/apis/usestate">
3838

39-
A React Hook that lets a component "remember" some information (called state).
39+
Declares a state variable.
40+
41+
```js
42+
function MyComponent() {
43+
const [age, setAge] = useState(42);
44+
// ...
45+
```
4046
4147
</YouWillLearnCard>
4248
49+
<YouWillLearnCard title="useRef" path="/apis/useref">
50+
51+
Declares a ref.
52+
53+
```js
54+
function MyComponent() {
55+
const inputRef = useRef(null);
56+
// ...
57+
```
58+
59+
</YouWillLearnCard>
60+
61+
4362
This section is incomplete and is still being written!

beta/src/pages/apis/reactdom.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,13 @@ ReactDOM supports all popular browsers, including Internet Explorer 9 and above.
3838

3939
## Exports {/*exports*/}
4040

41-
<YouWillLearnCard title="render" path="/reference/render">
41+
<YouWillLearnCard title="render" path="/apis/render">
4242

43-
Renders a piece of JSX ("React element") into a browser DOM container node.
43+
Displays a React component inside a browser DOM node.
44+
45+
```js
46+
render(<App />, document.getElementById('root'));
47+
```
4448

4549
</YouWillLearnCard>
4650

0 commit comments

Comments
 (0)