diff --git a/apps/www/components/LaunchWeek/Banners/CountdownBanner.tsx b/apps/www/components/LaunchWeek/Banners/CountdownBanner.tsx new file mode 100644 index 00000000000..12fe5c3738c --- /dev/null +++ b/apps/www/components/LaunchWeek/Banners/CountdownBanner.tsx @@ -0,0 +1,85 @@ +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 ( +
+
+ {value} + {unit} +
+
+ ) +} + +function CountdownBanner() { + const { pathname } = useRouter() + const isLaunchWeekPage = pathname === '/launch-week' + const isLaunchWeekSection = pathname.includes('launch-week') + + const renderer = ({ days, hours, minutes, seconds, completed }: any) => { + if (completed) { + // Render a completed state + return ( +
+

Supabase Launch Week 7

+
+ + + Now live + + +
+
+ ) + } else { + // Render countdown + return ( +
+

+ Supabase Launch Week 7 +

+
+ : + : + : + +
+ {!isLaunchWeekPage && ( +
+ + + Get your ticket + + +
+ )} +
+ ) + } + } + + return ( +
+ +
+ ) +} + +export default CountdownBanner diff --git a/apps/www/components/Nav/Announcement.tsx b/apps/www/components/Nav/Announcement.tsx index a85d9c524f2..60595a309be 100644 --- a/apps/www/components/Nav/Announcement.tsx +++ b/apps/www/components/Nav/Announcement.tsx @@ -1,26 +1,37 @@ import React, { useEffect, useState } from 'react' import _announcement from '~/data/Announcement.json' -import { IconChevronRight, IconX } from 'ui' +import { IconX } from 'ui' import { useRouter } from 'next/router' +import { PropsWithChildren } from 'react' -interface AnnouncementProps { +export interface AnnouncementProps { show: boolean text: string - cta: string + launchDate: string link: string badge?: string } const announcement = _announcement as AnnouncementProps -const Announcement = () => { +interface AnnouncementComponentProps { + show?: boolean + className?: string +} + +const Announcement = ({ + show = true, + className, + children, +}: PropsWithChildren) => { const [hidden, setHidden] = useState(true) const router = useRouter() + const isLaunchWeekSection = router.pathname.includes('launch-week') // override to hide announcement - if (!announcement.show) return null + if (!show || !announcement.show) return null // construct the key for the announcement, based on the title text const announcementKey = 'announcement_' + announcement.text.replace(/ /g, '') @@ -42,50 +53,23 @@ const Announcement = () => { function handleLink() { router.push(announcement.link) - window.localStorage.setItem(announcementKey, 'hidden') } - if (hidden) { + // Always show if on LW section + if (!isLaunchWeekSection && hidden) { return null } else { return ( -
-
- {announcement.text} - - {announcement.badge && ( -
- {announcement.badge} -
- )} -
- - {announcement.cta} - -
-
- -
+
+ {!isLaunchWeekSection && ( +
+ +
+ )} + {children}
) } diff --git a/apps/www/components/Nav/index.tsx b/apps/www/components/Nav/index.tsx index 17e7eeac174..7baf842c5f5 100644 --- a/apps/www/components/Nav/index.tsx +++ b/apps/www/components/Nav/index.tsx @@ -17,6 +17,7 @@ import TextLink from '../TextLink' import Image from 'next/image' import * as supabaseLogoWordmarkDark from 'common/assets/images/supabase-logo-wordmark--dark.png' import * as supabaseLogoWordmarkLight from 'common/assets/images/supabase-logo-wordmark--light.png' +import CountdownBanner from '../LaunchWeek/Banners/CountdownBanner' const Nav = () => { const { isDarkMode } = useTheme() @@ -194,7 +195,9 @@ const Nav = () => { return ( <> - {/* */} + + +
{
- {/*
*/}
{/*
*/} {/* Mobile Nav Menu */} diff --git a/apps/www/data/Announcement.json b/apps/www/data/Announcement.json index a0ab4c9ff86..ee460e86b28 100644 --- a/apps/www/data/Announcement.json +++ b/apps/www/data/Announcement.json @@ -1,7 +1,7 @@ { "show": true, - "text": "Launch Week 6 begins December 12th", - "cta": "Don't miss a thing, get your free ticket", - "link": "https://supabase.com/launch-week", - "badge": "Get a reminder" + "text": "Supabase Launch Week 7", + "launchDate": "2023-04-10T07:00:00.000-07:00", + "link": "/launch-week", + "badge": "Get your ticket" } diff --git a/apps/www/package.json b/apps/www/package.json index e34b14c8ab1..386cf50b53a 100644 --- a/apps/www/package.json +++ b/apps/www/package.json @@ -41,6 +41,7 @@ "parse-numeric-range": "^1.3.0", "react": "^17.0.2", "react-copy-to-clipboard": "^5.0.2", + "react-countdown": "^2.3.5", "react-dom": "^17.0.2", "react-ga": "^3.3.0", "react-markdown": "^8.0.3", diff --git a/apps/www/pages/launch-week/index.tsx b/apps/www/pages/launch-week/index.tsx index d882ec9625c..4fea6ced64b 100644 --- a/apps/www/pages/launch-week/index.tsx +++ b/apps/www/pages/launch-week/index.tsx @@ -95,7 +95,7 @@ export default function TicketHome({ users }: Props) { }} /> -
+
diff --git a/apps/www/pages/launch-week/tickets/[username].tsx b/apps/www/pages/launch-week/tickets/[username].tsx index 7c2707ddf5d..4f711ec921d 100644 --- a/apps/www/pages/launch-week/tickets/[username].tsx +++ b/apps/www/pages/launch-week/tickets/[username].tsx @@ -64,7 +64,7 @@ export default function UsernamePage({ user, users, ogImageUrl }: Props) { }} /> -
+
diff --git a/apps/www/pages/launch-week/tickets/index.tsx b/apps/www/pages/launch-week/tickets/index.tsx index 2ed83a94917..e916dc8c0c5 100644 --- a/apps/www/pages/launch-week/tickets/index.tsx +++ b/apps/www/pages/launch-week/tickets/index.tsx @@ -109,7 +109,7 @@ export default function TicketsPage({ users }: Props) { }} /> -
+
diff --git a/package-lock.json b/package-lock.json index b2eee282491..67067295f21 100644 --- a/package-lock.json +++ b/package-lock.json @@ -682,6 +682,7 @@ "parse-numeric-range": "^1.3.0", "react": "^17.0.2", "react-copy-to-clipboard": "^5.0.2", + "react-countdown": "^2.3.5", "react-dom": "^17.0.2", "react-ga": "^3.3.0", "react-markdown": "^8.0.3", @@ -31443,6 +31444,18 @@ "react": "^15.3.0 || 16 || 17 || 18" } }, + "node_modules/react-countdown": { + "version": "2.3.5", + "resolved": "https://registry.npmjs.org/react-countdown/-/react-countdown-2.3.5.tgz", + "integrity": "sha512-K26ENYEesMfPxhRRtm1r+Pf70SErrvW3g4CArLi/x6MPFjgfDFYePT4UghEj8p2nI0cqVV7/JjDgjyr//U60Og==", + "dependencies": { + "prop-types": "^15.7.2" + }, + "peerDependencies": { + "react": ">= 15", + "react-dom": ">= 15" + } + }, "node_modules/react-csv": { "version": "2.2.2", "resolved": "https://registry.npmjs.org/react-csv/-/react-csv-2.2.2.tgz", @@ -63238,6 +63251,14 @@ "prop-types": "^15.8.1" } }, + "react-countdown": { + "version": "2.3.5", + "resolved": "https://registry.npmjs.org/react-countdown/-/react-countdown-2.3.5.tgz", + "integrity": "sha512-K26ENYEesMfPxhRRtm1r+Pf70SErrvW3g4CArLi/x6MPFjgfDFYePT4UghEj8p2nI0cqVV7/JjDgjyr//U60Og==", + "requires": { + "prop-types": "^15.7.2" + } + }, "react-csv": { "version": "2.2.2", "resolved": "https://registry.npmjs.org/react-csv/-/react-csv-2.2.2.tgz", @@ -69302,6 +69323,7 @@ "postcss-preset-env": "^6.7.0", "react": "^17.0.2", "react-copy-to-clipboard": "^5.0.2", + "react-countdown": "^2.3.5", "react-dom": "^17.0.2", "react-ga": "^3.3.0", "react-markdown": "^8.0.3",