Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Slight refactor to flyout

Joshen Limd1f92d5cc126
diff --git a/www/components/Nav/index.tsx b/www/components/Nav/index.tsx
index 85adc806c1a..87dc1670695 100644
--- a/www/components/Nav/index.tsx
+++ b/www/components/Nav/index.tsx
@@ -29,14 +29,6 @@ const Nav = (props: Props) => {
} else {
document.body.style.overflow = 'auto'
}
-
- // window is accessible here.
- window.addEventListener('scroll', function (e) {
- // close Fly Outs window if user scrolls past 96px from top
- if (window.pageYOffset > 96) {
- handleCancel()
- }
- })
}, [open])
function handleToggle(callback: any) {
diff --git a/www/components/UI/FlyOut.tsx b/www/components/UI/FlyOut.tsx
index 219a67340c1..24f0c3e78a8 100644
--- a/www/components/UI/FlyOut.tsx
+++ b/www/components/UI/FlyOut.tsx
@@ -12,9 +12,17 @@ type Props = {
}
const FlyOut = (props: Props) => {
- const { title = '', children, className = '', renderTriggerElement = null, singleBgColor = false } = props
+ const { title = '', children, className = '', renderTriggerElement = null, singleBgColor = false, handleCancel } = props
const [show, setShow] = useState(false)
+ useEffect(() => {
+ function handleScroll() {
+ if (window.pageYOffset > 96) handleCancel()
+ }
+ window.addEventListener('scroll', handleScroll)
+ return () => window.removeEventListener('scroll', handleScroll)
+ })
+
// function handleToggle() {
// setShow(!show)
diff --git a/www/pages/beta.tsx b/www/pages/beta.tsx
index 9dc79e58a33..fc5e8c062c1 100644
--- a/www/pages/beta.tsx
+++ b/www/pages/beta.tsx
@@ -1,11 +1,12 @@
import Head from 'next/head'
-import { useRef } from 'react'
+import { useRef, useState } from 'react'
import Container from 'components/Container'
import Layout from 'components/Layout'
import CountUp from 'components/CountUp'
import FlyOut from 'components/UI/FlyOut'
import { APP_NAME, DESCRIPTION } from 'lib/constants'
import { AlphaNumbers, IntroductionSegments, PerformanceComparisonData } from 'data/BetaPage'
+import { render } from 'react-dom'
const site_title = `${APP_NAME} | We are now in Beta`
@@ -55,24 +56,27 @@ const VideoShot = (props: any) => {
)
}
-const renderHamburgerMenu = () => (
- <div className="cursor-pointer">
- <svg
- viewBox="0 0 24 24"
- width="24"
- height="24"
- stroke="white"
- strokeWidth="2"
- fill="none"
- strokeLinecap="round"
- strokeLinejoin="round"
- >
- <line x1="3" y1="12" x2="21" y2="12" />
- <line x1="3" y1="6" x2="21" y2="6" />
- <line x1="3" y1="18" x2="21" y2="18" />
- </svg>
- </div>
-)
+const HamburgerMenu = (props: any) => {
+ const { openMenu } = props
+ return (
+ <div className="cursor-pointer" onClick={openMenu}>
+ <svg
+ viewBox="0 0 24 24"
+ width="24"
+ height="24"
+ stroke="white"
+ strokeWidth="2"
+ fill="none"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ >
+ <line x1="3" y1="12" x2="21" y2="12" />
+ <line x1="3" y1="6" x2="21" y2="6" />
+ <line x1="3" y1="18" x2="21" y2="18" />
+ </svg>
+ </div>
+ )
+}
const SectionHeader = (props: any) => {
const { sectionNumber, header } = props
@@ -769,6 +773,9 @@ const WhatsNext = () => (
)
const Beta = () => {
+
+ const [ menuOpen, setMenuOpen ] = useState<boolean>(false)
+
const references: any = {
performance: useRef<HTMLDivElement>(null),
security: useRef<HTMLDivElement>(null),
@@ -809,7 +816,13 @@ const Beta = () => {
<Container>
<div className="relative shadow-lg py-5 px-5 xl:px-20 sticky inset-0 bg-dark-800 z-50 flex items-center justify-between">
<img className="h-5" src="images/logo-dark.png" />
- <FlyOut className="lg:col-span-1" renderTriggerElement={renderHamburgerMenu} singleBgColor={true}>
+ <HamburgerMenu openMenu={() => setMenuOpen(!menuOpen)}/>
+ <FlyOut
+ open={menuOpen}
+ handleCancel={() => setMenuOpen(false)}
+ className="lg:col-span-1"
+ singleBgColor={true}
+ >
<NavFlyOutMenu scrollTo={scrollTo} />
</FlyOut>
</div>