Skip to content

Commit

Permalink
docs(en): merge reactjs.org/main into zh-hans.reactjs.org/main @ a2f8ff3
Browse files Browse the repository at this point in the history
  • Loading branch information
awxiaoxian2020 authored May 2, 2024
2 parents 89068d5 + 989f6b9 commit f0cddbe
Show file tree
Hide file tree
Showing 73 changed files with 3,195 additions and 212 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,6 @@ yarn-error.log*

# external fonts
public/fonts/**/Optimistic_*.woff2

# rss
public/rss.xml
4 changes: 3 additions & 1 deletion colors.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = {
tertiary: '#5E687E', // gray-50
'tertiary-dark': '#99A1B3', // gray-30
link: '#087EA4', // blue-50
'link-dark': '#149ECA', // blue-40
'link-dark': '#58C4DC', // blue-40
syntax: '#EBECF0', // gray-10
wash: '#FFFFFF',
'wash-dark': '#23272F', // gray-90
Expand All @@ -23,6 +23,8 @@ module.exports = {
'border-dark': '#343A46', // gray-80
'secondary-button': '#EBECF0', // gray-10
'secondary-button-dark': '#404756', // gray-70
brand: '#087EA4', // blue-40
'brand-dark': '#58C4DC', // blue-40

// Gray
'gray-95': '#16181D',
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
"prettier:diff": "yarn nit:source",
"lint-heading-ids": "node scripts/headingIdLinter.js",
"fix-headings": "node scripts/headingIdLinter.js --fix",
"ci-check": "npm-run-all prettier:diff --parallel lint tsc lint-heading-ids",
"ci-check": "npm-run-all prettier:diff --parallel lint tsc lint-heading-ids rss",
"tsc": "tsc --noEmit",
"start": "next start",
"postinstall": "patch-package && (is-ci || husky install .husky)",
"check-all": "npm-run-all prettier lint:fix tsc"
"check-all": "npm-run-all prettier lint:fix tsc rss",
"rss": "node scripts/generateRss.js"
},
"dependencies": {
"@codesandbox/sandpack-react": "2.13.5",
Expand Down
Binary file added public/android-chrome-192x192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/android-chrome-384x384.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/android-chrome-512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/apple-touch-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions public/browserconfig.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<browserconfig>
<msapplication>
<tile>
<square150x150logo src="/mstile-150x150.png"/>
<TileColor>#2b5797</TileColor>
</tile>
</msapplication>
</browserconfig>
Binary file added public/favicon-16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/favicon-32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/favicon.ico
Binary file not shown.
Binary file added public/favicon_old.ico
Binary file not shown.
Binary file modified public/images/team/lauren.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/uwu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/mstile-150x150.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
60 changes: 60 additions & 0 deletions public/safari-pinned-tab.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions public/site.webmanifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "React",
"short_name": "React",
"icons": [
{
"src": "/android-chrome-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "/android-chrome-384x384.png",
"sizes": "384x384",
"type": "image/png"
}
],
"theme_color": "#23272f",
"background_color": "#23272f",
"display": "standalone"
}
6 changes: 6 additions & 0 deletions scripts/generateRss.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*/
const {generateRssFeed} = require('../src/utils/rss');

generateRssFeed();
3 changes: 2 additions & 1 deletion src/components/ButtonLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ function ButtonLink({
className,
'active:scale-[.98] transition-transform inline-flex font-bold items-center outline-none focus:outline-none focus-visible:outline focus-visible:outline-link focus:outline-offset-2 focus-visible:dark:focus:outline-link-dark leading-snug',
{
'bg-link text-white hover:bg-opacity-80': type === 'primary',
'bg-link text-white dark:bg-brand-dark dark:text-secondary hover:bg-opacity-80':
type === 'primary',
'text-primary dark:text-primary-dark shadow-secondary-button-stroke dark:shadow-secondary-button-stroke-dark hover:bg-gray-40/5 active:bg-gray-40/10 hover:dark:bg-gray-60/5 active:dark:bg-gray-60/10':
type === 'secondary',
'text-lg py-3 rounded-full px-4 sm:px-6': size === 'lg',
Expand Down
24 changes: 24 additions & 0 deletions src/components/Layout/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,30 @@ export function Footer() {
dir="ltr">
&copy;{new Date().getFullYear()}
</div>
<div
className="uwu-visible text-xs cursor-pointer hover:text-link hover:dark:text-link-dark hover:underline"
onClick={() => {
// @ts-ignore
window.__setUwu(false);
}}>
no uwu plz
</div>
<div
className="uwu-hidden text-xs cursor-pointer hover:text-link hover:dark:text-link-dark hover:underline"
onClick={() => {
// @ts-ignore
window.__setUwu(true);
}}>
uwu?
</div>
<div className="uwu-visible text-xs">
Logo by
<ExternalLink
className="ms-1"
href="https://twitter.com/sawaratsuki1004">
@sawaratsuki1004
</ExternalLink>
</div>
</div>
<div className="flex flex-col">
<FooterLink href="/learn" isHeader={true}>
Expand Down
28 changes: 24 additions & 4 deletions src/components/Layout/HomeContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import Link from 'components/MDX/Link';
import CodeBlock from 'components/MDX/CodeBlock';
import {ExternalLink} from 'components/ExternalLink';
import sidebarBlog from '../../sidebarBlog.json';
import * as React from 'react';
import Image from 'next/image';

function Section({children, background = null}) {
return (
Expand Down Expand Up @@ -115,12 +117,22 @@ export function HomeContent() {
<>
<div className="ps-0">
<div className="mx-5 mt-12 lg:mt-24 mb-20 lg:mb-32 flex flex-col justify-center">
<div className="uwu-visible flex justify-center">
<Image
alt="logo by @sawaratsuki1004"
title="logo by @sawaratsuki1004"
loading="eager"
width={313}
height={160}
src="/images/uwu.png"
/>
</div>
<Logo
className={cn(
'mt-4 mb-3 text-link dark:text-link-dark w-24 lg:w-28 self-center text-sm me-0 flex origin-center transition-all ease-in-out'
'uwu-hidden mt-4 mb-3 text-brand dark:text-brand-dark w-24 lg:w-28 self-center text-sm me-0 flex origin-center transition-all ease-in-out'
)}
/>
<h1 className="text-5xl font-display lg:text-6xl self-center flex font-semibold leading-snug text-primary dark:text-primary-dark">
<h1 className="uwu-hidden text-5xl font-display lg:text-6xl self-center flex font-semibold leading-snug text-primary dark:text-primary-dark">
React
</h1>
<p className="text-4xl font-display max-w-lg md:max-w-full py-1 text-center text-secondary dark:text-primary-dark leading-snug self-center">
Expand Down Expand Up @@ -470,7 +482,15 @@ export function HomeContent() {
</div>

<div className="mt-20 px-5 lg:px-0 mb-6 max-w-4xl text-center text-opacity-80">
<Logo className="text-link dark:text-link-dark w-24 lg:w-28 mb-10 lg:mb-8 mt-12 h-auto mx-auto self-start" />
<div className="uwu-visible flex justify-center">
<img
alt="logo by @sawaratsuki1004"
title="logo by @sawaratsuki1004"
className="uwu-visible mb-10 lg:mb-8 h-24 lg:h-32"
src="/images/uwu.png"
/>
</div>
<Logo className="uwu-hidden text-brand dark:text-brand-dark w-24 lg:w-28 mb-10 lg:mb-8 mt-12 h-auto mx-auto self-start" />
<Header>
欢迎来到 <br className="hidden lg:inline" />
React 社区
Expand Down Expand Up @@ -1601,7 +1621,7 @@ function Thumbnail({video}) {
</div>
<div className="mt-1">
<span className="inline-flex text-xs font-normal items-center text-primary-dark py-1 whitespace-nowrap outline-link px-1.5 rounded-lg">
<Logo className="text-xs me-1 w-4 h-4 text-link-dark" />
<Logo className="text-xs me-1 w-4 h-4 text-brand text-brand-dark" />
React Conf
</span>
</div>
Expand Down
28 changes: 26 additions & 2 deletions src/components/Layout/Page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ import {IconNavArrow} from 'components/Icon/IconNavArrow';
import PageHeading from 'components/PageHeading';
import {getRouteMeta} from './getRouteMeta';
import {TocContext} from '../MDX/TocContext';
import {Languages, LanguagesContext} from '../MDX/LanguagesContext';
import type {TocItem} from 'components/MDX/TocContext';
import type {RouteItem} from 'components/Layout/getRouteMeta';
import {HomeContent} from './HomeContent';
import {TopNav} from './TopNav';
import cn from 'classnames';
import Head from 'next/head';

import(/* webpackPrefetch: true */ '../MDX/CodeBlock/CodeBlock');

Expand All @@ -35,9 +37,17 @@ interface PageProps {
description?: string;
};
section: 'learn' | 'reference' | 'community' | 'blog' | 'home' | 'unknown';
languages?: Languages | null;
}

export function Page({children, toc, routeTree, meta, section}: PageProps) {
export function Page({
children,
toc,
routeTree,
meta,
section,
languages = null,
}: PageProps) {
const {asPath} = useRouter();
const cleanedPath = asPath.split(/[\?\#]/)[0];
const {route, nextRoute, prevRoute, breadcrumbs, order} = getRouteMeta(
Expand Down Expand Up @@ -74,7 +84,11 @@ export function Page({children, toc, routeTree, meta, section}: PageProps) {
'max-w-7xl mx-auto',
section === 'blog' && 'lg:flex lg:flex-col lg:items-center'
)}>
<TocContext.Provider value={toc}>{children}</TocContext.Provider>
<TocContext.Provider value={toc}>
<LanguagesContext.Provider value={languages}>
{children}
</LanguagesContext.Provider>
</TocContext.Provider>
</div>
{!isBlogIndex && (
<DocsPageFooter
Expand Down Expand Up @@ -117,6 +131,16 @@ export function Page({children, toc, routeTree, meta, section}: PageProps) {
image={`/images/og-` + section + '.png'}
searchOrder={searchOrder}
/>
{(isHomePage || isBlogIndex) && (
<Head>
<link
rel="alternate"
type="application/rss+xml"
title="React Blog RSS Feed"
href="/rss.xml"
/>
</Head>
)}
{/* <SocialBanner /> */}
<TopNav
section={section}
Expand Down
9 changes: 7 additions & 2 deletions src/components/Layout/Sidebar/SidebarRouteTree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {SidebarLink} from './SidebarLink';
import {useCollapse} from 'react-collapsed';
import usePendingRoute from 'hooks/usePendingRoute';
import type {RouteItem} from 'components/Layout/getRouteMeta';
import {siteConfig} from 'siteConfig';

interface SidebarRouteTreeProps {
isForceExpanded: boolean;
Expand Down Expand Up @@ -150,8 +151,12 @@ export function SidebarRouteTree({
);
}
if (hasSectionHeader) {
let sectionHeaderText =
sectionHeader != null
? sectionHeader.replace('{{version}}', siteConfig.version)
: '';
return (
<Fragment key={`${sectionHeader}-${level}-separator`}>
<Fragment key={`${sectionHeaderText}-${level}-separator`}>
{index !== 0 && (
<li
role="separator"
Expand All @@ -163,7 +168,7 @@ export function SidebarRouteTree({
'mb-1 text-sm font-bold ms-5 text-tertiary dark:text-tertiary-dark',
index !== 0 && 'mt-2'
)}>
{sectionHeader}
{sectionHeaderText}
</h3>
</Fragment>
);
Expand Down
Loading

0 comments on commit f0cddbe

Please sign in to comment.