mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 07:29:16 +00:00
## Problem Launch Week 16 is promoted on www but needs the same promotion in hosted Studio. ## Solution Add a low-priority card to the existing bottom-right Banner Stack across project, organisation, and account pages. It uses the shared dot artwork from #54511, links to the Launch Week site, saves dismissal, and expires after December 11 in San Francisco. Signed-out and self-hosted Studio do not show it. | After | | --- | | <img width="995" height="584" alt="1211" src="https://github.com/user-attachments/assets/ff1a60a3-6a4e-4b32-a3df-7fdfe74f4afb" /> | | <img width="995" height="584" alt="68318" src="https://github.com/user-attachments/assets/3a41c56a-fe59-4800-ae14-82ec42c6f260" /> | ## Review instructions 1. Open a hosted project, organisation, or account page on the Studio preview. If another notice is in front, expand the Banner Stack to find **Launch Week 16**. 2. Check the artwork, copy, and **Claim your ticket** button in light and dark mode. The button opens the Launch Week site in a new tab and dismisses the card. 3. Close the card and reload. It should stay dismissed.
109 lines
3.5 KiB
TypeScript
109 lines
3.5 KiB
TypeScript
import { IS_PLATFORM } from 'common'
|
||
import { ArrowUpRightIcon } from 'lucide-react'
|
||
import { useEffect, useState } from 'react'
|
||
import { Button } from 'ui'
|
||
import { LaunchWeek16DotField } from 'ui-patterns/Banners/LaunchWeek16DotField'
|
||
|
||
import { BannerCard } from '../BannerCard'
|
||
import { BANNER_ID, useBannerStack } from '../BannerStackProvider'
|
||
import {
|
||
LAUNCH_WEEK_16_DISMISSAL_KEY,
|
||
LAUNCH_WEEK_16_EXPIRES_AT,
|
||
shouldShowLaunchWeek16Banner,
|
||
} from './BannerLaunchWeek16.utils'
|
||
import { useLocalStorageQuery } from '@/hooks/misc/useLocalStorage'
|
||
|
||
export const BannerLaunchWeek16 = () => {
|
||
const { dismissBanner } = useBannerStack()
|
||
const [, setIsDismissed] = useLocalStorageQuery(LAUNCH_WEEK_16_DISMISSAL_KEY, false)
|
||
|
||
const handleDismiss = () => {
|
||
setIsDismissed(true)
|
||
dismissBanner(BANNER_ID.LAUNCH_WEEK_16)
|
||
}
|
||
|
||
return (
|
||
<BannerCard
|
||
className="w-72 bg-alternative"
|
||
background={
|
||
<LaunchWeek16DotField className="[mask-image:linear-gradient(to_bottom,black,transparent_65%)]" />
|
||
}
|
||
dismissButtonClassName="bg-alternative/50 hover:bg-foreground/10"
|
||
onDismiss={handleDismiss}
|
||
>
|
||
<div className="flex flex-col gap-y-2">
|
||
<div className="h-10" aria-hidden="true" />
|
||
<div className="mb-2 flex flex-col gap-y-1">
|
||
<p className="text-sm font-medium text-foreground text-balance">Launch Week 16</p>
|
||
<p className="text-xs text-foreground-lighter text-balance">
|
||
Join us December 7–11 for a week of daily launches. Explore what’s new and what you can
|
||
build.
|
||
</p>
|
||
</div>
|
||
<Button
|
||
asChild
|
||
variant="default"
|
||
size="tiny"
|
||
className="w-min"
|
||
iconRight={<ArrowUpRightIcon aria-hidden="true" size={14} strokeWidth={1.5} />}
|
||
>
|
||
<a
|
||
href="https://supabase.com/launch-week"
|
||
target="_blank"
|
||
rel="noopener noreferrer"
|
||
onClick={handleDismiss}
|
||
>
|
||
Claim your ticket
|
||
</a>
|
||
</Button>
|
||
</div>
|
||
</BannerCard>
|
||
)
|
||
}
|
||
|
||
export const LaunchWeek16BannerRegistration = () => {
|
||
const { addBanner, dismissBanner } = useBannerStack()
|
||
const [isDismissed, , { isSuccess: isDismissalLoaded }] = useLocalStorageQuery(
|
||
LAUNCH_WEEK_16_DISMISSAL_KEY,
|
||
false
|
||
)
|
||
const [now, setNow] = useState<number>()
|
||
|
||
useEffect(() => {
|
||
const syncClock = () => setNow(Date.now())
|
||
syncClock()
|
||
const timeout = setTimeout(syncClock, Math.max(0, LAUNCH_WEEK_16_EXPIRES_AT - Date.now()))
|
||
window.addEventListener('focus', syncClock)
|
||
window.addEventListener('pageshow', syncClock)
|
||
document.addEventListener('visibilitychange', syncClock)
|
||
|
||
return () => {
|
||
clearTimeout(timeout)
|
||
window.removeEventListener('focus', syncClock)
|
||
window.removeEventListener('pageshow', syncClock)
|
||
document.removeEventListener('visibilitychange', syncClock)
|
||
}
|
||
}, [])
|
||
|
||
useEffect(() => {
|
||
if (now === undefined || !isDismissalLoaded) return
|
||
|
||
if (
|
||
shouldShowLaunchWeek16Banner({ isPlatform: IS_PLATFORM, isDismissalLoaded, isDismissed, now })
|
||
) {
|
||
addBanner({
|
||
id: BANNER_ID.LAUNCH_WEEK_16,
|
||
isDismissed: false,
|
||
priority: -1,
|
||
content: <BannerLaunchWeek16 />,
|
||
})
|
||
} else {
|
||
dismissBanner(BANNER_ID.LAUNCH_WEEK_16)
|
||
}
|
||
}, [addBanner, dismissBanner, isDismissalLoaded, isDismissed, now])
|
||
|
||
useEffect(() => () => dismissBanner(BANNER_ID.LAUNCH_WEEK_16), [dismissBanner])
|
||
|
||
return null
|
||
}
|