Files
supabase/apps/studio/components/ui/BannerStack/BannerStack.tsx
Francesco Sansalvadore a098c3be32 chore(studio): improve versioning onboarding comms (#54059)
## Problem

We're going to release versioning in Public Alpha instead of Private, so
we need to be more clear and loud about the new feature being
introduced.

## Solution

This PR makes a few changes mostly around communications and messaging:
- Update `Private Alpha` badges to `Public Alpha`
- Add admonitions in the feature preview modal
- Prompt confirmation before enabling versioning on a bucket
- Dedicated announcement banner in Storage layout
- shown only to users with `storage.capabilities.object_versioning`
enabled
- Popover card when hovering over the Public Alpha badge

See
[update](https://linear.app/supabase/project/storage-object-versioning-and-lifecycle-policies-b5e5809a718e/activity#project-update-e9a50e15)
for more context.

## Review instructions

Functionality changes are minor so mostly check the above mentioned
messaging and ui changes.
2026-11-30 18:18:41 +01:00

88 lines
3.0 KiB
TypeScript

import { AnimatePresence, motion, useReducedMotion } from 'motion/react'
import { useState } from 'react'
import { useBannerStack } from './BannerStackProvider'
const PEEK_OFFSET = 8
const MAX_PEEKS = 2
const SPRING = { type: 'spring', stiffness: 300, damping: 30 } as const
export const BannerStack = () => {
const { banners } = useBannerStack()
const [isHovered, setIsHovered] = useState(false)
const [isFocused, setIsFocused] = useState(false)
const isExpanded = isHovered || isFocused
const reduceMotion = useReducedMotion()
const activeBanners = banners.filter((b) => !b.isDismissed)
if (activeBanners.length === 0) return null
const [frontBanner, ...extraBanners] = activeBanners
const peekCount = Math.min(extraBanners.length, MAX_PEEKS)
// Deepest sliver first so the closer ones paint on top of it.
const peeks = Array.from({ length: peekCount }, (_, i) => peekCount - i)
const transition = reduceMotion ? { duration: 0 } : SPRING
return (
<motion.div
className="fixed bottom-4 right-4 z-50 flex flex-col-reverse items-end gap-2"
onMouseEnter={() => setIsHovered(true)}
onMouseLeave={() => setIsHovered(false)}
onFocus={() => setIsFocused(true)}
onBlur={(event) => {
const nextTarget = event.relatedTarget
if (!(nextTarget instanceof Node) || !event.currentTarget.contains(nextTarget)) {
setIsFocused(false)
}
}}
animate={{ y: isExpanded ? -8 : 0 }}
transition={transition}
>
<div className="relative w-full max-w-72">
<AnimatePresence>
{!isExpanded &&
peeks.map((depth) => (
<motion.div
key={`peek-${depth}`}
className="absolute inset-0 rounded-2xl border bg-surface-75 shadow-lg"
style={{ transformOrigin: 'center top' }}
initial={{ opacity: 0 }}
animate={{ opacity: 1, y: -depth * PEEK_OFFSET, scaleX: 1 - depth * 0.06 }}
exit={{ opacity: 0, y: 0, scaleX: 1 }}
transition={transition}
/>
))}
</AnimatePresence>
<motion.div
className="relative z-10"
initial={{ opacity: 0, scale: 0.99, y: 8 }}
animate={{ opacity: 1, scale: 1, y: 0 }}
exit={{ opacity: 0, scale: 0.99, y: 8 }}
transition={transition}
>
{frontBanner.content}
</motion.div>
</div>
<AnimatePresence>
{isExpanded &&
extraBanners.map((banner, index) => (
<motion.div
key={banner.id}
className="w-full max-w-72"
initial={{ opacity: 0, scale: 0.98, y: 8 }}
animate={{ opacity: 1, scale: 1, y: 0 }}
exit={{ opacity: 0, scale: 0.98, y: 8 }}
transition={reduceMotion ? { duration: 0 } : { ...SPRING, delay: index * 0.04 }}
>
{banner.content}
</motion.div>
))}
</AnimatePresence>
</motion.div>
)
}