Skip to content

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

chore: add logic to lw announcement banner

Francesco Sansalvadore6ba3b08575c3
diff --git a/apps/www/components/LaunchWeek/Banners/CountdownBanner.tsx b/apps/www/components/LaunchWeek/Banners/CountdownBanner.tsx
index ce89ec931ab..ff9adbe96a7 100644
--- a/apps/www/components/LaunchWeek/Banners/CountdownBanner.tsx
+++ b/apps/www/components/LaunchWeek/Banners/CountdownBanner.tsx
@@ -1,12 +1,17 @@
import React from 'react'
import Link from 'next/link'
import Countdown from 'react-countdown'
+import _announcement from '~/data/Announcement.json'
+import { AnnouncementProps } from '../../Nav/Announcement'
+import { useRouter } from 'next/router'
interface CountdownStepProps {
value: string | number
unit: string
}
+const announcement = _announcement as AnnouncementProps
+
function CountdownStep({ value, unit }: CountdownStepProps) {
return (
<div className="rounded-md p-[1px] overflow-hidden bg-gradient-to-b from-[#FFFFFF50] to-[#FFFFFF00]">
@@ -19,7 +24,8 @@ function CountdownStep({ value, unit }: CountdownStepProps) {
}
function CountdownBanner() {
- const LW7_DATE = '2023-04-10T07:00:00.000-04:00'
+ const { pathname } = useRouter()
+ const isLaunchWeekPage = pathname === '/launch-week'
const renderer = ({ days, hours, minutes, seconds, completed }: any) => {
if (completed) {
@@ -49,13 +55,15 @@ function CountdownBanner() {
<CountdownStep value={minutes} unit="m" /> :
<CountdownStep value={seconds} unit="s" />
</div>
- <div>
- <Link href="/launch-week">
- <a className="bg-white text-xs px-1.5 md:px-2.5 py-1 rounded-full text-[#9E44EF] shadow-none hover:shadow-mg cursor-pointer">
- Get your ticket
- </a>
- </Link>
- </div>
+ {!isLaunchWeekPage && (
+ <div>
+ <Link href="/launch-week">
+ <a className="bg-white text-xs px-1.5 md:px-2.5 py-1 rounded-full text-[#9E44EF] shadow-none hover:shadow-mg cursor-pointer">
+ Get your ticket
+ </a>
+ </Link>
+ </div>
+ )}
</div>
)
}
@@ -63,7 +71,7 @@ function CountdownBanner() {
return (
<div className="w-full h-14 p-2 bg-gradient-to-r from-[#9E44EF] to-[#DBB8BF] bg-blue-300 flex items-center justify-center text-white">
- <Countdown date={new Date(LW7_DATE)} renderer={renderer} />
+ <Countdown date={new Date(announcement.launchDate)} renderer={renderer} />
</div>
)
}
diff --git a/apps/www/components/Layouts/Default.tsx b/apps/www/components/Layouts/Default.tsx
index 74e60591855..f960816a169 100644
--- a/apps/www/components/Layouts/Default.tsx
+++ b/apps/www/components/Layouts/Default.tsx
@@ -1,7 +1,6 @@
import { useEffect } from 'react'
import Nav from 'components/Nav/index'
import Footer from 'components/Footer/index'
-import CountdownBanner from '../LaunchWeek/Banners/CountdownBanner'
type Props = {
hideHeader?: boolean
@@ -24,7 +23,6 @@ const DefaultLayout = (props: Props) => {
return (
<>
- {/* <CountdownBanner /> */}
{!hideHeader && <Nav />}
<div className="min-h-screen">
<main>{children}</main>
diff --git a/apps/www/components/Nav/Announcement.tsx b/apps/www/components/Nav/Announcement.tsx
index 2f5582d9e3e..60595a309be 100644
--- a/apps/www/components/Nav/Announcement.tsx
+++ b/apps/www/components/Nav/Announcement.tsx
@@ -28,6 +28,7 @@ const Announcement = ({
const [hidden, setHidden] = useState(true)
const router = useRouter()
+ const isLaunchWeekSection = router.pathname.includes('launch-week')
// override to hide announcement
if (!show || !announcement.show) return null
@@ -54,17 +55,20 @@ const Announcement = ({
router.push(announcement.link)
}
- if (hidden) {
+ // Always show if on LW section
+ if (!isLaunchWeekSection && hidden) {
return null
} else {
return (
<div onClick={handleLink} className={['relative w-full cursor-pointer', className].join(' ')}>
- <div
- className="absolute right-4 flex h-full items-center opacity-50 transition-opacity hover:opacity-100"
- onClick={handleClose}
- >
- <IconX size={16} />
- </div>
+ {!isLaunchWeekSection && (
+ <div
+ className="absolute right-4 flex h-full items-center opacity-50 transition-opacity hover:opacity-100"
+ onClick={handleClose}
+ >
+ <IconX size={16} />
+ </div>
+ )}
{children}
</div>
)
diff --git a/apps/www/components/Nav/index.tsx b/apps/www/components/Nav/index.tsx
index 6173bd1bd84..7792858587d 100644
--- a/apps/www/components/Nav/index.tsx
+++ b/apps/www/components/Nav/index.tsx
@@ -209,7 +209,7 @@ const Nav = () => {
<nav
className={[
`border-scale-400 border-b backdrop-blur-sm transition-opacity`,
- showLaunchWeekNavMode && '!opacity-100 border-[#e0d2f430]',
+ showLaunchWeekNavMode && '!opacity-100 !border-[#e0d2f430]',
].join(' ')}
>
{/* <div className="relative flex justify-between h-16 mx-auto lg:container lg:px-10 xl:px-0"> */}
diff --git a/apps/www/data/Announcement.json b/apps/www/data/Announcement.json
index 03d59c9081f..98d9ed77ecc 100644
--- a/apps/www/data/Announcement.json
+++ b/apps/www/data/Announcement.json
@@ -2,6 +2,6 @@
"show": true,
"text": "Supabase Launch Week 7",
"launchDate": "2023-04-10T07:00:00.000-04:00",
- "link": "https://supabase.com/launch-week",
+ "link": "/launch-week",
"badge": "Get your ticket"
}