Skip to content

Commit

Permalink
Merge pull request #94 from reactjs/sync-2390627c
Browse files Browse the repository at this point in the history
Sync with react.dev @ 2390627
  • Loading branch information
nafistiham authored Sep 25, 2023
2 parents 3b57c6f + 9097a59 commit 51a4110
Show file tree
Hide file tree
Showing 41 changed files with 271 additions and 862 deletions.
1 change: 0 additions & 1 deletion .env.development
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
SANDPACK_BARE_COMPONENTS=true
3 changes: 1 addition & 2 deletions .env.production
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
NEXT_PUBLIC_GA_TRACKING_ID = 'UA-41298772-4'
SANDPACK_BARE_COMPONENTS=true
NEXT_PUBLIC_GA_TRACKING_ID = 'UA-41298772-4'
8 changes: 1 addition & 7 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ const nextConfig = {
scrollRestoration: true,
legacyBrowsers: false,
},
env: {
SANDPACK_BARE_COMPONENTS: process.env.SANDPACK_BARE_COMPONENTS,
},
env: {},
webpack: (config, {dev, isServer, ...options}) => {
if (process.env.ANALYZE) {
const {BundleAnalyzerPlugin} = require('webpack-bundle-analyzer');
Expand All @@ -35,10 +33,6 @@ const nextConfig = {

const {IgnorePlugin, NormalModuleReplacementPlugin} = require('webpack');
config.plugins.push(
new NormalModuleReplacementPlugin(
/^@stitches\/core$/,
require.resolve('./src/utils/emptyShim.js')
),
new NormalModuleReplacementPlugin(
/^raf$/,
require.resolve('./src/utils/rafShim.js')
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"check-all": "npm-run-all prettier lint:fix tsc"
},
"dependencies": {
"@codesandbox/sandpack-react": "1.15.5",
"@codesandbox/sandpack-react": "2.6.0",
"@docsearch/css": "3.0.0-alpha.41",
"@docsearch/react": "3.0.0-alpha.41",
"@headlessui/react": "^1.7.0",
Expand Down
30 changes: 0 additions & 30 deletions patches/@codemirror+lang-javascript+0.19.6.patch

This file was deleted.

62 changes: 0 additions & 62 deletions patches/@codesandbox+sandpack-react+1.15.5.patch

This file was deleted.

345 changes: 0 additions & 345 deletions patches/@lezer+javascript+0.15.2.patch

This file was deleted.

Binary file removed public/images/team/dave-mccabe.jpg
Binary file not shown.
Binary file removed public/images/team/lunaruan.jpg
Binary file not shown.
Binary file removed public/images/team/mengdi-chen.jpg
Binary file not shown.
Binary file removed public/images/team/sean-keegan.jpg
Binary file not shown.
4 changes: 2 additions & 2 deletions src/components/Layout/HomeContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -1654,8 +1654,8 @@ function LikeButton({video}) {
<button
data-hover="LikeButton"
className={cn(
'outline-none focus:bg-red-50/5 focus:text-red-50 relative flex items-center justify-center w-10 h-10 cursor-pointer rounded-full text-tertiary hover:bg-card active:scale-95 active:bg-red-50/5 active:text-red-50',
isLiked && 'text-red-50'
'outline-none focus:bg-red-50/5 focus:text-red-50 relative flex items-center justify-center w-10 h-10 cursor-pointer rounded-full hover:bg-card active:scale-95 active:bg-red-50/5 active:text-red-50',
isLiked ? 'text-red-50' : 'text-tertiary'
)}
aria-label={isLiked ? 'Unsave' : 'Save'}
onClick={() => {
Expand Down
3 changes: 1 addition & 2 deletions src/components/Layout/Toc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ export function Toc({headings}: {headings: Toc}) {
<ul className="space-y-2 pb-16">
{headings.length > 0 &&
headings.map((h, i) => {
if (h.url == null) {
// TODO: only log in DEV
if (!h.url && process.env.NODE_ENV === 'development') {
console.error('Heading does not have URL');
}
return (
Expand Down
7 changes: 5 additions & 2 deletions src/components/MDX/CodeBlock/CodeBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
*/

import cn from 'classnames';
import {highlightTree, HighlightStyle, tags} from '@codemirror/highlight';
import {HighlightStyle} from '@codemirror/language';
import {highlightTree} from '@lezer/highlight';
import {javascript} from '@codemirror/lang-javascript';
import {html} from '@codemirror/lang-html';
import {css} from '@codemirror/lang-css';
import rangeParser from 'parse-numeric-range';
import {tags} from '@lezer/highlight';

import {CustomTheme} from '../Sandpack/Themes';

interface InlineHighlight {
Expand Down Expand Up @@ -52,7 +55,7 @@ const CodeBlock = function CodeBlock({
let tokenStarts = new Map();
let tokenEnds = new Map();
const highlightTheme = getSyntaxHighlight(CustomTheme);
highlightTree(tree, highlightTheme.match, (from, to, className) => {
highlightTree(tree, highlightTheme, (from, to, className) => {
tokenStarts.set(from, className);
tokenEnds.set(to, className);
});
Expand Down
5 changes: 4 additions & 1 deletion src/components/MDX/Sandpack/Console.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import cn from 'classnames';
import {useState, useRef, useEffect} from 'react';
import {IconChevron} from 'components/Icon/IconChevron';

import {SandpackCodeViewer, useSandpack} from '@codesandbox/sandpack-react';
import {
SandpackCodeViewer,
useSandpack,
} from '@codesandbox/sandpack-react/unstyled';
import type {SandpackMessageConsoleMethods} from '@codesandbox/sandpack-client';

const getType = (
Expand Down
23 changes: 1 addition & 22 deletions src/components/MDX/Sandpack/CustomPreset.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ import {
useSandpack,
useActiveCode,
SandpackCodeEditor,
// SandpackReactDevTools,
SandpackLayout,
} from '@codesandbox/sandpack-react';
} from '@codesandbox/sandpack-react/unstyled';
import cn from 'classnames';

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

export const CustomPreset = memo(function CustomPreset({
showDevTools,
onDevToolsLoad,
devToolsLoaded,
providedFiles,
}: {
showDevTools: boolean;
devToolsLoaded: boolean;
onDevToolsLoad: () => void;
providedFiles: Array<string>;
}) {
const {lintErrors, lintExtensions} = useSandpackLint();
Expand All @@ -41,9 +34,6 @@ export const CustomPreset = memo(function CustomPreset({
const isExpandable = lineCount > 16;
return (
<SandboxShell
showDevTools={showDevTools}
onDevToolsLoad={onDevToolsLoad}
devToolsLoaded={devToolsLoaded}
providedFiles={providedFiles}
lintErrors={lintErrors}
lintExtensions={lintExtensions}
Expand All @@ -53,16 +43,11 @@ export const CustomPreset = memo(function CustomPreset({
});

const SandboxShell = memo(function SandboxShell({
showDevTools,
devToolsLoaded,
providedFiles,
lintErrors,
lintExtensions,
isExpandable,
}: {
showDevTools: boolean;
devToolsLoaded: boolean;
onDevToolsLoad: () => void;
providedFiles: Array<string>;
lintErrors: Array<any>;
lintExtensions: Array<any>;
Expand All @@ -81,7 +66,6 @@ const SandboxShell = memo(function SandboxShell({
<NavigationBar providedFiles={providedFiles} />
<SandpackLayout
className={cn(
showDevTools && devToolsLoaded && 'sp-layout-devtools',
!(isExpandable || isExpanded) && 'rounded-b-lg overflow-hidden',
isExpanded && 'sp-layout-expanded'
)}>
Expand Down Expand Up @@ -123,11 +107,6 @@ const SandboxShell = memo(function SandboxShell({
</button>
)}
</SandpackLayout>

{/* {showDevTools && (
// @ts-ignore TODO(@danilowoz): support devtools
<SandpackReactDevTools onLoadModule={onDevToolsLoad} />
)} */}
</div>
</>
);
Expand Down
2 changes: 1 addition & 1 deletion src/components/MDX/Sandpack/DownloadButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/

import {useSyncExternalStore} from 'react';
import {useSandpack} from '@codesandbox/sandpack-react';
import {useSandpack} from '@codesandbox/sandpack-react/unstyled';
import {IconDownload} from '../../Icon/IconDownload';
export interface DownloadButtonProps {}

Expand Down
2 changes: 1 addition & 1 deletion src/components/MDX/Sandpack/LoadingOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
LoadingOverlayState,
OpenInCodeSandboxButton,
useSandpack,
} from '@codesandbox/sandpack-react';
} from '@codesandbox/sandpack-react/unstyled';
import {useEffect} from 'react';

const FADE_ANIMATION_DURATION = 200;
Expand Down
2 changes: 1 addition & 1 deletion src/components/MDX/Sandpack/NavigationBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
FileTabs,
useSandpack,
useSandpackNavigation,
} from '@codesandbox/sandpack-react';
} from '@codesandbox/sandpack-react/unstyled';
import {OpenInCodeSandboxButton} from './OpenInCodeSandboxButton';
import {ResetButton} from './ResetButton';
import {DownloadButton} from './DownloadButton';
Expand Down
2 changes: 1 addition & 1 deletion src/components/MDX/Sandpack/OpenInCodeSandboxButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Facebook, Inc. and its affiliates.
*/

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

export const OpenInCodeSandboxButton = () => {
Expand Down
17 changes: 2 additions & 15 deletions src/components/MDX/Sandpack/Preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

/* eslint-disable react-hooks/exhaustive-deps */
import {useRef, useState, useEffect, useMemo, useId} from 'react';
import {useSandpack, SandpackStack} from '@codesandbox/sandpack-react';
import {useSandpack, SandpackStack} from '@codesandbox/sandpack-react/unstyled';
import cn from 'classnames';
import {ErrorMessage} from './ErrorMessage';
import {SandpackConsole} from './Console';
Expand Down Expand Up @@ -42,14 +42,7 @@ export function Preview({
null
);

let {
error: rawError,
registerBundler,
unregisterBundler,
errorScreenRegisteredRef,
openInCSBRegisteredRef,
loadingScreenRegisteredRef,
} = sandpack;
let {error: rawError, registerBundler, unregisterBundler} = sandpack;

if (
rawError &&
Expand Down Expand Up @@ -88,12 +81,6 @@ export function Preview({
const clientId = useId();
const iframeRef = useRef<HTMLIFrameElement | null>(null);

// SandpackPreview immediately registers the custom screens/components so the bundler does not render any of them
// TODO: why are we doing this during render?
openInCSBRegisteredRef.current = true;
errorScreenRegisteredRef.current = true;
loadingScreenRegisteredRef.current = true;

const sandpackIdle = sandpack.status === 'idle';

useEffect(function createBundler() {
Expand Down
15 changes: 4 additions & 11 deletions src/components/MDX/Sandpack/SandpackRoot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
* Copyright (c) Facebook, Inc. and its affiliates.
*/

import {Children, useState} from 'react';
import {Children} from 'react';
import * as React from 'react';
import {SandpackProvider} from '@codesandbox/sandpack-react';
import {SandpackProvider} from '@codesandbox/sandpack-react/unstyled';
import {SandpackLogLevel} from '@codesandbox/sandpack-client';
import {CustomPreset} from './CustomPreset';
import {createFileMap} from './createFileMap';
Expand All @@ -13,7 +13,6 @@ import {CustomTheme} from './Themes';
type SandpackProps = {
children: React.ReactNode;
autorun?: boolean;
showDevTools?: boolean;
};

const sandboxStyle = `
Expand Down Expand Up @@ -67,8 +66,7 @@ ul {
`.trim();

function SandpackRoot(props: SandpackProps) {
let {children, autorun = true, showDevTools = false} = props;
const [devToolsLoaded, setDevToolsLoaded] = useState(false);
let {children, autorun = true} = props;
const codeSnippets = Children.toArray(children) as React.ReactElement[];
const files = createFileMap(codeSnippets);

Expand All @@ -90,12 +88,7 @@ function SandpackRoot(props: SandpackProps) {
bundlerURL: 'https://1e4ad8f7.sandpack-bundler-4bw.pages.dev',
logLevel: SandpackLogLevel.None,
}}>
<CustomPreset
showDevTools={showDevTools}
onDevToolsLoad={() => setDevToolsLoaded(true)}
devToolsLoaded={devToolsLoaded}
providedFiles={Object.keys(files)}
/>
<CustomPreset providedFiles={Object.keys(files)} />
</SandpackProvider>
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion src/components/MDX/Sandpack/createFileMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Facebook, Inc. and its affiliates.
*/

import type {SandpackFile} from '@codesandbox/sandpack-react';
import type {SandpackFile} from '@codesandbox/sandpack-react/unstyled';

export const createFileMap = (codeSnippets: any) => {
return codeSnippets.reduce(
Expand Down
10 changes: 1 addition & 9 deletions src/components/Seo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,12 @@ const deployedTranslations = [
'en',
'zh-hans',
'es',
'fr',
// We'll add more languages when they have enough content.
// Please DO NOT edit this list without a discussion in the reactjs/react.dev repo.
// It must be the same between all translations.
];

let shouldPreventIndexing = false;
if (
siteConfig.languageCode !== 'en' &&
!deployedTranslations.includes(siteConfig.languageCode)
) {
shouldPreventIndexing = true;
}

function getDomain(languageCode: string): string {
const subdomain = languageCode === 'en' ? '' : languageCode + '.';
return subdomain + 'react.dev';
Expand Down Expand Up @@ -69,7 +62,6 @@ export const Seo = withRouter(
href={canonicalUrl.replace(siteDomain, getDomain('en'))}
hrefLang="x-default"
/>
{shouldPreventIndexing && <meta name="robots" content="noindex" />}
{deployedTranslations.map((languageCode) => (
<link
key={'alt-' + languageCode}
Expand Down
5 changes: 4 additions & 1 deletion src/content/community/acknowledgements.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ We'd like to recognize a few people who have made significant contributions to R
* [Christoph Nakazawa](https://github.com/cpojer)
* [Christopher Chedeau](https://github.com/vjeux)
* [Clement Hoang](https://github.com/clemmy)
* [Dave McCabe](https://github.com/davidmccabe)
* [Dominic Gannaway](https://github.com/trueadm)
* [Flarnie Marchan](https://github.com/flarnie)
* [Jason Quense](https://github.com/jquense)
Expand All @@ -33,8 +34,10 @@ We'd like to recognize a few people who have made significant contributions to R
* [Josh Duck](https://github.com/joshduck)
* [Joe Critchley](https://github.com/joecritch)
* [Jeff Morrison](https://github.com/jeffmo)
* [Luna Ruan](https://github.com/lunaruan)
* [Keyan Zhang](https://github.com/keyz)
* [Marco Salazar](https://github.com/salazarm)
* [Mengdi Chen](https://github.com/mondaychen)
* [Nat Alison](https://github.com/tesseralis)
* [Nathan Hunzaker](https://github.com/nhunzaker)
* [Nicolas Gallagher](https://github.com/necolas)
Expand All @@ -45,7 +48,7 @@ We'd like to recognize a few people who have made significant contributions to R
* [Robert Zhang](https://github.com/robertzhidealx)
* [Sander Spies](https://github.com/sanderspies)
* [Sasha Aickin](https://github.com/aickin)
* [Seth Webster](https://github.com/sethwebster)
* [Sean Keegan](https://github.com/seanryankeegan)
* [Sophia Shoemaker](https://github.com/mrscobbler)
* [Sunil Pai](https://github.com/threepointone)
* [Tim Yung](https://github.com/yungsters)
Expand Down
2 changes: 1 addition & 1 deletion src/content/community/conferences.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ October 5 - 7, 2023. In-person in Goa, India (hybrid event) + Oct 3 2023 - remot

[Website](https://www.reactindia.io) - [Twitter](https://twitter.com/react_india) - [Facebook](https://www.facebook.com/ReactJSIndia) - [Youtube](https://www.youtube.com/channel/UCaFbHCBkPvVv1bWs_jwYt3w)

### React Brussels 2023 {/*react-brussels-2023*/}
### React Brussels 2023 {/*react-brussels-2023*/}
October 13th 2023. In-person in Brussels, Belgium + Remote (hybrid)

[Website](https://www.react.brussels/) - [Twitter](https://twitter.com/BrusselsReact)
Expand Down
Loading

0 comments on commit 51a4110

Please sign in to comment.