Skip to content

Commit 190bd0f

Browse files
authored
Merge branch 'main' into sync-943e3ce4
2 parents ff8f99d + 9d6e639 commit 190bd0f

File tree

121 files changed

+1792
-1209
lines changed

Some content is hidden

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

121 files changed

+1792
-1209
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
"retext": "^7.0.1",
9292
"retext-smartypants": "^4.0.0",
9393
"rss": "^1.2.2",
94-
"tailwindcss": "^3.3.2",
94+
"tailwindcss": "^3.4.1",
9595
"typescript": "^4.0.2",
9696
"unist-util-visit": "^2.0.3",
9797
"webpack-bundle-analyzer": "^4.5.0"

plugins/remark-smartypants.js

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/*!
2+
* Based on 'silvenon/remark-smartypants'
3+
* https://github.com/silvenon/remark-smartypants/pull/80
4+
*/
5+
16
const visit = require('unist-util-visit');
27
const retext = require('retext');
38
const smartypants = require('retext-smartypants');
@@ -9,12 +14,48 @@ function check(parent) {
914
}
1015

1116
module.exports = function (options) {
12-
const processor = retext().use(smartypants, options);
17+
const processor = retext().use(smartypants, {
18+
...options,
19+
// Do not replace ellipses, dashes, backticks because they change string
20+
// length, and we couldn't guarantee right splice of text in second visit of
21+
// tree
22+
ellipses: false,
23+
dashes: false,
24+
backticks: false,
25+
});
26+
27+
const processor2 = retext().use(smartypants, {
28+
...options,
29+
// Do not replace quotes because they are already replaced in the first
30+
// processor
31+
quotes: false,
32+
});
1333

1434
function transformer(tree) {
15-
visit(tree, 'text', (node, index, parent) => {
16-
if (check(parent)) node.value = String(processor.processSync(node.value));
35+
let allText = '';
36+
let startIndex = 0;
37+
const textOrInlineCodeNodes = [];
38+
39+
visit(tree, ['text', 'inlineCode'], (node, _, parent) => {
40+
if (check(parent)) {
41+
if (node.type === 'text') allText += node.value;
42+
// for the case when inlineCode contains just one part of quote: `foo'bar`
43+
else allText += 'A'.repeat(node.value.length);
44+
textOrInlineCodeNodes.push(node);
45+
}
1746
});
47+
48+
// Concat all text into one string, to properly replace quotes around non-"text" nodes
49+
allText = String(processor.processSync(allText));
50+
51+
for (const node of textOrInlineCodeNodes) {
52+
const endIndex = startIndex + node.value.length;
53+
if (node.type === 'text') {
54+
const processedText = allText.slice(startIndex, endIndex);
55+
node.value = String(processor2.processSync(processedText));
56+
}
57+
startIndex = endIndex;
58+
}
1859
}
1960

2061
return transformer;

src/components/DocsFooter.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const DocsPageFooter = memo<DocsPageFooterProps>(
2727
<>
2828
{prevRoute?.path || nextRoute?.path ? (
2929
<>
30-
<div className="max-w-7xl mx-auto grid grid-cols-1 md:grid-cols-2 gap-4 py-4 md:py-12">
30+
<div className="grid grid-cols-1 gap-4 py-4 mx-auto max-w-7xl md:grid-cols-2 md:py-12">
3131
{prevRoute?.path ? (
3232
<FooterLink
3333
type="Previous"
@@ -69,21 +69,23 @@ function FooterLink({
6969
<NextLink
7070
href={href}
7171
className={cn(
72-
'flex gap-x-4 md:gap-x-6 items-center w-full md:w-80 px-4 md:px-5 py-6 border-2 border-transparent text-base leading-base text-link dark:text-link-dark rounded-lg group focus:text-link dark:focus:text-link-dark focus:bg-highlight focus:border-link dark:focus:bg-highlight-dark dark:focus:border-link-dark focus:border-opacity-100 focus:border-2 focus:ring-1 focus:ring-offset-4 focus:ring-blue-40 active:ring-0 active:ring-offset-0 hover:bg-gray-5 dark:hover:bg-gray-80',
72+
'flex gap-x-4 md:gap-x-6 items-center w-full md:min-w-80 md:w-fit md:max-w-md px-4 md:px-5 py-6 border-2 border-transparent text-base leading-base text-link dark:text-link-dark rounded-lg group focus:text-link dark:focus:text-link-dark focus:bg-highlight focus:border-link dark:focus:bg-highlight-dark dark:focus:border-link-dark focus:border-opacity-100 focus:border-2 focus:ring-1 focus:ring-offset-4 focus:ring-blue-40 active:ring-0 active:ring-offset-0 hover:bg-gray-5 dark:hover:bg-gray-80',
7373
{
7474
'flex-row-reverse justify-self-end text-end': type === 'Next',
7575
}
7676
)}>
7777
<IconNavArrow
78-
className="text-tertiary dark:text-tertiary-dark inline group-focus:text-link dark:group-focus:text-link-dark"
78+
className="inline text-tertiary dark:text-tertiary-dark group-focus:text-link dark:group-focus:text-link-dark"
7979
displayDirection={type === 'Previous' ? 'start' : 'end'}
8080
/>
81-
<span>
82-
<span className="block no-underline text-sm tracking-wide text-secondary dark:text-secondary-dark uppercase font-bold group-focus:text-link dark:group-focus:text-link-dark group-focus:text-opacity-100">
81+
<div className="flex flex-col overflow-hidden">
82+
<span className="text-sm font-bold tracking-wide no-underline uppercase text-secondary dark:text-secondary-dark group-focus:text-link dark:group-focus:text-link-dark group-focus:text-opacity-100">
8383
{type}
8484
</span>
85-
<span className="block text-lg group-hover:underline">{title}</span>
86-
</span>
85+
<span className="text-lg break-words group-hover:underline">
86+
{title}
87+
</span>
88+
</div>
8789
</NextLink>
8890
);
8991
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Error Decoder requires reading pregenerated error message from getStaticProps,
2+
// but MDX component doesn't support props. So we use React Context to populate
3+
// the value without prop-drilling.
4+
// TODO: Replace with React.cache + React.use when migrating to Next.js App Router
5+
6+
import {createContext, useContext} from 'react';
7+
8+
const notInErrorDecoderContext = Symbol('not in error decoder context');
9+
10+
export const ErrorDecoderContext = createContext<
11+
| {errorMessage: string | null; errorCode: string | null}
12+
| typeof notInErrorDecoderContext
13+
>(notInErrorDecoderContext);
14+
15+
export const useErrorDecoderParams = () => {
16+
const params = useContext(ErrorDecoderContext);
17+
18+
if (params === notInErrorDecoderContext) {
19+
throw new Error('useErrorDecoder must be used in error decoder pages only');
20+
}
21+
22+
return params;
23+
};

src/components/Icon/IconGitHub.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ export const IconGitHub = memo<JSX.IntrinsicElements['svg']>(
99
return (
1010
<svg
1111
xmlns="http://www.w3.org/2000/svg"
12-
width="1.33em"
13-
height="1.33em"
12+
width="1.5em"
13+
height="1.5em"
1414
viewBox="0 -2 24 24"
1515
fill="currentColor"
1616
{...props}>

src/components/Icon/IconThreads.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*/
4+
5+
import {memo} from 'react';
6+
7+
export const IconThreads = memo<JSX.IntrinsicElements['svg']>(
8+
function IconThreads(props) {
9+
return (
10+
<svg
11+
aria-label="Threads"
12+
viewBox="0 0 192 192"
13+
height="1.40em"
14+
width="1.40em"
15+
fill="currentColor"
16+
xmlns="http://www.w3.org/2000/svg"
17+
{...props}>
18+
<path
19+
className="x19hqcy"
20+
d="M141.537 88.9883C140.71 88.5919 139.87 88.2104 139.019 87.8451C137.537 60.5382 122.616 44.905 97.5619 44.745C97.4484 44.7443 97.3355 44.7443 97.222 44.7443C82.2364 44.7443 69.7731 51.1409 62.102 62.7807L75.881 72.2328C81.6116 63.5383 90.6052 61.6848 97.2286 61.6848C97.3051 61.6848 97.3819 61.6848 97.4576 61.6855C105.707 61.7381 111.932 64.1366 115.961 68.814C118.893 72.2193 120.854 76.925 121.825 82.8638C114.511 81.6207 106.601 81.2385 98.145 81.7233C74.3247 83.0954 59.0111 96.9879 60.0396 116.292C60.5615 126.084 65.4397 134.508 73.775 140.011C80.8224 144.663 89.899 146.938 99.3323 146.423C111.79 145.74 121.563 140.987 128.381 132.296C133.559 125.696 136.834 117.143 138.28 106.366C144.217 109.949 148.617 114.664 151.047 120.332C155.179 129.967 155.42 145.8 142.501 158.708C131.182 170.016 117.576 174.908 97.0135 175.059C74.2042 174.89 56.9538 167.575 45.7381 153.317C35.2355 139.966 29.8077 120.682 29.6052 96C29.8077 71.3178 35.2355 52.0336 45.7381 38.6827C56.9538 24.4249 74.2039 17.11 97.0132 16.9405C119.988 17.1113 137.539 24.4614 149.184 38.788C154.894 45.8136 159.199 54.6488 162.037 64.9503L178.184 60.6422C174.744 47.9622 169.331 37.0357 161.965 27.974C147.036 9.60668 125.202 0.195148 97.0695 0H96.9569C68.8816 0.19447 47.2921 9.6418 32.7883 28.0793C19.8819 44.4864 13.2244 67.3157 13.0007 95.9325L13 96L13.0007 96.0675C13.2244 124.684 19.8819 147.514 32.7883 163.921C47.2921 182.358 68.8816 191.806 96.9569 192H97.0695C122.03 191.827 139.624 185.292 154.118 170.811C173.081 151.866 172.51 128.119 166.26 113.541C161.776 103.087 153.227 94.5962 141.537 88.9883ZM98.4405 129.507C88.0005 130.095 77.1544 125.409 76.6196 115.372C76.2232 107.93 81.9158 99.626 99.0812 98.6368C101.047 98.5234 102.976 98.468 104.871 98.468C111.106 98.468 116.939 99.0737 122.242 100.233C120.264 124.935 108.662 128.946 98.4405 129.507Z"></path>
21+
</svg>
22+
);
23+
}
24+
);

src/components/Layout/Feedback.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import {useState} from 'react';
66
import {useRouter} from 'next/router';
7+
import cn from 'classnames';
78

89
export function Feedback({onSubmit = () => {}}: {onSubmit?: () => void}) {
910
const {asPath} = useRouter();
@@ -60,14 +61,18 @@ function sendGAEvent(isPositive: boolean) {
6061
function SendFeedback({onSubmit}: {onSubmit: () => void}) {
6162
const [isSubmitted, setIsSubmitted] = useState(false);
6263
return (
63-
<div className="max-w-xs w-80 lg:w-auto py-3 shadow-lg rounded-lg m-4 bg-wash dark:bg-gray-95 px-4 flex">
64-
<p className="w-full font-bold text-primary dark:text-primary-dark text-lg me-4">
64+
<div
65+
className={cn(
66+
'max-w-custom-xs w-80 lg:w-auto py-3 shadow-lg rounded-lg m-4 bg-wash dark:bg-gray-95 px-4 flex',
67+
{exit: isSubmitted}
68+
)}>
69+
<p className="w-full text-lg font-bold text-primary dark:text-primary-dark me-4">
6570
{isSubmitted ? 'Thank you for your feedback!' : 'Is this page useful?'}
6671
</p>
6772
{!isSubmitted && (
6873
<button
6974
aria-label="Yes"
70-
className="bg-secondary-button dark:bg-secondary-button-dark rounded-lg text-primary dark:text-primary-dark px-3 me-2"
75+
className="px-3 rounded-lg bg-secondary-button dark:bg-secondary-button-dark text-primary dark:text-primary-dark me-2"
7176
onClick={() => {
7277
setIsSubmitted(true);
7378
onSubmit();
@@ -79,7 +84,7 @@ function SendFeedback({onSubmit}: {onSubmit: () => void}) {
7984
{!isSubmitted && (
8085
<button
8186
aria-label="No"
82-
className="bg-secondary-button dark:bg-secondary-button-dark rounded-lg text-primary dark:text-primary-dark px-3"
87+
className="px-3 rounded-lg bg-secondary-button dark:bg-secondary-button-dark text-primary dark:text-primary-dark"
8388
onClick={() => {
8489
setIsSubmitted(true);
8590
onSubmit();

src/components/Layout/HomeContent.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1499,7 +1499,7 @@ function ConferenceLayout({conf, children}) {
14991499
navigate(e.target.value);
15001500
});
15011501
}}
1502-
className="appearance-none pe-8 bg-transparent text-primary-dark text-2xl font-bold mb-0.5"
1502+
className="appearance-none pe-8 ps-2 bg-transparent text-primary-dark text-2xl font-bold mb-0.5"
15031503
style={{
15041504
backgroundSize: '4px 4px, 4px 4px',
15051505
backgroundRepeat: 'no-repeat',
@@ -1508,8 +1508,16 @@ function ConferenceLayout({conf, children}) {
15081508
backgroundImage:
15091509
'linear-gradient(45deg,transparent 50%,currentColor 50%),linear-gradient(135deg,currentColor 50%,transparent 50%)',
15101510
}}>
1511-
<option value="react-conf-2021">React Conf 2021</option>
1512-
<option value="react-conf-2019">React Conf 2019</option>
1511+
<option
1512+
className="bg-wash dark:bg-wash-dark text-primary dark:text-primary-dark"
1513+
value="react-conf-2021">
1514+
React Conf 2021
1515+
</option>
1516+
<option
1517+
className="bg-wash dark:bg-wash-dark text-primary dark:text-primary-dark"
1518+
value="react-conf-2019">
1519+
React Conf 2019
1520+
</option>
15131521
</select>
15141522
</Cover>
15151523
<div className="px-4 pb-4" key={conf.id}>

src/components/Layout/Page.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ export function Page({children, toc, routeTree, meta, section}: PageProps) {
130130
)}>
131131
{showSidebar && (
132132
<div className="lg:-mt-16">
133-
<div className="lg:pt-16 fixed lg:sticky top-0 start-0 end-0 py-0 shadow lg:shadow-none">
133+
<div className="fixed top-0 py-0 shadow lg:pt-16 lg:sticky start-0 end-0 lg:shadow-none">
134134
<SidebarNav
135135
key={section}
136136
routeTree={routeTree}
@@ -143,7 +143,7 @@ export function Page({children, toc, routeTree, meta, section}: PageProps) {
143143
<Suspense fallback={null}>
144144
<main className="min-w-0 isolate">
145145
<article
146-
className="break-words font-normal text-primary dark:text-primary-dark"
146+
className="font-normal break-words text-primary dark:text-primary-dark"
147147
key={asPath}>
148148
{content}
149149
</article>
@@ -153,14 +153,14 @@ export function Page({children, toc, routeTree, meta, section}: PageProps) {
153153
isHomePage && 'bg-wash dark:bg-gray-95 mt-[-1px]'
154154
)}>
155155
{!isHomePage && (
156-
<div className="mx-auto w-full px-5 sm:px-12 md:px-12 pt-10 md:pt-12 lg:pt-10">
156+
<div className="w-full px-5 pt-10 mx-auto sm:px-12 md:px-12 md:pt-12 lg:pt-10">
157157
{
158-
<hr className="max-w-7xl mx-auto border-border dark:border-border-dark" />
158+
<hr className="mx-auto max-w-7xl border-border dark:border-border-dark" />
159159
}
160160
{showSurvey && (
161161
<>
162-
<div className="flex flex-col items-center m-4 p-4">
163-
<p className="font-bold text-primary dark:text-primary-dark text-lg mb-4">
162+
<div className="flex flex-col items-center p-4 m-4">
163+
<p className="mb-4 text-lg font-bold text-primary dark:text-primary-dark">
164164
How do you like these docs?
165165
</p>
166166
<div>
@@ -178,7 +178,7 @@ export function Page({children, toc, routeTree, meta, section}: PageProps) {
178178
</ButtonLink>
179179
</div>
180180
</div>
181-
<hr className="max-w-7xl mx-auto border-border dark:border-border-dark" />
181+
<hr className="mx-auto max-w-7xl border-border dark:border-border-dark" />
182182
</>
183183
)}
184184
</div>
@@ -193,7 +193,7 @@ export function Page({children, toc, routeTree, meta, section}: PageProps) {
193193
</div>
194194
</main>
195195
</Suspense>
196-
<div className="-mt-16 hidden lg:max-w-xs 2xl:block">
196+
<div className="hidden -mt-16 lg:max-w-custom-xs 2xl:block">
197197
{showToc && toc.length > 0 && <Toc headings={toc} key={asPath} />}
198198
</div>
199199
</div>

src/components/Layout/SidebarNav/SidebarNav.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ export default function SidebarNav({
4040
}}>
4141
<aside
4242
className={cn(
43-
`lg:grow flex-col w-full pb-8 lg:pb-0 lg:max-w-xs z-10 hidden lg:block`
43+
`lg:grow flex-col w-full pb-8 lg:pb-0 lg:max-w-custom-xs z-10 hidden lg:block`
4444
)}>
4545
<nav
4646
role="navigation"
4747
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)
48-
className="w-full lg:h-auto grow pe-0 lg:pe-5 pt-6 lg:pb-16 md:pt-4 lg:pt-4 scrolling-touch scrolling-gpu">
48+
className="w-full pt-6 scrolling-touch lg:h-auto grow pe-0 lg:pe-5 lg:pb-16 md:pt-4 lg:pt-4 scrolling-gpu">
4949
{/* No fallback UI so need to be careful not to suspend directly inside. */}
5050
<Suspense fallback={null}>
5151
<SidebarRouteTree

0 commit comments

Comments
 (0)