Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
fa15160
Fix - Sandpack error icon overlapping issue (#4332)
imanpalsingh Feb 14, 2022
b677012
Add App.js Conf 2022 to the conferences page (#4336)
tsapeta Feb 15, 2022
b10ae60
sandpack: bring back init mode (#4337)
danilowoz Feb 15, 2022
b4de700
[Beta] Add ARIA labels (#4335)
shamwela Feb 15, 2022
0209e1b
[Beta] Reorder API sections (#4328)
gaearon Feb 16, 2022
2979d0c
Splitting sandpack from main bundle (#4256)
Feb 16, 2022
a2138f2
Nitpicks for code splitting (#4346)
gaearon Feb 16, 2022
4ed4fb7
[Beta] Change highlight styles (#4348)
gaearon Feb 17, 2022
93fdfb2
[Beta] useRef API (#4345)
gaearon Feb 17, 2022
3d6eba7
[beta] fix typo in useref.md (#4352)
mayank99 Feb 17, 2022
aa4bb41
Cache a font file (#4350)
shamwela Feb 17, 2022
3d6081f
[Beta] Add aria-label and title to permalinks (#4344)
shamwela Feb 18, 2022
a48ba9c
Link to how to set up syntax in Sublime
gaearon Feb 18, 2022
c8ec9d8
[Beta] Replace Hotjar with GA buttons (#4275)
gaearon Feb 18, 2022
45ac43a
Never use local font
gaearon Feb 18, 2022
81f772e
Switch from GA4 to UA to track feedback
gaearon Feb 18, 2022
8ca0215
Fix pageview collection for UA
gaearon Feb 18, 2022
9ac33ff
Fix TS
gaearon Feb 18, 2022
0883863
[Beta] Use a light GA client (#4355)
gaearon Feb 18, 2022
8def749
Try caching the font
gaearon Feb 18, 2022
753c4fc
Delete dead code
gaearon Feb 18, 2022
855c26a
Ignore TSC build file
gaearon Feb 18, 2022
f3f580a
Don't use unload on modern browsers
gaearon Feb 18, 2022
ab648df
Consolidate and preload fonts
gaearon Feb 18, 2022
6c855f7
Remember whether downloads are supported
gaearon Feb 18, 2022
3ae0eb6
Fix white flash when loading
gaearon Feb 18, 2022
7d55f61
Initial Commit (#4357)
Feb 18, 2022
5b8a720
Initial Commit (#4358)
Feb 18, 2022
2310e15
Add ARIA labels on the navigation buttons (#4363)
shamwela Feb 19, 2022
0c71b35
merging all conflicts
react-translations-bot Feb 21, 2022
da39617
chore: resolve conflict
neighborhood999 Feb 21, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions beta/.env.development
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
NEXT_PUBLIC_HJ_SITE_ID = 2411683
NEXT_PUBLIC_HJ_SITE_V = 6
4 changes: 1 addition & 3 deletions beta/.env.production
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
NEXT_PUBLIC_HJ_SITE_ID = 2411651
NEXT_PUBLIC_HJ_SITE_V = 6
NEXT_PUBLIC_GA_TRACKING_ID = 'G-3918VS75Y6'
NEXT_PUBLIC_GA_TRACKING_ID = 'UA-41298772-4'
1 change: 1 addition & 0 deletions beta/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
# misc
.DS_Store
*.pem
tsconfig.tsbuildinfo

# debug
npm-debug.log*
Expand Down
4 changes: 2 additions & 2 deletions beta/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = {
experimental: {
plugins: true,
// TODO: this doesn't work because https://github.com/vercel/next.js/issues/30714
// concurrentFeatures: true,
concurrentFeatures: false,
scrollRestoration: true,
},
async redirects() {
Expand All @@ -27,7 +27,7 @@ module.exports = {
},
webpack: (config, {dev, isServer, ...options}) => {
if (process.env.ANALYZE) {
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer')
const {BundleAnalyzerPlugin} = require('webpack-bundle-analyzer');
config.plugins.push(
new BundleAnalyzerPlugin({
analyzerMode: 'static',
Expand Down
7 changes: 4 additions & 3 deletions beta/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
"ci-check": "npm-run-all prettier:diff --parallel lint tsc lint-heading-ids",
"tsc": "tsc --noEmit",
"start": "next start",
"postinstall": "is-ci || (cd .. && husky install beta/.husky)",
"postinstall": "patch-package && (is-ci || (cd .. && husky install beta/.husky))",
"check-all": "npm-run-all prettier lint:fix tsc"
},
"dependencies": {
"@codesandbox/sandpack-react": "0.13.11-experimental.0",
"@codesandbox/sandpack-react": "0.13.16-experimental.0",
"@docsearch/css": "3.0.0-alpha.41",
"@docsearch/react": "3.0.0-alpha.41",
"@headlessui/react": "^1.3.0",
Expand All @@ -31,8 +31,9 @@
"classnames": "^2.2.6",
"date-fns": "^2.16.1",
"debounce": "^1.2.1",
"ga-lite": "^2.1.4",
"github-slugger": "^1.3.0",
"next": "^12.0.9",
"next": "^12.0.10",
"parse-numeric-range": "^1.2.0",
"react": "experimental",
"react-collapsed": "3.1.0",
Expand Down
Binary file added beta/public/fonts/Source-Code-Pro-Regular.woff2
Binary file not shown.
Binary file removed beta/public/fonts/SourceCodePro-Regular.ttf
Binary file not shown.
94 changes: 94 additions & 0 deletions beta/src/components/Layout/Feedback.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*/

import * as React from 'react';
import {useRouter} from 'next/router';
// @ts-ignore
import galite from 'ga-lite';

export function Feedback({onSubmit = () => {}}: {onSubmit?: () => void}) {
const {pathname} = useRouter();
// Reset on route changes.
return <SendFeedback key={pathname} onSubmit={onSubmit} />;
}

const thumbsUpIcon = (
<svg
width="16"
height="18"
viewBox="0 0 16 18"
fill="none"
xmlns="http://www.w3.org/2000/svg">
<path
fillRule="evenodd"
clipRule="evenodd"
d="M9.36603 0.384603C9.36605 0.384617 9.36601 0.384588 9.36603 0.384603L9.45902 0.453415C9.99732 0.851783 10.3873 1.42386 10.5654 2.07648C10.7435 2.72909 10.6993 3.42385 10.44 4.04763L9.27065 6.86008H12.6316C13.5249 6.86008 14.3817 7.22121 15.0134 7.86402C15.6451 8.50683 16 9.37868 16 10.2877V13.7154C16 14.8518 15.5564 15.9416 14.7668 16.7451C13.9771 17.5486 12.9062 18 11.7895 18H5.05263C3.71259 18 2.42743 17.4583 1.47988 16.4941C0.532325 15.5299 0 14.2221 0 12.8585V11.2511C2.40928e-06 9.87711 0.463526 8.54479 1.31308 7.47688L6.66804 0.745592C6.98662 0.345136 7.44414 0.08434 7.94623 0.0171605C8.4483 -0.0500155 8.95656 0.0815891 9.36603 0.384603ZM8.37542 1.77064C8.31492 1.72587 8.23987 1.70646 8.16579 1.71637C8.09171 1.72628 8.02415 1.76477 7.97708 1.82393L2.62213 8.55522C2.0153 9.31801 1.68421 10.2697 1.68421 11.2511V12.8585C1.68421 13.7676 2.03909 14.6394 2.67079 15.2822C3.30249 15.925 4.15927 16.2862 5.05263 16.2862H11.7895C12.4595 16.2862 13.1021 16.0153 13.5759 15.5332C14.0496 15.0511 14.3158 14.3972 14.3158 13.7154V10.2877C14.3158 9.83321 14.1383 9.39729 13.8225 9.07588C13.5066 8.75448 13.0783 8.57392 12.6316 8.57392H8C7.71763 8.57392 7.45405 8.4299 7.29806 8.19039C7.14206 7.95087 7.11442 7.64774 7.22445 7.38311L8.88886 3.37986C9 3.11253 9.01896 2.81477 8.94262 2.53507C8.8663 2.25541 8.69921 2.01027 8.46853 1.83954L8.37542 1.77064Z"
fill="currentColor"
/>
</svg>
);

const thumbsDownIcon = (
<svg
width="16"
height="18"
viewBox="0 0 16 18"
fill="none"
xmlns="http://www.w3.org/2000/svg">
<path
fillRule="evenodd"
clipRule="evenodd"
d="M6.63397 17.6154C6.63395 17.6154 6.63399 17.6154 6.63397 17.6154L6.54098 17.5466C6.00268 17.1482 5.61269 16.5761 5.43458 15.9235C5.25648 15.2709 5.30069 14.5761 5.56004 13.9524L6.72935 11.1399L3.36842 11.1399C2.47506 11.1399 1.61829 10.7788 0.986585 10.136C0.354883 9.49316 8.1991e-07 8.62132 8.99384e-07 7.71225L1.19904e-06 4.28458C1.29838e-06 3.14824 0.443605 2.05844 1.23323 1.25492C2.02286 0.451403 3.09383 -1.12829e-06 4.21053 -1.03067e-06L10.9474 -4.41715e-07C12.2874 -3.24565e-07 13.5726 0.541687 14.5201 1.50591C15.4677 2.47013 16 3.77789 16 5.1415L16 6.74893C16 8.12289 15.5365 9.45521 14.6869 10.5231L9.33196 17.2544C9.01338 17.6549 8.55586 17.9157 8.05377 17.9828C7.5517 18.05 7.04344 17.9184 6.63397 17.6154ZM7.62458 16.2294C7.68508 16.2741 7.76013 16.2935 7.83421 16.2836C7.90829 16.2737 7.97585 16.2352 8.02292 16.1761L13.3779 9.44478C13.9847 8.68199 14.3158 7.73033 14.3158 6.74892L14.3158 5.1415C14.3158 4.23242 13.9609 3.36058 13.3292 2.71777C12.6975 2.07496 11.8407 1.71383 10.9474 1.71383L4.21053 1.71383C3.5405 1.71383 2.89793 1.98468 2.42415 2.46679C1.95038 2.94889 1.68421 3.60277 1.68421 4.28458L1.68421 7.71225C1.68421 8.16679 1.86166 8.60271 2.1775 8.92411C2.49335 9.24552 2.92174 9.42608 3.36842 9.42608L8 9.42608C8.28237 9.42608 8.54595 9.5701 8.70195 9.80961C8.85794 10.0491 8.88558 10.3523 8.77555 10.6169L7.11114 14.6201C7 14.8875 6.98105 15.1852 7.05738 15.4649C7.1337 15.7446 7.30079 15.9897 7.53147 16.1605L7.62458 16.2294Z"
fill="currentColor"
/>
</svg>
);

function sendGAEvent(isPositive: boolean) {
// Fragile. Don't change unless you've tested the network payload
// and verified that the right events actually show up in GA.
galite(
'send',
'event',
'button',
'feedback',
window.location.pathname,
isPositive ? '1' : '0'
);
}

function SendFeedback({onSubmit}: {onSubmit: () => void}) {
const [isSubmitted, setIsSubmitted] = React.useState(false);
return (
<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">
<p className="w-full font-bold text-primary dark:text-primary-dark text-lg">
{isSubmitted ? 'Thank you for your feedback!' : 'Is this page useful?'}
</p>
{!isSubmitted && (
<button
aria-label="Yes"
className="bg-secondary-button dark:bg-secondary-button-dark rounded-lg text-primary dark:text-primary-dark px-3 mr-2"
onClick={() => {
setIsSubmitted(true);
onSubmit();
sendGAEvent(true);
}}>
{thumbsUpIcon}
</button>
)}
{!isSubmitted && (
<button
aria-label="No"
className="bg-secondary-button dark:bg-secondary-button-dark rounded-lg text-primary dark:text-primary-dark px-3"
onClick={() => {
setIsSubmitted(true);
onSubmit();
sendGAEvent(false);
}}>
{thumbsDownIcon}
</button>
)}
</div>
);
}
2 changes: 2 additions & 0 deletions beta/src/components/Layout/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,13 @@ export function Footer() {
</FooterLink>
<div className="flex flex-row mt-8 gap-x-2">
<ExternalLink
aria-label="React on Facebook"
href="https://www.facebook.com/react"
className={socialLinkClasses}>
<IconFacebookCircle />
</ExternalLink>
<ExternalLink
aria-label="React on Twitter"
href="https://twitter.com/reactjs"
className={socialLinkClasses}>
<IconTwitter />
Expand Down
1 change: 0 additions & 1 deletion beta/src/components/Layout/MarkdownPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ export function MarkdownPage<
// a full-width section which interrupts it.
let fullWidthTypes = [
'Sandpack',
'APIAnatomy',
'FullWidth',
'Illustration',
'IllustrationBlock',
Expand Down
95 changes: 66 additions & 29 deletions beta/src/components/Layout/Nav/Nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {Search} from 'components/Search';
import {MenuContext} from 'components/useMenu';

import {Logo} from '../../Logo';
import {Feedback} from '../Feedback';
import NavLink from './NavLink';

declare global {
Expand All @@ -24,24 +25,23 @@ declare global {

const feedbackIcon = (
<svg
xmlns="http://www.w3.org/2000/svg"
width="18"
height="18"
viewBox="0 0 24 24">
<g fill="none" fillRule="evenodd" transform="translate(-444 -204)">
<g fill="currentColor" transform="translate(354.5 205)">
<path d="M102.75 14C102.75 14.6905 102.1905 15.25 101.5 15.25 100.8095 15.25 100.25 14.6905 100.25 14 100.25 13.3095 100.8095 12.75 101.5 12.75 102.1905 12.75 102.75 13.3095 102.75 14M101 5.25L101.5 11 102 5.25C102 5.25 102 4.75 101.5 4.75 101 4.75 101 5.25 101 5.25" />
<path
fillRule="nonzero"
d="M100.25282,5.31497221 L100.75282,11.0649722 C100.832243,11.9783426 102.167757,11.9783426 102.24718,11.0649722 L102.74718,5.31497221 L102.75,5.25 C102.75,5.08145956 102.716622,4.88119374 102.60832,4.6645898 C102.407353,4.2626558 102.01337,4 101.5,4 C100.98663,4 100.592647,4.2626558 100.39168,4.6645898 C100.283378,4.88119374 100.25,5.08145956 100.25,5.25 L100.25282,5.31497221 Z M101.249053,5.22834322 L101.24717,5.25 L101.75283,5.25 L101.750947,5.22834322 L101.5,5.20652174 L101.249053,5.22834322 Z M101.25,5.25 L101.75,5.25 C101.75,5.29354044 101.747872,5.30630626 101.73332,5.3354102 C101.688603,5.4248442 101.57587,5.5 101.5,5.5 C101.42413,5.5 101.311397,5.4248442 101.26668,5.3354102 C101.252128,5.30630626 101.25,5.29354044 101.25,5.25 Z"
/>
<path
fillRule="nonzero"
d="M96.2928885,18.5085 L109.75,18.5085 C111.268908,18.5085 112.5085,17.268908 112.5085,15.75 L112.5085,3.25 C112.5085,1.73109202 111.268908,0.4915 109.75,0.4915 L93.25,0.4915 C91.731092,0.4915 90.4915,1.73109202 90.4915,3.25 L90.4915,21.5 C90.4915,22.3943136 91.5519083,22.8250723 92.1764221,22.2491522 L92.230357,22.1957095 L96.2928885,18.5085 Z M92.0085,3.25 C92.0085,2.56890798 92.568908,2.0085 93.25,2.0085 L109.75,2.0085 C110.431092,2.0085 110.9915,2.56890798 110.9915,3.25 L110.9915,15.75 C110.9915,16.431092 110.431092,16.9915 109.75,16.9915 L96,16.9915 C95.8115227,16.9915 95.6297966,17.0616721 95.4902321,17.1883427 L92.0085,20.3484106 L92.0085,3.25 Z"
/>
</g>
<polygon points="444 228 468 228 468 204 444 204" />
</g>
width="28"
height="28"
viewBox="0 0 28 28"
fill="none"
xmlns="http://www.w3.org/2000/svg">
<path
fillRule="evenodd"
clipRule="evenodd"
d="M8.41477 2.29921C8.41479 2.29923 8.41476 2.2992 8.41477 2.29921L8.48839 2.35275C8.91454 2.66267 9.22329 3.10774 9.36429 3.61547C9.50529 4.12319 9.47029 4.6637 9.26497 5.14899L8.33926 7.33703H11C11.7072 7.33703 12.3855 7.61798 12.8856 8.11807C13.3857 8.61817 13.6667 9.29645 13.6667 10.0037V12.6704C13.6667 13.5544 13.3155 14.4023 12.6904 15.0274C12.0652 15.6525 11.2174 16.0037 10.3333 16.0037H5C3.93914 16.0037 2.92172 15.5823 2.17157 14.8321C1.42142 14.082 1 13.0646 1 12.0037V10.7531C1 9.68422 1.36696 8.6477 2.03953 7.81688L6.27886 2.58006C6.53107 2.26851 6.89328 2.06562 7.29077 2.01335C7.68823 1.96109 8.09061 2.06347 8.41477 2.29921ZM7.63054 3.37753C7.58264 3.34269 7.52323 3.32759 7.46459 3.33531C7.40594 3.34302 7.35245 3.37296 7.31519 3.41899L3.07585 8.65581C2.59545 9.24925 2.33333 9.98963 2.33333 10.7531V12.0037C2.33333 12.7109 2.61428 13.3892 3.11438 13.8893C3.61448 14.3894 4.29275 14.6704 5 14.6704H10.3333C10.8638 14.6704 11.3725 14.4596 11.7475 14.0846C12.1226 13.7095 12.3333 13.2008 12.3333 12.6704V10.0037C12.3333 9.65007 12.1929 9.31093 11.9428 9.06088C11.6928 8.81084 11.3536 8.67036 11 8.67036H7.33333C7.10979 8.67036 6.90112 8.55832 6.77763 8.37198C6.65413 8.18564 6.63225 7.94981 6.71936 7.74393L8.03701 4.62947C8.125 4.42149 8.14001 4.18984 8.07958 3.97224C8.01916 3.75467 7.88687 3.56396 7.70425 3.43113L7.63054 3.37753Z"
fill="currentColor"
/>
<path
fillRule="evenodd"
clipRule="evenodd"
d="M19.2517 25.7047C19.2517 25.7047 19.2517 25.7047 19.2517 25.7047L19.1781 25.6512C18.752 25.3412 18.4432 24.8962 18.3022 24.3884C18.1612 23.8807 18.1962 23.3402 18.4015 22.8549L19.3272 20.6669L16.6665 20.6669C15.9593 20.6669 15.281 20.3859 14.7809 19.8858C14.2808 19.3857 13.9998 18.7075 13.9998 18.0002L13.9998 15.3335C13.9998 14.4495 14.351 13.6016 14.9761 12.9765C15.6013 12.3514 16.4491 12.0002 17.3332 12.0002L22.6665 12.0002C23.7274 12.0002 24.7448 12.4216 25.4949 13.1718C26.2451 13.9219 26.6665 14.9393 26.6665 16.0002L26.6665 17.2508C26.6665 18.3197 26.2995 19.3562 25.627 20.187L21.3876 25.4238C21.1354 25.7354 20.7732 25.9383 20.3757 25.9906C19.9783 26.0428 19.5759 25.9404 19.2517 25.7047ZM20.036 24.6264C20.0839 24.6612 20.1433 24.6763 20.2019 24.6686C20.2606 24.6609 20.3141 24.6309 20.3513 24.5849L24.5907 19.3481C25.0711 18.7547 25.3332 18.0143 25.3332 17.2508L25.3332 16.0002C25.3332 15.293 25.0522 14.6147 24.5521 14.1146C24.052 13.6145 23.3738 13.3335 22.6665 13.3335L17.3332 13.3335C16.8027 13.3335 16.294 13.5443 15.919 13.9193C15.5439 14.2944 15.3332 14.8031 15.3332 15.3335L15.3332 18.0002C15.3332 18.3538 15.4736 18.693 15.7237 18.943C15.9737 19.1931 16.3129 19.3335 16.6665 19.3335L20.3332 19.3335C20.5567 19.3335 20.7654 19.4456 20.8889 19.6319C21.0124 19.8183 21.0343 20.0541 20.9471 20.26L19.6295 23.3744C19.5415 23.5824 19.5265 23.8141 19.5869 24.0317C19.6473 24.2492 19.7796 24.4399 19.9623 24.5728L20.036 24.6264Z"
fill="currentColor"
/>
</svg>
);

Expand Down Expand Up @@ -99,18 +99,34 @@ function inferSection(pathname: string): 'learn' | 'apis' | 'home' {
export default function Nav() {
const {pathname} = useRouter();
const {isOpen, toggleOpen} = React.useContext(MenuContext);
const [showFeedback, setShowFeedback] = React.useState(false);
const feedbackAutohideRef = React.useRef<any>(null);
const section = inferSection(pathname);
const feedbackPopupRef = React.useRef<null | HTMLDivElement>(null);

function handleFeedback() {
const nodes: any = document.querySelectorAll(
'#_hj_feedback_container button'
);
if (nodes.length > 0) {
nodes[nodes.length - 1].click();
} else {
window.location.href =
'https://github.com/reactjs/reactjs.org/issues/3308';
React.useEffect(() => {
if (!showFeedback) {
return;
}
function handleDocumentClickCapture(e: MouseEvent) {
if (!feedbackPopupRef.current!.contains(e.target as any)) {
e.stopPropagation();
e.preventDefault();
setShowFeedback(false);
}
}
document.addEventListener('click', handleDocumentClickCapture, {
capture: true,
});
return () =>
document.removeEventListener('click', handleDocumentClickCapture, {
capture: true,
});
}, [showFeedback]);

function handleFeedback() {
clearTimeout(feedbackAutohideRef.current);
setShowFeedback(!showFeedback);
}

return (
Expand Down Expand Up @@ -170,11 +186,17 @@ export default function Nav() {
API
</NavLink>
</div>
<div className="flex my-4 h-10 mx-0 w-full lg:hidden justify-end slg:max-w-sm">
<div className="flex my-4 h-10 mx-0 w-full lg:hidden justify-end lg:max-w-sm">
<Search />
<button
aria-label="Give feedback"
type="button"
className="inline-flex lg:hidden items-center p-1 ml-4 lg:ml-6 relative top-px"
className={cn(
'inline-flex lg:hidden items-center rounded-full px-1.5 ml-4 lg:ml-6 relative top-px',
{
'bg-card dark:bg-card-dark': showFeedback,
}
)}
onClick={handleFeedback}>
{feedbackIcon}
</button>
Expand All @@ -189,6 +211,21 @@ export default function Nav() {
{darkIcon}
</button>
</div>
<div
ref={feedbackPopupRef}
className={cn(
'fixed top-12 right-0',
showFeedback ? 'block' : 'hidden'
)}>
<Feedback
onSubmit={() => {
clearTimeout(feedbackAutohideRef.current);
feedbackAutohideRef.current = setTimeout(() => {
setShowFeedback(false);
}, 1000);
}}
/>
</div>
<div className="hidden dark:block">
<button
type="button"
Expand Down
44 changes: 3 additions & 41 deletions beta/src/components/Layout/Sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {SidebarRouteTree} from './SidebarRouteTree';
import {Search} from 'components/Search';
import {Button} from 'components/Button';
import {MobileNav} from '../Nav/MobileNav';
import {Feedback} from '../Feedback';

const SIDEBAR_BREAKPOINT = 1023;

Expand All @@ -24,41 +25,6 @@ export function Sidebar({isMobileOnly}: {isMobileOnly?: boolean}) {
if ((routeTree as any).routes.length === 1) {
routeTree = (routeTree as any).routes[0];
}

function handleFeedback() {
const nodes: any = document.querySelectorAll(
'#_hj_feedback_container button'
);
if (nodes.length > 0) {
nodes[nodes.length - 1].click();
} else {
window.location.href =
'https://github.com/reactjs/reactjs.org/issues/3308';
}
}
const feedbackIcon = (
<svg
xmlns="http://www.w3.org/2000/svg"
width="18"
height="18"
className="mr-2"
viewBox="0 0 24 24">
<g fill="none" fillRule="evenodd" transform="translate(-444 -204)">
<g fill="currentColor" transform="translate(354.5 205)">
<path d="M102.75 14C102.75 14.6905 102.1905 15.25 101.5 15.25 100.8095 15.25 100.25 14.6905 100.25 14 100.25 13.3095 100.8095 12.75 101.5 12.75 102.1905 12.75 102.75 13.3095 102.75 14M101 5.25L101.5 11 102 5.25C102 5.25 102 4.75 101.5 4.75 101 4.75 101 5.25 101 5.25" />
<path
fillRule="nonzero"
d="M100.25282,5.31497221 L100.75282,11.0649722 C100.832243,11.9783426 102.167757,11.9783426 102.24718,11.0649722 L102.74718,5.31497221 L102.75,5.25 C102.75,5.08145956 102.716622,4.88119374 102.60832,4.6645898 C102.407353,4.2626558 102.01337,4 101.5,4 C100.98663,4 100.592647,4.2626558 100.39168,4.6645898 C100.283378,4.88119374 100.25,5.08145956 100.25,5.25 L100.25282,5.31497221 Z M101.249053,5.22834322 L101.24717,5.25 L101.75283,5.25 L101.750947,5.22834322 L101.5,5.20652174 L101.249053,5.22834322 Z M101.25,5.25 L101.75,5.25 C101.75,5.29354044 101.747872,5.30630626 101.73332,5.3354102 C101.688603,5.4248442 101.57587,5.5 101.5,5.5 C101.42413,5.5 101.311397,5.4248442 101.26668,5.3354102 C101.252128,5.30630626 101.25,5.29354044 101.25,5.25 Z"
/>
<path
fillRule="nonzero"
d="M96.2928885,18.5085 L109.75,18.5085 C111.268908,18.5085 112.5085,17.268908 112.5085,15.75 L112.5085,3.25 C112.5085,1.73109202 111.268908,0.4915 109.75,0.4915 L93.25,0.4915 C91.731092,0.4915 90.4915,1.73109202 90.4915,3.25 L90.4915,21.5 C90.4915,22.3943136 91.5519083,22.8250723 92.1764221,22.2491522 L92.230357,22.1957095 L96.2928885,18.5085 Z M92.0085,3.25 C92.0085,2.56890798 92.568908,2.0085 93.25,2.0085 L109.75,2.0085 C110.431092,2.0085 110.9915,2.56890798 110.9915,3.25 L110.9915,15.75 C110.9915,16.431092 110.431092,16.9915 109.75,16.9915 L96,16.9915 C95.8115227,16.9915 95.6297966,17.0616721 95.4902321,17.1883427 L92.0085,20.3484106 L92.0085,3.25 Z"
/>
</g>
<polygon points="444 228 468 228 468 204 444 204" />
</g>
</svg>
);
return (
<aside
className={cn(
Expand All @@ -80,12 +46,8 @@ export function Sidebar({isMobileOnly}: {isMobileOnly?: boolean}) {
<SidebarRouteTree routeTree={routeTree} />
)}
</nav>
<div className="px-5 py-3 sticky bottom-0 lg:px-5 w-full hidden lg:flex items-center bg-gradient-to-t from-wash dark:from-wash-dark">
<Button
className="w-full text-center justify-center"
onClick={handleFeedback}>
{feedbackIcon} Feedback
</Button>
<div className="sticky bottom-0 hidden lg:block">
<Feedback />
</div>
</aside>
);
Expand Down
Loading