Files
supabase/apps/www/components/Pricing/PricingAddons.tsx
anthony lio 1a37362821 chore(billing): plan selection styling (#53841)
## Problem

- plan cards on the studio upgrade screen do not match recent plan cards
updates to the pricing page
- add-on illustrations on the pricing page sometimes show the light
image in dark mode
- spend cap bars on the pricing page flash when a user toggles the spend
cap


## Solution

- changes the upgrade screen plan cards to the pricing page design +
shows enterprise as a fourth column
- moves the lifted card style to the current plan of the organization +
gives it a neutral "current plan" badge
- moves the compare plans and pricing faq links below the plan cards +
removes the stagger animation on the cards
- changes the pricing page illustrations to pick the light or dark image
with css because the server render does not know the theme
- changes the spend cap animation to resize the bars instead of
remounting them
2026-11-24 18:04:01 +08:00

185 lines
6.1 KiB
TypeScript

'use client'
import { ArrowUpRight } from 'lucide-react'
import Image from 'next/image'
import Link from 'next/link'
import { FC } from 'react'
import { Button, cn } from 'ui'
import CostControlAnimation from './CostControlAnimation'
import { isCrossZoneHref } from '@/lib/cross-zone'
const addons = [
{
id: 'addon-cost-control',
name: 'Cost Control',
price: 'Available on Pro Plan',
heroImg: <CostControlAnimation className="relative w-full h-full lg:max-w-md" />,
description:
"The Pro Plan has a spend cap enabled by default to keep costs under control. If you want to scale beyond the plan's included quota, simply switch off the spend cap to pay for additional resources.",
ctaText: 'Learn about Cost Control',
ctaLink: 'https://supabase.com/docs/guides/platform/cost-control#spend-cap',
ctaTarget: '_blank',
},
{
id: 'addon-custom-domain',
name: 'Custom Domain',
heroImg: 'custom-domain-on',
icon: 'custom-domain-upgrade',
price: 'Flat fee $10/month',
description:
'Use your own domain for your Supabase project to present a branded experience to your users.',
ctaText: 'Documentation',
ctaLink: 'https://supabase.com/docs/guides/platform/custom-domains',
ctaTarget: '_blank',
},
{
id: 'addon-pitr',
name: 'Point in Time Recovery',
heroImg: 'pitr-on',
icon: 'pitr-upgrade',
price: 'Starts from $100/month',
description: 'Roll back to any specific point in time, down to the second.',
ctaText: 'Documentation',
ctaLink: 'https://supabase.com/docs/guides/platform/backups',
ctaTarget: '_blank',
},
]
const PricingAddons: FC = () => {
return (
<div>
<div className="text-center">
<h2 className="text-foreground text-3xl">Fine-tune your project</h2>
<p className="text-foreground-light mt-4 mb-8 lg:mb-16 text-lg">
Go beyond your Plan limits and level up your Supabase experience
</p>
</div>
<div className="grid lg:grid-cols-2 gap-4 mb-16 mx-auto max-w-6xl">
{addons.map((addon) => (
<AddonCard key={addon.name} addon={addon} />
))}
</div>
</div>
)
}
const AddonCard = ({ addon }: any) => {
const basePath = '' // basePath is empty string in next.config.mjs
const isHighlightCard = addon.id === 'addon-cost-control'
const containerClasses = cn(
'group relative bg-surface-100 border rounded-lg gap-4 transition-colors',
isHighlightCard && 'flex flex-col lg:flex-row lg:h-[300px] col-span-2',
!isHighlightCard &&
'flex flex-col lg:flex-row hover:border-stronger hover:bg-surface-200 col-span-2 sm:col-span-1'
)
const HighlightCard = () => (
<>
<div className="relative order-last lg:order-first w-full max-w-full lg:w-auto lg:h-full aspect-2/1 lg:aspect-3/2 p-4 pt-0 lg:pt-4 lg:pr-0">
{addon.heroImg}
</div>
<div className="p-4 gap-4 flex flex-col justify-center">
<div className="flex flex-col gap-2">
<p className="text-[13px] text-foreground-lighter" translate="no">
{addon.price}
</p>
<div className="flex items-center gap-2">
<h3 className="text-foreground text-2xl">{addon.name}</h3>
</div>
<p className="text-foreground-lighter text-[13px] text-base xl:pr-8">
{addon.description}
</p>
</div>
<div className="flex items-center gap-4 mt-4">
<Button asChild size="tiny" iconRight={<ArrowUpRight className="w-4 h-4" />}>
{isCrossZoneHref(addon.ctaLink) ? (
<a href={addon.ctaLink} target={addon.ctaTarget}>
{addon.ctaText}
</a>
) : (
<Link href={addon.ctaLink} target={addon.ctaTarget}>
{addon.ctaText}
</Link>
)}
</Button>
</div>
</div>
</>
)
const SmallCard = () => (
<>
<div
className={cn(
'relative w-full hidden lg:block md:aspect-[1.53/1] md:h-auto max-w-[200px]',
addon.id === 'addon-pitr' && 'lg:flex items-end'
)}
>
<Image
src={`${basePath}/images/pricing/${addon.heroImg}-light.svg`}
alt={`${addon.name} illustration`}
fill
className={cn('object-contain dark:hidden', addon.id === 'addon-pitr' && 'object-bottom')}
/>
<Image
src={`${basePath}/images/pricing/${addon.heroImg}.svg`}
alt={`${addon.name} illustration`}
fill
className={cn(
'hidden object-contain dark:block',
addon.id === 'addon-pitr' && 'object-bottom'
)}
/>
</div>
<div className="p-4 lg:pl-0 lg:-ml-2 xl:ml-0 gap-4 col-span-2">
<div className="flex flex-col gap-2">
<p className="text-[13px] text-foreground-lighter" translate="no">
{addon.price}
</p>
<div className="flex items-center gap-2">
<Image
src={`${basePath}/images/pricing/${addon.icon}-light.svg`}
width={14}
height={14}
alt="Compute"
className="dark:hidden"
/>
<Image
src={`${basePath}/images/pricing/${addon.icon}.svg`}
width={14}
height={14}
alt="Compute"
className="hidden dark:block"
/>
<h3 className="text-sm text-foreground">{addon.name}</h3>
</div>
<p className="text-foreground-lighter text-[13px]">{addon.description}</p>
</div>
</div>
<div className="absolute right-0 flex justify-end p-4">
<ArrowUpRight className="w-5 h-5 text-foreground-lighter group-hover:text-foreground transition-colors" />
</div>
</>
)
return isHighlightCard ? (
<div className={containerClasses}>
<HighlightCard />
</div>
) : isCrossZoneHref(addon.ctaLink) ? (
<a href={addon.ctaLink} className={containerClasses} target={addon.ctaTarget}>
<SmallCard />
</a>
) : (
<Link href={addon.ctaLink} className={containerClasses} target={addon.ctaTarget}>
<SmallCard />
</Link>
)
}
export default PricingAddons