Skip to content

Commit d3a22a9

Browse files
committed
Update dependencies in package.json and yarn.lock; remove unused components and files from the project.
1 parent 22088c3 commit d3a22a9

28 files changed

+363
-104
lines changed

cnwebsite/core/DocsRating.tsx

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
import React, {useState} from 'react';
9+
import useIsBrowser from '@docusaurus/useIsBrowser';
10+
11+
const DocsRating = ({label}) => {
12+
const isBrowser = useIsBrowser();
13+
const [haveVoted, setHaveVoted] = useState(false);
14+
15+
if (!isBrowser) {
16+
return null;
17+
}
18+
19+
const giveFeedback = value => {
20+
if (window.ga) {
21+
window.ga('send', {
22+
hitType: 'event',
23+
eventCategory: 'button',
24+
eventAction: 'feedback',
25+
eventLabel: label,
26+
eventValue: value,
27+
});
28+
}
29+
setHaveVoted(true);
30+
};
31+
32+
return (
33+
<div className="docsRating">
34+
{haveVoted ? (
35+
'Thanks for letting us know!'
36+
) : (
37+
<>
38+
Is this page useful?
39+
<svg
40+
className="i_thumbsup"
41+
aria-label="Like"
42+
onClick={() => giveFeedback(1)}
43+
xmlns="http://www.w3.org/2000/svg"
44+
viewBox="0 0 81.13 89.76">
45+
<path d="M22.9 6a18.57 18.57 0 002.67 8.4 25.72 25.72 0 008.65 7.66c3.86 2 8.67 7.13 13.51 11 3.86 3.11 8.57 7.11 11.54 8.45s13.59.26 14.64 1.17c1.88 1.63 1.55 9-.11 15.25-1.61 5.86-5.96 10.55-6.48 16.86-.4 4.83-2.7 4.88-10.93 4.88h-1.35c-3.82 0-8.24 2.93-12.92 3.62a68 68 0 01-9.73.5c-3.57 0-7.86-.08-13.25-.08-3.56 0-4.71-1.83-4.71-4.48h8.42a3.51 3.51 0 000-7H12.28a2.89 2.89 0 01-2.88-2.88 1.91 1.91 0 01.77-1.78h16.46a3.51 3.51 0 000-7H12.29c-3.21 0-4.84-1.83-4.84-4a6.41 6.41 0 011.17-3.78h19.06a3.5 3.5 0 100-7H9.75A3.51 3.51 0 016 42.27a3.45 3.45 0 013.75-3.48h13.11c5.61 0 7.71-3 5.71-5.52-4.43-4.74-10.84-12.62-11-18.71-.15-6.51 2.6-7.83 5.36-8.56m0-6a6.18 6.18 0 00-1.53.2c-6.69 1.77-10 6.65-9.82 14.5.08 5.09 2.99 11.18 8.52 18.09H9.74a9.52 9.52 0 00-6.23 16.9 12.52 12.52 0 00-2.07 6.84 9.64 9.64 0 003.65 7.7 7.85 7.85 0 00-1.7 5.13 8.9 8.9 0 005.3 8.13 6 6 0 00-.26 1.76c0 6.37 4.2 10.48 10.71 10.48h13.25a73.75 73.75 0 0010.6-.56 35.89 35.89 0 007.58-2.18 17.83 17.83 0 014.48-1.34h1.35c4.69 0 7.79 0 10.5-1 3.85-1.44 6-4.59 6.41-9.38.2-2.46 1.42-4.85 2.84-7.62a41.3 41.3 0 003.42-8.13 48 48 0 001.59-10.79c.1-5.13-1-8.48-3.35-10.55-2.16-1.87-4.64-1.87-9.6-1.88a46.86 46.86 0 01-6.64-.29c-1.92-.94-5.72-4-8.51-6.3l-1.58-1.28c-1.6-1.3-3.27-2.79-4.87-4.23-3.33-3-6.47-5.79-9.61-7.45a20.2 20.2 0 01-6.43-5.53 12.44 12.44 0 01-1.72-5.36 6 6 0 00-6-5.86z" />
46+
</svg>
47+
<svg
48+
className="i_thumbsdown"
49+
aria-label="Dislike"
50+
onClick={() => giveFeedback(0)}
51+
xmlns="http://www.w3.org/2000/svg"
52+
viewBox="0 0 81.13 89.76">
53+
<path d="M22.9 6a18.57 18.57 0 002.67 8.4 25.72 25.72 0 008.65 7.66c3.86 2 8.67 7.13 13.51 11 3.86 3.11 8.57 7.11 11.54 8.45s13.59.26 14.64 1.17c1.88 1.63 1.55 9-.11 15.25-1.61 5.86-5.96 10.55-6.48 16.86-.4 4.83-2.7 4.88-10.93 4.88h-1.35c-3.82 0-8.24 2.93-12.92 3.62a68 68 0 01-9.73.5c-3.57 0-7.86-.08-13.25-.08-3.56 0-4.71-1.83-4.71-4.48h8.42a3.51 3.51 0 000-7H12.28a2.89 2.89 0 01-2.88-2.88 1.91 1.91 0 01.77-1.78h16.46a3.51 3.51 0 000-7H12.29c-3.21 0-4.84-1.83-4.84-4a6.41 6.41 0 011.17-3.78h19.06a3.5 3.5 0 100-7H9.75A3.51 3.51 0 016 42.27a3.45 3.45 0 013.75-3.48h13.11c5.61 0 7.71-3 5.71-5.52-4.43-4.74-10.84-12.62-11-18.71-.15-6.51 2.6-7.83 5.36-8.56m0-6a6.18 6.18 0 00-1.53.2c-6.69 1.77-10 6.65-9.82 14.5.08 5.09 2.99 11.18 8.52 18.09H9.74a9.52 9.52 0 00-6.23 16.9 12.52 12.52 0 00-2.07 6.84 9.64 9.64 0 003.65 7.7 7.85 7.85 0 00-1.7 5.13 8.9 8.9 0 005.3 8.13 6 6 0 00-.26 1.76c0 6.37 4.2 10.48 10.71 10.48h13.25a73.75 73.75 0 0010.6-.56 35.89 35.89 0 007.58-2.18 17.83 17.83 0 014.48-1.34h1.35c4.69 0 7.79 0 10.5-1 3.85-1.44 6-4.59 6.41-9.38.2-2.46 1.42-4.85 2.84-7.62a41.3 41.3 0 003.42-8.13 48 48 0 001.59-10.79c.1-5.13-1-8.48-3.35-10.55-2.16-1.87-4.64-1.87-9.6-1.88a46.86 46.86 0 01-6.64-.29c-1.92-.94-5.72-4-8.51-6.3l-1.58-1.28c-1.6-1.3-3.27-2.79-4.87-4.23-3.33-3-6.47-5.79-9.61-7.45a20.2 20.2 0 01-6.43-5.53 12.44 12.44 0 01-1.72-5.36 6 6 0 00-6-5.86z" />
54+
</svg>
55+
</>
56+
)}
57+
</div>
58+
);
59+
};
60+
61+
export default DocsRating;

