Skip to content

Commit 289e0fb

Browse files
committed
Merge branch 'main' of github.com:reactjs/reactjs.org
2 parents ba74b05 + fba9eab commit 289e0fb

33 files changed

+2413
-590
lines changed

beta/.env.development

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
SANDPACK_BARE_COMPONENTS=true

beta/.env.production

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
NEXT_PUBLIC_GA_TRACKING_ID = 'UA-41298772-4'
1+
NEXT_PUBLIC_GA_TRACKING_ID = 'UA-41298772-4'
2+
SANDPACK_BARE_COMPONENTS=true

beta/next.config.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
* Copyright (c) Facebook, Inc. and its affiliates.
33
*/
44

5-
const path = require('path');
65
const redirects = require('./src/redirects.json');
76

87
/**
@@ -17,6 +16,9 @@ const nextConfig = {
1716
legacyBrowsers: false,
1817
browsersListForSwc: true,
1918
},
19+
env: {
20+
SANDPACK_BARE_COMPONENTS: process.env.SANDPACK_BARE_COMPONENTS,
21+
},
2022
async redirects() {
2123
return redirects.redirects;
2224
},
@@ -49,8 +51,16 @@ const nextConfig = {
4951
const {IgnorePlugin, NormalModuleReplacementPlugin} = require('webpack');
5052
config.plugins.push(
5153
new NormalModuleReplacementPlugin(
52-
/@codemirror\/lang-markdown/,
53-
require.resolve('./src/utils/codemirrorMarkdownShim.js')
54+
/^@stitches\/core$/,
55+
require.resolve('./src/utils/emptyShim.js')
56+
),
57+
new NormalModuleReplacementPlugin(
58+
/^raf$/,
59+
require.resolve('./src/utils/rafShim.js')
60+
),
61+
new NormalModuleReplacementPlugin(
62+
/^process$/,
63+
require.resolve('./src/utils/processShim.js')
5464
),
5565
new IgnorePlugin({
5666
checkResource(resource, context) {

beta/package.json

Lines changed: 2 additions & 1 deletion
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.7.2",
25+
"@codesandbox/sandpack-react": "1.14.1",
2626
"@docsearch/css": "3.0.0-alpha.41",
2727
"@docsearch/react": "3.0.0-alpha.41",
2828
"@headlessui/react": "^1.7.0",
@@ -38,6 +38,7 @@
3838
"react": "0.0.0-experimental-cb5084d1c-20220924",
3939
"react-collapsed": "npm:@gaearon/[email protected]",
4040
"react-dom": "0.0.0-experimental-cb5084d1c-20220924",
41+
"remark-frontmatter": "^4.0.1",
4142
"remark-gfm": "^3.0.1"
4243
},
4344
"devDependencies": {

beta/src/components/Layout/MarkdownPage.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import PageHeading from 'components/PageHeading';
99
import {useRouteMeta} from './useRouteMeta';
1010
import {TocContext} from '../MDX/TocContext';
1111

12+
import(/* webpackPrefetch: true */ '../MDX/CodeBlock/CodeBlock');
13+
1214
export interface MarkdownProps<Frontmatter> {
1315
meta: Frontmatter & {description?: string};
1416
children?: React.ReactNode;

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,10 @@ export function Navigation({
7171

7272
useEffect(() => {
7373
handleResize();
74-
window.addEventListener('resize', debounce(handleResize, 200));
74+
const debouncedHandleResize = debounce(handleResize, 200);
75+
window.addEventListener('resize', debouncedHandleResize);
7576
return () => {
76-
window.removeEventListener('resize', handleResize);
77+
window.removeEventListener('resize', debouncedHandleResize);
7778
};
7879
}, [handleResize]);
7980

beta/src/components/MDX/ConsoleBlock.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function ConsoleBlock({level = 'error', children}: ConsoleBlockProps) {
3838
}
3939

4040
return (
41-
<div className="mb-4" translate="no">
41+
<div className="mb-4 text-secondary" translate="no">
4242
<div className="flex w-full rounded-t-lg bg-gray-200 dark:bg-gray-80">
4343
<div className="px-4 py-2 border-gray-300 dark:border-gray-90 border-r">
4444
<Box className="bg-gray-300 dark:bg-gray-90" width="15px" />

beta/src/components/MDX/ExpandableCallout.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,25 @@ import {useRef} from 'react';
66
import * as React from 'react';
77
import cn from 'classnames';
88
import {IconNote} from '../Icon/IconNote';
9+
import {IconWarning} from '../Icon/IconWarning';
910
import {IconGotcha} from '../Icon/IconGotcha';
1011

11-
type CalloutVariants = 'gotcha' | 'note' | 'wip';
12+
type CalloutVariants = 'deprecated' | 'gotcha' | 'note' | 'wip';
1213

1314
interface ExpandableCalloutProps {
1415
children: React.ReactNode;
1516
type: CalloutVariants;
1617
}
1718

1819
const variantMap = {
20+
deprecated: {
21+
title: 'Deprecated',
22+
Icon: IconWarning,
23+
containerClasses: 'bg-red-5 dark:bg-red-60 dark:bg-opacity-20',
24+
textColor: 'text-red-50 dark:text-red-40',
25+
overlayGradient:
26+
'linear-gradient(rgba(249, 247, 243, 0), rgba(249, 247, 243, 1)',
27+
},
1928
note: {
2029
title: 'Nota',
2130
Icon: IconNote,

beta/src/components/MDX/MDXComponents.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ const Wip = ({children}: {children: React.ReactNode}) => (
7979
const Gotcha = ({children}: {children: React.ReactNode}) => (
8080
<ExpandableCallout type="gotcha">{children}</ExpandableCallout>
8181
);
82+
const Deprecated = ({children}: {children: React.ReactNode}) => (
83+
<ExpandableCallout type="deprecated">{children}</ExpandableCallout>
84+
);
8285
const Note = ({children}: {children: React.ReactNode}) => (
8386
<ExpandableCallout type="note">{children}</ExpandableCallout>
8487
);
@@ -369,6 +372,7 @@ export const MDXComponents = {
369372
return <div className="max-w-4xl ml-0 2xl:mx-auto">{children}</div>;
370373
},
371374
Gotcha,
375+
Deprecated,
372376
Wip,
373377
HomepageHero,
374378
Illustration,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,14 +181,14 @@ export const SandpackConsole = ({visible}: {visible: boolean}) => {
181181
</button>
182182
</div>
183183
{isExpanded && (
184-
<div className="w-full h-full border-y bg-white dark:border-gray-700 dark:bg-gray-95 min-h-[28px] console">
184+
<div className="w-full h-full border-t bg-white dark:border-gray-700 dark:bg-gray-95 min-h-[28px] console">
185185
<div className="max-h-40 h-auto overflow-auto" ref={wrapperRef}>
186186
{logs.map(({data, id, method}) => {
187187
return (
188188
<div
189189
key={id}
190190
className={cn(
191-
'last:border-none border-b dark:border-gray-700 text-md p-1 pl-2 leading-6 font-mono min-h-[32px] whitespace-pre-wrap',
191+
'first:border-none border-t dark:border-gray-700 text-md p-1 pl-2 leading-6 font-mono min-h-[32px] whitespace-pre-wrap',
192192
`console-${getType(method)}`,
193193
getColor(method)
194194
)}>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ const SandboxShell = memo(function SandboxShell({
111111
}
112112
}
113113
}}>
114-
<span className="flex p-2 focus:outline-none text-primary dark:text-primary-dark">
114+
<span className="flex p-2 focus:outline-none text-primary dark:text-primary-dark leading-[20px]">
115115
<IconChevron
116116
className="inline mr-1.5 text-xl"
117117
displayDirection={isExpanded ? 'up' : 'down'}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ export function NavigationBar({providedFiles}: {providedFiles: Array<string>}) {
125125
// space that's taken by the (invisible) tab list.
126126
<button
127127
className={cn(
128-
'absolute top-0 left-0',
128+
'absolute top-0 left-[2px]',
129129
!showDropdown && 'invisible'
130130
)}>
131131
<span

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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 ml-2 md:ml-1"
1212
title="Open in CodeSandbox">
1313
<IconNewPage
14-
className="inline ml-1 mr-1 relative"
14+
className="inline ml-1 mr-1 relative top-[1px]"
1515
width="1em"
1616
height="1em"
1717
/>

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

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {SandpackLogLevel} from '@codesandbox/sandpack-client';
99
import {CustomPreset} from './CustomPreset';
1010
import {createFileMap} from './createFileMap';
1111
import {CustomTheme} from './Themes';
12-
import type {SandpackSetup} from '@codesandbox/sandpack-react';
1312

1413
type SandpackProps = {
1514
children: React.ReactNode;
@@ -78,19 +77,11 @@ function SandpackRoot(props: SandpackProps) {
7877
hidden: true,
7978
};
8079

81-
let setup: SandpackSetup | undefined;
82-
if (files['/package.json']) {
83-
setup = {
84-
dependencies: JSON.parse(files['/package.json'].code).dependencies,
85-
};
86-
}
87-
8880
return (
89-
<div className="sandpack sandpack--playground sandbox my-8">
81+
<div className="sandpack sandpack--playground my-8">
9082
<SandpackProvider
9183
template="react"
9284
files={files}
93-
customSetup={setup}
9485
theme={CustomTheme}
9586
options={{
9687
autorun,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {createFileMap} from './createFileMap';
88
const SandpackRoot = lazy(() => import('./SandpackRoot'));
99

1010
const SandpackGlimmer = ({code}: {code: string}) => (
11-
<div className="sandpack sandpack--playground sandbox my-8">
11+
<div className="sandpack sandpack--playground my-8">
1212
<div className="sp-wrapper">
1313
<div className="shadow-lg dark:shadow-lg-dark rounded-lg">
1414
<div className="bg-wash h-10 dark:bg-card-dark flex justify-between items-center relative z-10 border-b border-border dark:border-border-dark rounded-t-lg rounded-b-none">

0 commit comments

Comments
 (0)