Files
supabase/apps/studio/components/ui/BannerStack/Banners/BannerLaunchWeek16.tsx
kemal.earth 82e4becf37 fix(studio): lw banner priority (#54605)
## Problem

The Launch Week 16 banner could be outranked by other banners in the
shared `BannerStack` and pushed out of the front/top slot.

## Solution

Set its `priority` to `Number.POSITIVE_INFINITY` in
`BannerLaunchWeek16.tsx` so it always sorts to the front, regardless of
other banners' priority values.

## Review instructions

1. Trigger the launch week banner alongside at least one other banner.
2. Confirm the launch week banner is always the front/top card in the
stack.
2026-12-04 11:18:11 +00:00

109 lines
3.5 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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: Number.POSITIVE_INFINITY,
content: <BannerLaunchWeek16 />,
})
} else {
dismissBanner(BANNER_ID.LAUNCH_WEEK_16)
}
}, [addBanner, dismissBanner, isDismissalLoaded, isDismissed, now])
useEffect(() => () => dismissBanner(BANNER_ID.LAUNCH_WEEK_16), [dismissBanner])
return null
}