From 9247d1a359f117a66d80f044270b2c2fc39e8804 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 7 Sep 2022 04:20:32 +0100 Subject: [PATCH] [Beta] Make banner scrollable (#5002) --- beta/src/components/Layout/Feedback.tsx | 2 +- beta/src/components/Layout/Footer.tsx | 2 +- beta/src/components/Layout/MarkdownPage.tsx | 5 +- beta/src/components/Layout/Nav/Nav.tsx | 77 ++++++++++++--------- beta/src/components/Layout/Page.tsx | 29 ++++---- beta/src/components/Layout/Toc.tsx | 20 ++---- beta/src/components/PageHeading.tsx | 2 +- beta/src/components/SocialBanner.tsx | 33 +++++++-- beta/src/pages/404.js | 4 +- beta/src/pages/500.js | 4 +- beta/src/pages/[[...markdownPath]].js | 7 +- beta/yarn.lock | 17 ----- 12 files changed, 107 insertions(+), 95 deletions(-) diff --git a/beta/src/components/Layout/Feedback.tsx b/beta/src/components/Layout/Feedback.tsx index 700612e84..f0697f248 100644 --- a/beta/src/components/Layout/Feedback.tsx +++ b/beta/src/components/Layout/Feedback.tsx @@ -61,7 +61,7 @@ function SendFeedback({onSubmit}: {onSubmit: () => void}) { const [isSubmitted, setIsSubmitted] = React.useState(false); return (
-

+

{isSubmitted ? 'Thank you for your feedback!' : 'Is this page useful?'}

{!isSubmitted && ( diff --git a/beta/src/components/Layout/Footer.tsx b/beta/src/components/Layout/Footer.tsx index 20b555bff..d2707dbe2 100644 --- a/beta/src/components/Layout/Footer.tsx +++ b/beta/src/components/Layout/Footer.tsx @@ -13,7 +13,7 @@ export function Footer() { const socialLinkClasses = 'hover:text-primary dark:text-primary-dark'; return ( <> -
+

diff --git a/beta/src/components/Layout/MarkdownPage.tsx b/beta/src/components/Layout/MarkdownPage.tsx index 57b3b250c..21d058653 100644 --- a/beta/src/components/Layout/MarkdownPage.tsx +++ b/beta/src/components/Layout/MarkdownPage.tsx @@ -34,7 +34,7 @@ export function MarkdownPage< const isHomePage = route?.path === '/'; return ( <> -
+
{!isHomePage && (
-
- {!isHomePage && toc.length > 0 && } -
); } diff --git a/beta/src/components/Layout/Nav/Nav.tsx b/beta/src/components/Layout/Nav/Nav.tsx index e682dfff6..a6afc0260 100644 --- a/beta/src/components/Layout/Nav/Nav.tsx +++ b/beta/src/components/Layout/Nav/Nav.tsx @@ -99,7 +99,7 @@ const lightIcon = ( export default function Nav() { const [isOpen, setIsOpen] = React.useState(false); const [showFeedback, setShowFeedback] = React.useState(false); - const menuRef = React.useRef(null); + const scrollParentRef = React.useRef(null); const feedbackAutohideRef = React.useRef(null); const section = useActiveSection(); const {asPath} = useRouter(); @@ -136,7 +136,7 @@ export default function Nav() { // While the overlay is open, disable body scroll. React.useEffect(() => { if (isOpen) { - const preferredScrollParent = menuRef.current!; + const preferredScrollParent = scrollParentRef.current!; disableBodyScroll(preferredScrollParent); return () => enableBodyScroll(preferredScrollParent); } else { @@ -190,9 +190,14 @@ export default function Nav() { capture: true, }); }, [showFeedback]); + return ( - <> -