@olwiba/ui 0.2.12 → 0.2.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@olwiba/ui",
3
- "version": "0.2.12",
3
+ "version": "0.2.13",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -3,7 +3,7 @@
3
3
  import * as React from 'react';
4
4
  import { Check, Minus } from 'lucide-react';
5
5
  import { Badge, Button, cn, Separator, useUIVariant } from '@olwiba/cn';
6
- import { AnimatedSwap } from '../motion/AnimatedSwap';
6
+ import { AnimatedSwap, type AnimatedSwapEffect, type AnimatedSwapSpec } from '../motion/AnimatedSwap';
7
7
 
8
8
  export interface PricingFeature {
9
9
  label: string;
@@ -24,6 +24,15 @@ export interface PricingCardProps extends React.HTMLAttributes<HTMLDivElement> {
24
24
  badge?: React.ReactNode;
25
25
  /** Rendered directly below the CTA button (e.g. a "Get notified" link). */
26
26
  footer?: React.ReactNode;
27
+ /**
28
+ * How the price transitions when a cadence toggle swaps it. Omit and the
29
+ * current UI mode decides — `fade` in default, `roll` in playful, `slide` in
30
+ * smooth — which is the right answer for a product that has picked a mode
31
+ * and wants every swap on the page to agree with it. Set it when the price
32
+ * specifically should read as a mechanism (`'roll'`) without moving the
33
+ * whole app to playful.
34
+ */
35
+ priceEffect?: AnimatedSwapEffect | AnimatedSwapSpec;
27
36
  onSelect?: () => void;
28
37
  }
29
38
 
@@ -39,6 +48,7 @@ export function PricingCard({
39
48
  ctaDisabled = false,
40
49
  badge,
41
50
  footer,
51
+ priceEffect,
42
52
  onSelect,
43
53
  className,
44
54
  ...props
@@ -71,8 +81,13 @@ export function PricingCard({
71
81
  <div className="flex items-end gap-1">
72
82
  {/* Animates when a billing-cadence toggle swaps the price out. The
73
83
  price is its own swap key: a card whose price never changes never
74
- animates. */}
75
- <AnimatedSwap swapKey={price} className="text-4xl font-bold tracking-tight">
84
+ animates. `effect` undefined leaves AnimatedSwap on the mode
85
+ default. */}
86
+ <AnimatedSwap
87
+ swapKey={price}
88
+ effect={priceEffect}
89
+ className="text-4xl font-bold tracking-tight"
90
+ >
76
91
  {price}
77
92
  </AnimatedSwap>
78
93
  <span className="mb-1 text-sm text-muted-foreground">{period}</span>
@@ -2,7 +2,7 @@
2
2
 
3
3
  import * as React from 'react';
4
4
  import { Badge, Button, cn, useUIVariant } from '@olwiba/cn';
5
- import { PricingCard, type PricingFeature } from '../components/PricingCard';
5
+ import { PricingCard, type PricingCardProps, type PricingFeature } from '../components/PricingCard';
6
6
  import { StaggerChildren } from '../motion/StaggerChildren';
7
7
  import { CountdownTimer } from '../motion/CountdownTimer';
8
8
  import type { AppShellRenderLink } from '../app/AppShell';
@@ -140,6 +140,13 @@ export interface PricingSectionProps {
140
140
  onSelectPlan?: (plan: PricingPlan, cadence?: string) => void;
141
141
  /** Marks one plan as busy (e.g. its checkout is being created). */
142
142
  pendingPlanName?: string;
143
+ /**
144
+ * How each card's price transitions when the cadence toggle changes it.
145
+ * Omit and the current UI mode decides (see `PricingCard.priceEffect`) —
146
+ * pass `'roll'` for an odometer on a product that is otherwise in default
147
+ * mode.
148
+ */
149
+ priceEffect?: PricingCardProps['priceEffect'];
143
150
  }
144
151
 
145
152
  const defaultRenderLink: AppShellRenderLink = ({ href, children, className }) => (
@@ -164,6 +171,7 @@ export function PricingSection({
164
171
  defaultCadence,
165
172
  onSelectPlan,
166
173
  pendingPlanName,
174
+ priceEffect,
167
175
  }: PricingSectionProps) {
168
176
  const [annual, setAnnual] = React.useState(false);
169
177
  const isOneTime = mode === 'one-time';
@@ -314,6 +322,7 @@ export function PricingSection({
314
322
  ctaDisabled={plan.ctaDisabled || pendingPlanName === plan.name}
315
323
  badge={badge}
316
324
  footer={renderPlanFooter?.(plan)}
325
+ priceEffect={priceEffect}
317
326
  onSelect={
318
327
  onSelectPlan
319
328
  ? () => onSelectPlan(plan, useCadences ? activeCadence : undefined)