Skip to content

Commit 970823c

Browse files
committed
Merge branch 'main' into pr/Radapls/610
2 parents 7a131b7 + 76768e3 commit 970823c

File tree

153 files changed

+18062
-9088
lines changed

Some content is hidden

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

153 files changed

+18062
-9088
lines changed

beta/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
"eslint-plugin-import": "2.x",
6868
"eslint-plugin-jsx-a11y": "6.x",
6969
"eslint-plugin-react": "7.x",
70-
"eslint-plugin-react-hooks": "experimental",
70+
"eslint-plugin-react-hooks": "^0.0.0-experimental-fabef7a6b-20221215",
7171
"fs-extra": "^9.0.1",
7272
"globby": "^11.0.1",
7373
"gray-matter": "^4.0.2",
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
diff --git a/node_modules/@codemirror/lang-javascript/dist/index.cjs b/node_modules/@codemirror/lang-javascript/dist/index.cjs
2+
index 4475e4f..e1255c9 100644
3+
--- a/node_modules/@codemirror/lang-javascript/dist/index.cjs
4+
+++ b/node_modules/@codemirror/lang-javascript/dist/index.cjs
5+
@@ -135,7 +135,9 @@ const javascriptLanguage = language.LRLanguage.define({
6+
JSXText: highlight.tags.content,
7+
"JSXStartTag JSXStartCloseTag JSXSelfCloseEndTag JSXEndTag": highlight.tags.angleBracket,
8+
"JSXIdentifier JSXNameSpacedName": highlight.tags.tagName,
9+
- "JSXAttribute/JSXIdentifier JSXAttribute/JSXNameSpacedName": highlight.tags.attributeName
10+
+ "JSXAttribute/JSXIdentifier JSXAttribute/JSXNameSpacedName": highlight.tags.attributeName,
11+
+ "JSXAttribute/JSXLowerIdentifier JSXAttribute/JSXNameSpacedName": highlight.tags.attributeName,
12+
+ "JSXBuiltin/JSXIdentifier": highlight.tags.standard(highlight.tags.tagName)
13+
})
14+
]
15+
}),
16+
diff --git a/node_modules/@codemirror/lang-javascript/dist/index.js b/node_modules/@codemirror/lang-javascript/dist/index.js
17+
index d089f6b..db09ea6 100644
18+
--- a/node_modules/@codemirror/lang-javascript/dist/index.js
19+
+++ b/node_modules/@codemirror/lang-javascript/dist/index.js
20+
@@ -131,7 +131,9 @@ const javascriptLanguage = /*@__PURE__*/LRLanguage.define({
21+
JSXText: tags.content,
22+
"JSXStartTag JSXStartCloseTag JSXSelfCloseEndTag JSXEndTag": tags.angleBracket,
23+
"JSXIdentifier JSXNameSpacedName": tags.tagName,
24+
- "JSXAttribute/JSXIdentifier JSXAttribute/JSXNameSpacedName": tags.attributeName
25+
+ "JSXAttribute/JSXIdentifier JSXAttribute/JSXNameSpacedName": tags.attributeName,
26+
+ "JSXAttribute/JSXLowerIdentifier JSXAttribute/JSXNameSpacedName": tags.attributeName,
27+
+ "JSXBuiltin/JSXIdentifier": tags.standard(tags.tagName),
28+
})
29+
]
30+
}),

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

Lines changed: 26 additions & 0 deletions
Large diffs are not rendered by default.

beta/patches/@lezer+javascript+0.15.2.patch

Lines changed: 345 additions & 0 deletions
Large diffs are not rendered by default.
Loading
Loading
Loading
Loading
Loading
-23.4 KB
Binary file not shown.
3.96 KB
Loading
Loading
Loading
18.7 KB
Loading
Loading
Loading
-10.9 KB
Binary file not shown.
-16.4 KB
Binary file not shown.
Loading
2.53 KB
Loading