cnwebsite/core/PlatformTag.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import React from 'react';
2+
3+
const PlatformTag = ({platform}) => {
4+
const platformLabel = platform === 'ios' ? 'iOS' : 'Android';
5+
return (
6+
<div
7+
className={`label ${platform}`}
8+
title={`This section is related to ${platformLabel} platform`}>
9+
{platformLabel}
10+
</div>
11+
);
12+
};
13+
14+
export default PlatformTag;
Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
const theme = {
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
import type {ThemeConfig} from '@docusaurus/preset-classic';
9+
10+
const theme: ThemeConfig['prism']['theme'] = {
211
plain: {
312
color: '#FFFFFF',
413
backgroundColor: '#282C34',
@@ -116,4 +125,4 @@ const theme = {
116125
],
117126
};
118127

119-
module.exports = theme;
128+
export default theme;

cnwebsite/core/RNRepoLink.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import A from '@theme/MDXComponents/A';
2+
import type {ComponentProps} from 'react';
3+
import {getTemplateBranchNameForCurrentVersion} from '../src/getTemplateBranchNameForCurrentVersion';
4+
5+
type Props = ComponentProps<'a'>;
6+
7+
export default function RNRepoLink({href, children, ...rest}: Props) {
8+
return (
9+
<A
10+
href={`https://github.com/facebook/react-native/blob/${getTemplateBranchNameForCurrentVersion()}/${href.startsWith('/') ? href.slice(1) : href}`}
11+
{...rest}>
12+
{children}
13+
</A>
14+
);
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import A from '@theme/MDXComponents/A';
2+
import type {ComponentProps} from 'react';
3+
import {getTemplateBranchNameForCurrentVersion} from '../src/getTemplateBranchNameForCurrentVersion';
4+
5+
type Props = ComponentProps<'a'>;
6+
7+
export default function RNTemplateRepoLink({href, children, ...rest}: Props) {
8+
return (
9+
<A
10+
href={`https://github.com/react-native-community/template/blob/${getTemplateBranchNameForCurrentVersion()}/${href.startsWith('/') ? href.slice(1) : href}`}
11+
{...rest}>
12+
{children}
13+
</A>
14+
);
15+
}
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
import React, {useState} from 'react';
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
import React from 'react';
29

310
import CodeBlock from '@theme/CodeBlock';
411

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ const isWindows = ExecutionEnvironment.canUseDOM
1515
: false;
1616

1717
const syntax = [
18-
{label: '函数式组件', value: 'functional'},
19-
{label: 'Class 组件', value: 'classical'},
18+
{label: 'Function Component', value: 'functional'},
19+
{label: 'Class Component', value: 'classical'},
2020
];
2121
const defaultSyntax = 'functional';
2222

@@ -58,10 +58,10 @@ const jsDebuggers = [
5858
const defaultJsDebugger = 'flipper';
5959

6060
const guides = [
61-
{label: '完整原生环境', value: 'native'},
62-
{label: '简易沙盒环境', value: 'quickstart'},
61+
{label: 'Expo Go Quickstart', value: 'quickstart'},
62+
{label: 'React Native CLI Quickstart', value: 'native'},
6363
];
64-
const defaultGuide = 'native';
64+
const defaultGuide = 'quickstart';
6565

6666
const platforms = [
6767
{label: 'Android', value: 'android'},

cnwebsite/modules/snackPlayerInitializer.js renamed to cnwebsite/modules/snackPlayerInitializer.ts

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ export default (() => {
1515
const updateSnacksTheme = () => {
1616
const theme = document.querySelector('html').dataset.theme;
1717
document.querySelectorAll('.snack-player').forEach(snack => {
18-
snack.dataset.snackTheme = theme;
18+
(snack as HTMLElement).dataset.snackTheme = theme;
1919
});
2020
};
2121

2222
const initSnackPlayers = () => {
2323
updateSnacksTheme();
24-
window.ExpoSnack && window.ExpoSnack.initialize();
24+
window?.ExpoSnack?.initialize();
2525
};
2626

2727
const setupTabPanelsMutationObservers = () => {
@@ -53,8 +53,8 @@ export default (() => {
5353
if ('ExpoSnack' in window) {
5454
document.querySelectorAll('.snack-player').forEach(container => {
5555
updateSnacksTheme();
56-
window.ExpoSnack && window.ExpoSnack.remove(container);
57-
window.ExpoSnack && window.ExpoSnack.append(container);
56+
window?.ExpoSnack?.remove(container);
57+
window?.ExpoSnack?.append(container);
5858
});
5959
}
6060
}).observe(document.getElementsByTagName('html')[0], {
@@ -65,13 +65,34 @@ export default (() => {
6565
});
6666
};
6767

68+
const setupSnackObserver = () => {
69+
const observer = new MutationObserver(() => {
70+
const snacks = document.body.querySelectorAll('.snack-player');
71+
72+
if (snacks.length) {
73+
initSnackPlayers();
74+
}
75+
});
76+
77+
// Homepage or Showcase pages does not use MDX content, so `.container` node is not present there
78+
const mdxContentContainer = document.body.querySelector('.container');
79+
if (mdxContentContainer) {
80+
observer.observe(mdxContentContainer, {
81+
childList: true,
82+
subtree: true,
83+
});
84+
}
85+
};
86+
6887
// Need to set the theme before the snack script (deferred) initialize
6988
updateSnacksTheme();
89+
setupSnackObserver();
7090
setupThemeSynchronization();
7191

7292
return {
7393
onRouteDidUpdate() {
7494
initSnackPlayers();
95+
setupSnackObserver();
7596
setupTabPanelsMutationObservers();
7697
},
7798
};

0 commit comments

Comments
 (0)