Skip to content

Commit 18fc360

Browse files
committed
pricing: Add tooltip with credits per dollar info on subscription tier
1 parent 99ac3a1 commit 18fc360

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

web/src/app/pricing/pricing-client.tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ import { cn } from '@/lib/utils'
3030

3131
import type { SubscriptionResponse } from '@codebuff/common/types/subscription'
3232

33+
const WEEKS_PER_MONTH = 4
34+
const CREDITS_PER_DOLLAR = Object.fromEntries(
35+
Object.entries(SUBSCRIPTION_TIERS).map(([key, tier]) => [
36+
Number(key),
37+
Math.floor(tier.weeklyCreditsLimit * WEEKS_PER_MONTH / tier.monthlyPrice),
38+
]),
39+
) as Record<number, number>
40+
3341
const USAGE_MULTIPLIER: Record<number, string> = {
3442
100: '1×',
3543
200: '3×',
@@ -241,6 +249,21 @@ function PricingCardsGrid() {
241249

242250
<p className="text-sm sm:text-base font-medium text-white/60 mb-3 sm:mb-6">
243251
{USAGE_MULTIPLIER[price]} usage
252+
<TooltipProvider delayDuration={200}>
253+
<Tooltip>
254+
<TooltipTrigger asChild>
255+
<span tabIndex={0} className="inline-flex items-center ml-1 cursor-help align-middle">
256+
<HelpCircle className="h-3.5 w-3.5 text-white/30 hover:text-white/60 transition-colors" />
257+
</span>
258+
</TooltipTrigger>
259+
<TooltipContent
260+
side="bottom"
261+
className="bg-black/90 border-white/10 text-white/80 text-sm max-w-xs"
262+
>
263+
Up to {CREDITS_PER_DOLLAR[price]} credits per dollar
264+
</TooltipContent>
265+
</Tooltip>
266+
</TooltipProvider>
244267
</p>
245268

246269
<SubscribeButton

0 commit comments

Comments
 (0)