Skip to content

Commit 94a1d2c

Browse files
Merge branch 'main' of https://github.com/reactjs/react.dev into sync-bdc60c26
2 parents c8ceb74 + bdc60c2 commit 94a1d2c

Some content is hidden

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

47 files changed

+1366
-859
lines changed

.env.development

-1
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
SANDPACK_BARE_COMPONENTS=true

.env.production

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
NEXT_PUBLIC_GA_TRACKING_ID = 'UA-41298772-4'
2-
SANDPACK_BARE_COMPONENTS=true
1+
NEXT_PUBLIC_GA_TRACKING_ID = 'UA-41298772-4'

next.config.js

+1-7
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ const nextConfig = {
1414
scrollRestoration: true,
1515
legacyBrowsers: false,
1616
},
17-
env: {
18-
SANDPACK_BARE_COMPONENTS: process.env.SANDPACK_BARE_COMPONENTS,
19-
},
17+
env: {},
2018
webpack: (config, {dev, isServer, ...options}) => {
2119
if (process.env.ANALYZE) {
2220
const {BundleAnalyzerPlugin} = require('webpack-bundle-analyzer');
@@ -35,10 +33,6 @@ const nextConfig = {
3533

3634
const {IgnorePlugin, NormalModuleReplacementPlugin} = require('webpack');
3735
config.plugins.push(
38-
new NormalModuleReplacementPlugin(
39-
/^@stitches\/core$/,
40-
require.resolve('./src/utils/emptyShim.js')
41-
),
4236
new NormalModuleReplacementPlugin(
4337
/^raf$/,
4438
require.resolve('./src/utils/rafShim.js')

package.json

+1-1
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": "1.15.5",
25+
"@codesandbox/sandpack-react": "2.6.0",
2626
"@docsearch/css": "3.0.0-alpha.41",
2727
"@docsearch/react": "3.0.0-alpha.41",
2828
"@headlessui/react": "^1.7.0",

patches/@codemirror+lang-javascript+0.19.6.patch

-30
This file was deleted.

patches/@codesandbox+sandpack-react+1.15.5.patch

-62
This file was deleted.

patches/@lezer+javascript+0.15.2.patch

-345
This file was deleted.

src/components/Icon/IconTwitter.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ export const IconTwitter = memo<JSX.IntrinsicElements['svg']>(
99
return (
1010
<svg
1111
xmlns="http://www.w3.org/2000/svg"
12-
viewBox="0 0 24 24"
13-
width="1.33em"
14-
height="1.33em"
12+
viewBox="0 0 512 512"
13+
height="1.30em"
14+
width="1.30em"
1515
fill="currentColor"
1616
{...props}>
1717
<path fill="none" d="M0 0h24v24H0z" />
18-
<path d="M22.162 5.656a8.384 8.384 0 0 1-2.402.658A4.196 4.196 0 0 0 21.6 4c-.82.488-1.719.83-2.656 1.015a4.182 4.182 0 0 0-7.126 3.814 11.874 11.874 0 0 1-8.62-4.37 4.168 4.168 0 0 0-.566 2.103c0 1.45.738 2.731 1.86 3.481a4.168 4.168 0 0 1-1.894-.523v.052a4.185 4.185 0 0 0 3.355 4.101 4.21 4.21 0 0 1-1.89.072A4.185 4.185 0 0 0 7.97 16.65a8.394 8.394 0 0 1-6.191 1.732 11.83 11.83 0 0 0 6.41 1.88c7.693 0 11.9-6.373 11.9-11.9 0-.18-.005-.362-.013-.54a8.496 8.496 0 0 0 2.087-2.165z" />
18+
<path d="M389.2 48h70.6L305.6 224.2 487 464H345L233.7 318.6 106.5 464H35.8L200.7 275.5 26.8 48H172.4L272.9 180.9 389.2 48zM364.4 421.8h39.1L151.1 88h-42L364.4 421.8z" />
1919
</svg>
2020
);
2121
}

src/components/Layout/HomeContent.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,7 @@ function ExampleLayout({
849849
{overlayStyles.map((styles, i) => (
850850
<div
851851
key={i}
852-
className="inset-x-0 bg-blue-30/5 border-2 border-link dark:border-link-dark absolute rounded-lg"
852+
className="top-0 start-0 bg-blue-30/5 border-2 border-link dark:border-link-dark absolute rounded-lg"
853853
style={styles}
854854
/>
855855
))}

src/components/Layout/Sidebar/SidebarButton.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export function SidebarButton({
3131
})}>
3232
<button
3333
className={cn(
34-
'p-2 pe-2 ps-5 w-full rounded-s-lg text-start hover:bg-gray-5 dark:hover:bg-gray-80 relative flex items-center justify-between',
34+
'p-2 pe-2 ps-5 w-full rounded-e-lg text-start hover:bg-gray-5 dark:hover:bg-gray-80 relative flex items-center justify-between',
3535
{
3636
'p-2 text-base': level > 1,
3737
'text-link bg-highlight dark:bg-highlight-dark text-base font-bold hover:bg-highlight dark:hover:bg-highlight-dark hover:text-link dark:hover:text-link-dark':

src/components/Layout/Sidebar/SidebarLink.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export function SidebarLink({
5858
passHref
5959
aria-current={selected ? 'page' : undefined}
6060
className={cn(
61-
'p-2 pe-2 w-full rounded-none lg:rounded-s-2xl text-start hover:bg-gray-5 dark:hover:bg-gray-80 relative flex items-center justify-between',
61+
'p-2 pe-2 w-full rounded-none lg:rounded-e-2xl text-start hover:bg-gray-5 dark:hover:bg-gray-80 relative flex items-center justify-between',
6262
{
6363
'text-sm ps-6': level > 0,
6464
'ps-5': level < 2,
@@ -78,7 +78,7 @@ export function SidebarLink({
7878
{canary && (
7979
<IconCanary
8080
title="This feature is available in the latest Canary"
81-
className="ml-2 text-gray-30 dark:text-gray-60 inline-block w-4 h-4 align-[-3px]"
81+
className="ms-2 text-gray-30 dark:text-gray-60 inline-block w-4 h-4 align-[-3px]"
8282
/>
8383
)}
8484
</div>

src/components/MDX/CodeBlock/CodeBlock.tsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@
33
*/
44

55
import cn from 'classnames';
6-
import {highlightTree, HighlightStyle, tags} from '@codemirror/highlight';
6+
import {HighlightStyle} from '@codemirror/language';
7+
import {highlightTree} from '@lezer/highlight';
78
import {javascript} from '@codemirror/lang-javascript';
89
import {html} from '@codemirror/lang-html';
910
import {css} from '@codemirror/lang-css';
1011
import rangeParser from 'parse-numeric-range';
12+
import {tags} from '@lezer/highlight';
13+
1114
import {CustomTheme} from '../Sandpack/Themes';
1215

1316
interface InlineHighlight {
@@ -52,7 +55,7 @@ const CodeBlock = function CodeBlock({
5255
let tokenStarts = new Map();
5356
let tokenEnds = new Map();
5457
const highlightTheme = getSyntaxHighlight(CustomTheme);
55-
highlightTree(tree, highlightTheme.match, (from, to, className) => {
58+
highlightTree(tree, highlightTheme, (from, to, className) => {
5659
tokenStarts.set(from, className);
5760
tokenEnds.set(to, className);
5861
});

src/components/MDX/Heading.tsx

+8
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,11 @@ export const H4 = ({className, ...props}: HeadingProps) => (
8888
{...props}
8989
/>
9090
);
91+
92+
export const H5 = ({className, ...props}: HeadingProps) => (
93+
<Heading
94+
as="h5"
95+
className={cn(className, 'text-lg font-display font-bold leading-9 my-2')}
96+
{...props}
97+
/>
98+
);

src/components/MDX/MDXComponents.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {CodeDiagram} from './CodeDiagram';
1111
import ConsoleBlock from './ConsoleBlock';
1212
import ExpandableCallout from './ExpandableCallout';
1313
import ExpandableExample from './ExpandableExample';
14-
import {H1, H2, H3, H4} from './Heading';
14+
import {H1, H2, H3, H4, H5} from './Heading';
1515
import InlineCode from './InlineCode';
1616
import Intro from './Intro';
1717
import BlogCard from './BlogCard';
@@ -388,6 +388,7 @@ export const MDXComponents = {
388388
h2: H2,
389389
h3: H3,
390390
h4: H4,
391+
h5: H5,
391392
hr: Divider,
392393
a: Link,
393394
img: Image,

src/components/MDX/Sandpack/Console.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ import cn from 'classnames';
55
import {useState, useRef, useEffect} from 'react';
66
import {IconChevron} from 'components/Icon/IconChevron';
77

8-
import {SandpackCodeViewer, useSandpack} from '@codesandbox/sandpack-react';
8+
import {
9+
SandpackCodeViewer,
10+
useSandpack,
11+
} from '@codesandbox/sandpack-react/unstyled';
912
import type {SandpackMessageConsoleMethods} from '@codesandbox/sandpack-client';
1013

1114
const getType = (

src/components/MDX/Sandpack/CustomPreset.tsx

+1-22
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ import {
77
useSandpack,
88
useActiveCode,
99
SandpackCodeEditor,
10-
// SandpackReactDevTools,
1110
SandpackLayout,
12-
} from '@codesandbox/sandpack-react';
11+
} from '@codesandbox/sandpack-react/unstyled';
1312
import cn from 'classnames';
1413

1514
import {IconChevron} from 'components/Icon/IconChevron';
@@ -19,14 +18,8 @@ import {Preview} from './Preview';
1918
import {useSandpackLint} from './useSandpackLint';
2019

2120
export const CustomPreset = memo(function CustomPreset({
22-
showDevTools,
23-
onDevToolsLoad,
24-
devToolsLoaded,
2521
providedFiles,
2622
}: {
27-
showDevTools: boolean;
28-
devToolsLoaded: boolean;
29-
onDevToolsLoad: () => void;
3023
providedFiles: Array<string>;
3124
}) {
3225
const {lintErrors, lintExtensions} = useSandpackLint();
@@ -41,9 +34,6 @@ export const CustomPreset = memo(function CustomPreset({
4134
const isExpandable = lineCount > 16;
4235
return (
4336
<SandboxShell
44-
showDevTools={showDevTools}
45-
onDevToolsLoad={onDevToolsLoad}
46-
devToolsLoaded={devToolsLoaded}
4737
providedFiles={providedFiles}
4838
lintErrors={lintErrors}
4939
lintExtensions={lintExtensions}
@@ -53,16 +43,11 @@ export const CustomPreset = memo(function CustomPreset({
5343
});
5444

5545
const SandboxShell = memo(function SandboxShell({
56-
showDevTools,
57-
devToolsLoaded,
5846
providedFiles,
5947
lintErrors,
6048
lintExtensions,
6149
isExpandable,
6250
}: {
63-
showDevTools: boolean;
64-
devToolsLoaded: boolean;
65-
onDevToolsLoad: () => void;
6651
providedFiles: Array<string>;
6752
lintErrors: Array<any>;
6853
lintExtensions: Array<any>;
@@ -81,7 +66,6 @@ const SandboxShell = memo(function SandboxShell({
8166
<NavigationBar providedFiles={providedFiles} />
8267
<SandpackLayout
8368
className={cn(
84-
showDevTools && devToolsLoaded && 'sp-layout-devtools',
8569
!(isExpandable || isExpanded) && 'rounded-b-lg overflow-hidden',
8670
isExpanded && 'sp-layout-expanded'
8771
)}>
@@ -123,11 +107,6 @@ const SandboxShell = memo(function SandboxShell({
123107
</button>
124108
)}
125109
</SandpackLayout>
126-
127-
{/* {showDevTools && (
128-
// @ts-ignore TODO(@danilowoz): support devtools
129-
<SandpackReactDevTools onLoadModule={onDevToolsLoad} />
130-
)} */}
131110
</div>
132111
</>
133112
);

src/components/MDX/Sandpack/DownloadButton.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44

55
import {useSyncExternalStore} from 'react';
6-
import {useSandpack} from '@codesandbox/sandpack-react';
6+
import {useSandpack} from '@codesandbox/sandpack-react/unstyled';
77
import {IconDownload} from '../../Icon/IconDownload';
88
export interface DownloadButtonProps {}
99

src/components/MDX/Sandpack/LoadingOverlay.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
LoadingOverlayState,
55
OpenInCodeSandboxButton,
66
useSandpack,
7-
} from '@codesandbox/sandpack-react';
7+
} from '@codesandbox/sandpack-react/unstyled';
88
import {useEffect} from 'react';
99

1010
const FADE_ANIMATION_DURATION = 200;

src/components/MDX/Sandpack/NavigationBar.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
FileTabs,
1616
useSandpack,
1717
useSandpackNavigation,
18-
} from '@codesandbox/sandpack-react';
18+
} from '@codesandbox/sandpack-react/unstyled';
1919
import {OpenInCodeSandboxButton} from './OpenInCodeSandboxButton';
2020
import {ResetButton} from './ResetButton';
2121
import {DownloadButton} from './DownloadButton';

src/components/MDX/Sandpack/OpenInCodeSandboxButton.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Copyright (c) Facebook, Inc. and its affiliates.
33
*/
44

5-
import {UnstyledOpenInCodeSandboxButton} from '@codesandbox/sandpack-react';
5+
import {UnstyledOpenInCodeSandboxButton} from '@codesandbox/sandpack-react/unstyled';
66
import {IconNewPage} from '../../Icon/IconNewPage';
77

88
export const OpenInCodeSandboxButton = () => {
@@ -11,7 +11,7 @@ export const OpenInCodeSandboxButton = () => {
1111
className="text-sm text-primary dark:text-primary-dark inline-flex items-center hover:text-link duration-100 ease-in transition mx-1 ms-2 md:ms-1"
1212
title="Open in CodeSandbox">
1313
<IconNewPage
14-
className="inline ms-1 me-1 relative top-[1px]"
14+
className="inline mx-1 relative top-[1px]"
1515
width="1em"
1616
height="1em"
1717
/>

src/components/MDX/Sandpack/OpenInTypeScriptPlayground.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export const OpenInTypeScriptPlaygroundButton = (props: {content: string}) => {
1616
target="_blank"
1717
rel="noreferrer">
1818
<IconNewPage
19-
className="inline ml-1 mr-1 relative top-[1px]"
19+
className="inline mx-1 relative top-[1px]"
2020
width="1em"
2121
height="1em"
2222
/>

src/components/MDX/Sandpack/Preview.tsx

+2-15
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
/* eslint-disable react-hooks/exhaustive-deps */
66
import {useRef, useState, useEffect, useMemo, useId} from 'react';
7-
import {useSandpack, SandpackStack} from '@codesandbox/sandpack-react';
7+
import {useSandpack, SandpackStack} from '@codesandbox/sandpack-react/unstyled';
88
import cn from 'classnames';
99
import {ErrorMessage} from './ErrorMessage';
1010
import {SandpackConsole} from './Console';
@@ -42,14 +42,7 @@ export function Preview({
4242
null
4343
);
4444

45-
let {
46-
error: rawError,
47-
registerBundler,
48-
unregisterBundler,
49-
errorScreenRegisteredRef,
50-
openInCSBRegisteredRef,
51-
loadingScreenRegisteredRef,
52-
} = sandpack;
45+
let {error: rawError, registerBundler, unregisterBundler} = sandpack;
5346

5447
if (
5548
rawError &&
@@ -88,12 +81,6 @@ export function Preview({
8881
const clientId = useId();
8982
const iframeRef = useRef<HTMLIFrameElement | null>(null);
9083

91-
// SandpackPreview immediately registers the custom screens/components so the bundler does not render any of them
92-
// TODO: why are we doing this during render?
93-
openInCSBRegisteredRef.current = true;
94-
errorScreenRegisteredRef.current = true;
95-
loadingScreenRegisteredRef.current = true;
96-
9784
const sandpackIdle = sandpack.status === 'idle';
9885

9986
useEffect(function createBundler() {

src/components/MDX/Sandpack/ResetButton.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export function ResetButton({onReset}: ResetButtonProps) {
1515
onClick={onReset}
1616
title="Reset Sandbox"
1717
type="button">
18-
<IconRestart className="inline ms-1 me-1 relative" /> Reset
18+
<IconRestart className="inline mx-1 relative" /> Reset
1919
</button>
2020
);
2121
}

0 commit comments

Comments
 (0)