beta/src/components/Breadcrumbs.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function Breadcrumbs() {
1010
const {breadcrumbs} = useRouteMeta();
1111
if (!breadcrumbs) return null;
1212
return (
13-
<div className="flex">
13+
<div className="flex flex-wrap">
1414
{breadcrumbs.map(
1515
(crumb, i) =>
1616
crumb.path && (

beta/src/components/Layout/Footer.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,13 @@ export function Footer() {
112112
</FooterLink>
113113
</div>
114114
<div className="flex flex-col">
115-
<FooterLink href="/apis/react" isHeader={true}>
115+
<FooterLink href="/reference/react" isHeader={true}>
116116
API Reference
117117
</FooterLink>
118-
<FooterLink href="/apis/react">React APIs</FooterLink>
119-
<FooterLink href="/apis/react-dom">React DOM APIs</FooterLink>
118+
<FooterLink href="/reference/react">React APIs</FooterLink>
119+
<FooterLink href="/reference/react-dom">
120+
React DOM APIs
121+
</FooterLink>
120122
</div>
121123
<div className="flex flex-col sm:col-start-2 xl:col-start-4">
122124
<FooterLink href="/" isHeader={true}>

beta/src/components/Layout/Nav/Nav.tsx

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {SidebarContext} from 'components/Layout/useRouteMeta';
2020
import {SidebarRouteTree} from '../Sidebar/SidebarRouteTree';
2121
import type {RouteItem} from '../useRouteMeta';
2222
import sidebarLearn from '../../../sidebarLearn.json';
23-
import sidebarAPIs from '../../../sidebarAPIs.json';
23+
import sidebarReference from '../../../sidebarReference.json';
2424

2525
declare global {
2626
interface Window {
@@ -117,8 +117,8 @@ export default function Nav() {
117117
case 'learn':
118118
routeTree = sidebarLearn as RouteItem;
119119
break;
120-
case 'apis':
121-
routeTree = sidebarAPIs as RouteItem;
120+
case 'reference':
121+
routeTree = sidebarReference as RouteItem;
122122
break;
123123
}
124124
}
@@ -185,7 +185,7 @@ export default function Nav() {
185185
});
186186
}, [showFeedback]);
187187

188-
function selectTab(nextTab: 'learn' | 'apis') {
188+
function selectTab(nextTab: 'learn' | 'reference') {
189189
setTab(nextTab);
190190
scrollParentRef.current!.scrollTop = 0;
191191
}
@@ -214,7 +214,7 @@ export default function Nav() {
214214
</a>
215215
</NextLink>
216216
<div className="lg:w-full leading-loose hidden sm:flex flex-initial items-center h-auto pr-5 lg:pr-5 pt-0.5">
217-
<div className="px-1 mb-px bg-highlight dark:bg-highlight-dark rounded text-link dark:text-link-dark uppercase font-bold tracking-wide text-xs whitespace-nowrap">
217+
<div className="px-1 mb-px bg-highlight dark:bg-highlight-dark rounded uppercase text-link dark:text-link-dark font-bold tracking-wide text-xs whitespace-nowrap">
218218
Beta
219219
</div>
220220
</div>
@@ -241,14 +241,19 @@ export default function Nav() {
241241
</button>
242242
</div>
243243
</div>
244+
{!isOpen && (
245+
<div className="hidden lg:block sm:pt-10 lg:pt-4">
246+
<Search />
247+
</div>
248+
)}
244249
<div className="px-0 pt-2 w-full 2xl:max-w-xs hidden lg:flex items-center self-center border-b-0 lg:border-b border-border dark:border-border-dark">
245250
<NavLink
246251
href="/learn"
247252
isActive={section === 'learn' || section === 'home'}>
248253
Aprende
249254
</NavLink>
250-
<NavLink href="/apis/react" isActive={section === 'apis'}>
251-
API
255+
<NavLink href="/reference/react" isActive={section === 'reference'}>
256+
Referencia
252257
</NavLink>
253258
</div>
254259
<div className="flex my-4 h-10 mx-0 w-full lg:hidden justify-end lg:max-w-sm">
@@ -313,9 +318,9 @@ export default function Nav() {
313318
Aprende
314319
</TabButton>
315320
<TabButton
316-
isActive={tab === 'apis'}
317-
onClick={() => selectTab('apis')}>
318-
API
321+
isActive={tab === 'reference'}
322+
onClick={() => selectTab('reference')}>
323+
Referencia
319324
</TabButton>
320325
</div>
321326
)}
@@ -328,11 +333,6 @@ export default function Nav() {
328333
`lg:grow lg:flex flex-col w-full pb-8 lg:pb-0 lg:max-w-xs z-10`,
329334
isOpen ? 'block z-40' : 'hidden lg:block'
330335
)}>
331-
{!isOpen && (
332-
<div className="px-5 sm:pt-10 lg:pt-4">
333-
<Search />
334-
</div>
335-
)}
336336
<nav
337337
role="navigation"
338338
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)

beta/src/components/Layout/Page.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {Footer} from './Footer';
1212
import {Toc} from './Toc';
1313
import SocialBanner from '../SocialBanner';
1414
import sidebarLearn from '../../sidebarLearn.json';
15-
import sidebarAPIs from '../../sidebarAPIs.json';
15+
import sidebarReference from '../../sidebarReference.json';
1616
import type {TocItem} from 'components/MDX/TocContext';
1717

1818
interface PageProps {
@@ -25,8 +25,8 @@ export function Page({children, toc}: PageProps) {
2525
const section = useActiveSection();
2626
let routeTree = sidebarLearn as RouteItem;
2727
switch (section) {
28-
case 'apis':
29-
routeTree = sidebarAPIs as RouteItem;
28+
case 'reference':
29+
routeTree = sidebarReference as RouteItem;
3030
break;
3131
}
3232
return (

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

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,10 @@ export function SidebarRouteTree({
100100
return (
101101
<ul>
102102
{currentRoutes.map(
103-
({path, title, routes, wip, heading, hasSeparator}) => {
103+
(
104+
{path, title, routes, wip, heading, hasSectionHeader, sectionHeader},
105+
index
106+
) => {
104107
const pagePath = path && removeFromLast(path, '.');
105108
const selected = slug === pagePath;
106109

@@ -155,15 +158,22 @@ export function SidebarRouteTree({
155158
</li>
156159
);
157160
}
158-
159-
if (hasSeparator) {
161+
if (hasSectionHeader) {
160162
return (
161-
<Fragment key={`${title}-${path}-${level}-separator`}>
162-
<li
163-
role="separator"
164-
className="my-2 ml-5 border-b border-border dark:border-border-dark"
165-
/>
166-
{listItem}
163+
<Fragment key={`${sectionHeader}-${level}-separator`}>
164+
{index !== 0 && (
165+
<li
166+
role="separator"
167+
className="mt-4 mb-2 ml-5 border-b border-border dark:border-border-dark"
168+
/>
169+
)}
170+
<h3
171+
className={cn(
172+
'mb-1 text-sm font-bold ml-5 text-gray-400 dark:text-gray-500',
173+
index !== 0 && 'mt-2'
174+
)}>
175+
{sectionHeader}
176+
</h3>
167177
</Fragment>
168178
);
169179
} else {

beta/src/components/Layout/useRouteMeta.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ export interface RouteItem {
3434
wip?: boolean;
3535
/** List of sub-routes */
3636
routes?: RouteItem[];
37-
/** Adds a separator above the route item */
38-
hasSeparator?: boolean;
37+
/** Adds a section header above the route item */
38+
hasSectionHeader?: boolean;
39+
/** Title of section header */
40+
sectionHeader?: string;
3941
}
4042

4143
export interface Routes {

beta/src/components/MDX/CodeBlock/CodeBlock.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
*/
44

55
import cn from 'classnames';
6-
import {highlightTree} from '@codemirror/highlight';
6+
import {highlightTree, HighlightStyle, tags} from '@codemirror/highlight';
77
import {javascript} from '@codemirror/lang-javascript';
88
import {html} from '@codemirror/lang-html';
99
import {css} from '@codemirror/lang-css';
10-
import {HighlightStyle, tags} from '@codemirror/highlight';
1110
import rangeParser from 'parse-numeric-range';
1211
import {CustomTheme} from '../Sandpack/Themes';
1312

@@ -233,7 +232,7 @@ function getSyntaxHighlight(theme: any): HighlightStyle {
233232
class: classNameToken('static'),
234233
},
235234
{
236-
tag: tags.tagName,
235+
tag: tags.standard(tags.tagName),
237236
class: classNameToken('tag'),
238237
},
239238
{tag: tags.variableName, class: classNameToken('plain')},
@@ -244,7 +243,7 @@ function getSyntaxHighlight(theme: any): HighlightStyle {
244243
},
245244
{
246245
// Highlight function definition differently (eg: functional component def in React)
247-
tag: tags.definition(tags.function(tags.variableName)),
246+
tag: [tags.definition(tags.function(tags.variableName)), tags.tagName],
248247
class: classNameToken('definition'),
249248
},
250249
{

beta/src/components/MDX/ConsoleBlock.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ function ConsoleBlock({level = 'error', children}: ConsoleBlockProps) {
5858
className={cn(
5959
'flex px-4 pt-4 pb-6 items-center content-center font-mono text-code rounded-b-md',
6060
{
61-
'bg-red-30 text-red-40 bg-opacity-10': level === 'error',
61+
'bg-red-30 text-red-50 dark:text-red-30 bg-opacity-5':
62+
level === 'error',
6263
'bg-yellow-5 text-yellow-50': level === 'warning',
6364
'bg-gray-5 text-secondary dark:text-secondary-dark':
6465
level === 'info',

beta/src/components/MDX/ExpandableExample.tsx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,17 @@ function ExpandableExample({children, excerpt, type}: ExpandableExampleProps) {
2828
const isExample = type === 'Example';
2929
const id = children[0].props.id;
3030

31-
const queuedExpandRef = useRef<boolean>(true);
3231
const {asPath} = useRouter();
33-
// init as expanded to prevent flash
34-
const [isExpanded, setIsExpanded] = useState(true);
32+
const shouldAutoExpand = id === asPath.split('#')[1];
33+
const queuedExpandRef = useRef<boolean>(shouldAutoExpand);
34+
const [isExpanded, setIsExpanded] = useState(false);
3535

36-
// asPath would mismatch between server and client, reset here instead of put it into init state
3736
useEffect(() => {
3837
if (queuedExpandRef.current) {
3938
queuedExpandRef.current = false;
40-
if (id !== asPath.split('#')[1]) {
41-
setIsExpanded(false);
42-
}
39+
setIsExpanded(true);
4340
}
44-
}, [asPath, id]);
41+
}, []);
4542

4643
return (
4744
<details

beta/src/components/MDX/HomepageHero.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ function HomepageHero() {
2121
</div>
2222
<section className="my-8 sm:my-10 grid grid-cols-1 lg:grid-cols-2 gap-x-8 gap-y-4">
2323
<div className="flex flex-col justify-center">
24-
<YouWillLearnCard title="Learn React" path="/learn">
24+
<YouWillLearnCard title="Quick Start" path="/learn">
2525
<p>
2626
Learn how to think in React with step-by-step explanations and
2727
interactive examples.
2828
</p>
2929
</YouWillLearnCard>
3030
</div>
3131
<div className="flex flex-col justify-center">
32-
<YouWillLearnCard title="API Reference" path="/apis/react">
32+
<YouWillLearnCard title="API Reference" path="/reference/react">
3333
<p>
3434
Look up the API of React Hooks, and see their shape with
3535
color-coded signatures.

beta/src/components/MDX/MDXComponents.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ const UL = (p: JSX.IntrinsicElements['ul']) => (
7272
);
7373

7474
const Divider = () => (
75-
<hr className="my-6 block border-b border-border dark:border-border-dark" />
75+
<hr className="my-6 block border-b border-t-0 border-border dark:border-border-dark" />
7676
);
7777
const Wip = ({children}: {children: React.ReactNode}) => (
7878
<ExpandableCallout type="wip">{children}</ExpandableCallout>
@@ -325,6 +325,9 @@ function calculateNestedToc(toc: Toc): NestedTocRoot {
325325
function InlineToc() {
326326
const toc = useContext(TocContext);
327327
const root = useMemo(() => calculateNestedToc(toc), [toc]);
328+
if (root.children.length < 2) {
329+
return null;
330+
}
328331
return <InlineTocItem items={root.children} />;
329332
}
330333

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ export const SandpackConsole = ({visible}: {visible: boolean}) => {
109109
setLogs((prev) => {
110110
const newLogs = message.log
111111
.filter((consoleData) => {
112+
if (!consoleData.method) {
113+
return false;
114+
}
112115
if (
113116
typeof consoleData.data[0] === 'string' &&
114117
consoleData.data[0].indexOf('The above error occurred') !== -1

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ function SandpackRoot(props: SandpackProps) {
7474

7575
files['/styles.css'] = {
7676
code: [sandboxStyle, files['/styles.css']?.code ?? ''].join('\n\n'),
77-
hidden: true,
77+
hidden: !files['/styles.css']?.visible,
7878
};
7979

8080
return (

beta/src/components/Search.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ export function Search({
155155

156156
<button
157157
type="button"
158-
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"
158+
className="hidden md:flex relative pl-4 pr-1 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-md align-middle text-sm"
159159
onClick={onOpen}>
160160
<IconSearch className="mr-3 align-middle text-gray-30 shrink-0 group-betterhover:hover:text-gray-70" />
161161
Search

0 commit comments

Comments
 (0)