Skip to content

Commit e280c48

Browse files
authored
Merge pull request #239 from reactjs/sync-80c16779
Sync with reactjs.org @ 80c1677
2 parents 94b9f9b + 1ba42b0 commit e280c48

File tree

9 files changed

+4374
-3075
lines changed

9 files changed

+4374
-3075
lines changed

Diff for: content/community/examples.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ There are many example projects created by the React community. We're keeping th
1010

1111
If you add a project, please commit to keeping it up to date with the latest versions of React.
1212

13-
## Small Examples
13+
## Small Examples {#small-examples}
1414

1515
* **[Calculator](https://github.com/ahfarmer/calculator)** Implementation of the iOS calculator built in React
1616
* **[Emoji Search](https://github.com/ahfarmer/emoji-search)** React app for searching emoji
@@ -20,6 +20,6 @@ If you add a project, please commit to keeping it up to date with the latest ver
2020
* **[Counter App](https://github.com/arnab-datta/counter-app)** A small shopping cart example
2121
* **[Tutorial Solutions](https://github.com/harman052/react-tutorial-solutions)** Solutions to challenges mentioned at the end of React tutorial
2222

23-
## Complete Apps
23+
## Complete Apps {#complete-apps}
2424

2525
* **[Builder Book](https://github.com/builderbook/builderbook)** Open-source web app to write and host documentation or sell books. Built with React, Material-UI, Next, Express, Mongoose, MongoDB

Diff for: flow-typed/gatsby-plugin-google-analytics.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*/
4+
5+
declare module 'gatsby-plugin-google-analytics' {
6+
declare module.exports: {
7+
trackCustomEvent: (...params: any) => void,
8+
};
9+
}

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"unist-util-visit": "^1.1.3"
5959
},
6060
"engines": {
61-
"node": "12.x.x",
61+
"node": "12.x.x || 14.x.x",
6262
"yarn": "^1.3.2"
6363
},
6464
"homepage": "https://ko.reactjs.org/",

Diff for: src/components/FeedbackForm/FeedbackForm.js

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*
4+
* @emails react-core
5+
* @flow
6+
*/
7+
8+
// $FlowExpectedError
9+
import React, {useState} from 'react';
10+
import {trackCustomEvent} from 'gatsby-plugin-google-analytics';
11+
import {sharedStyles} from 'theme';
12+
13+
const FeedbackForm = () => {
14+
const [feedbackGiven, setFeedbackGiven] = useState(false);
15+
16+
if (feedbackGiven) {
17+
return 'Thanks for letting us know!';
18+
} else {
19+
return (
20+
<span>
21+
Is this page useful?
22+
<button
23+
css={[sharedStyles.articleLayout.feedbackButton, {marginLeft: '6px'}]}
24+
aria-label="Yes"
25+
onClick={e => {
26+
e.preventDefault();
27+
trackCustomEvent({
28+
category: 'Feedback Button',
29+
action: 'feedback',
30+
label: window.location.pathname,
31+
value: 1,
32+
});
33+
setFeedbackGiven(true);
34+
}}>
35+
<svg
36+
css={{
37+
transform: 'translateY(0.1em)',
38+
}}
39+
focusable="false"
40+
xmlns="http://www.w3.org/2000/svg"
41+
viewBox="0 0 81.13 89.76">
42+
<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" />
43+
</svg>
44+
</button>
45+
<button
46+
css={[sharedStyles.articleLayout.feedbackButton, {marginLeft: '3px'}]}
47+
aria-label="No"
48+
onClick={e => {
49+
e.preventDefault();
50+
trackCustomEvent({
51+
category: 'Feedback Button',
52+
action: 'feedback',
53+
label: window.location.pathname,
54+
value: 0,
55+
});
56+
}}>
57+
<svg
58+
css={{
59+
transform: 'scale(-1, -1) translateY(-.6em)',
60+
}}
61+
xmlns="http://www.w3.org/2000/svg"
62+
viewBox="0 0 81.13 89.76">
63+
<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" />
64+
</svg>
65+
</button>
66+
</span>
67+
);
68+
}
69+
};
70+
71+
export default FeedbackForm;

Diff for: src/components/FeedbackForm/index.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*
4+
* @emails react-core
5+
*/
6+
7+
import FeedbackForm from './FeedbackForm';
8+
9+
export default FeedbackForm;

Diff for: src/components/MarkdownPage/MarkdownPage.js

+13
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ import NavigationFooter from 'templates/components/NavigationFooter';
1212
import React from 'react';
1313
import StickyResponsiveSidebar from 'components/StickyResponsiveSidebar';
1414
import TitleAndMetaTags from 'components/TitleAndMetaTags';
15+
import FeedbackForm from 'components/FeedbackForm';
1516
import findSectionForPath from 'utils/findSectionForPath';
1617
import toCommaSeparatedList from 'utils/toCommaSeparatedList';
1718
import {sharedStyles} from 'theme';
1819
import createCanonicalUrl from 'utils/createCanonicalUrl';
20+
import {colors} from 'theme';
1921

2022
import type {Node} from 'types';
2123

@@ -74,6 +76,7 @@ const MarkdownPage = ({
7476
}}>
7577
<TitleAndMetaTags
7678
ogDescription={ogDescription}
79+
ogType="article"
7780
canonicalUrl={createCanonicalUrl(markdownRemark.fields.slug)}
7881
title={`${titlePrefix}${titlePostfix}`}
7982
/>
@@ -113,6 +116,16 @@ const MarkdownPage = ({
113116

114117
{markdownRemark.fields.path && (
115118
<div css={{marginTop: 80}}>
119+
<span
120+
css={{
121+
whiteSpace: 'nowrap',
122+
paddingBottom: '1em',
123+
marginRight: '36px',
124+
display: 'inline-block',
125+
color: colors.subtle,
126+
}}>
127+
<FeedbackForm />
128+
</span>
116129
<a
117130
css={sharedStyles.articleLayout.editLink}
118131
href={`https://github.com/reactjs/ko.reactjs.org/tree/master/${markdownRemark.fields.path}`}>

Diff for: src/components/TitleAndMetaTags/TitleAndMetaTags.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ type Props = {
1717
title: string,
1818
ogDescription: string,
1919
canonicalUrl: string,
20+
ogType: string,
2021
};
2122

2223
// only provide alternate links to pages in languages where 95-100% of core content has been translated
@@ -45,11 +46,16 @@ const defaultPage = canonicalUrl => {
4546
return canonicalUrl.replace(urlRoot, 'https://reactjs.org');
4647
};
4748

48-
const TitleAndMetaTags = ({title, ogDescription, canonicalUrl}: Props) => {
49+
const TitleAndMetaTags = ({
50+
title,
51+
ogDescription,
52+
canonicalUrl,
53+
ogType = 'website',
54+
}: Props) => {
4955
return (
5056
<Helmet title={title}>
5157
<meta property="og:title" content={title} />
52-
<meta property="og:type" content="website" />
58+
<meta property="og:type" content={ogType} />
5359
{canonicalUrl && <meta property="og:url" content={canonicalUrl} />}
5460
<meta property="og:image" content="https://reactjs.org/logo-og.png" />
5561
<meta

Diff for: src/theme.js

+31-5
Original file line numberDiff line numberDiff line change
@@ -168,20 +168,46 @@ const sharedStyles = {
168168
zIndex: 2,
169169
},
170170
},
171-
171+
feedbackButton: {
172+
border: 0,
173+
background: 'none',
174+
cursor: 'pointer',
175+
':focus': {
176+
color: colors.text,
177+
borderColor: colors.text,
178+
'& svg': {
179+
fill: colors.text,
180+
},
181+
},
182+
':hover': {
183+
color: colors.text,
184+
borderColor: colors.text,
185+
'& svg': {
186+
fill: colors.text,
187+
},
188+
},
189+
'& svg': {
190+
height: '1.5em',
191+
width: '1.5em',
192+
fill: colors.subtle,
193+
transition: 'fill 0.2s ease',
194+
},
195+
},
172196
editLink: {
173-
color: colors.subtle,
197+
color: colors.lighter,
174198
borderColor: colors.divider,
175-
transition: 'all 0.2s ease',
176-
transitionPropery: 'color, border-color',
199+
transition: 'color 0.2s ease, border-color 0.2s ease',
177200
whiteSpace: 'nowrap',
178201
borderBottomWidth: 1,
179202
borderBottomStyle: 'solid',
180-
181203
':hover': {
182204
color: colors.text,
183205
borderColor: colors.text,
184206
},
207+
':focus': {
208+
color: colors.text,
209+
borderColor: colors.text,
210+
},
185211
},
186212
},
187213

0 commit comments

Comments
 (0)