{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "pricing-01",
  "title": "Two plans with a billing switch",
  "description": "A monthly and yearly segmented switch whose thumb travels while the digits of both prices roll to their new value, over two plans with example prices.",
  "dependencies": [],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/badge.json",
    "https://ui.ndekocode.dev/r/button.json",
    "https://ui.ndekocode.dev/r/chip.json",
    "https://ui.ndekocode.dev/r/motion-number.json",
    "https://ui.ndekocode.dev/r/motion-word-roll.json",
    "https://ui.ndekocode.dev/r/tabs.json",
    "https://ui.ndekocode.dev/r/theme.json",
    "https://ui.ndekocode.dev/r/utils.json",
    "https://ui.ndekocode.dev/r/wash.json"
  ],
  "files": [
    {
      "path": "registry/ndeko/blocks/pricing/pricing-01/index.tsx",
      "content": "'use client';\n\nimport { useState } from 'react';\n\nimport { MotionNumber } from '@/components/core/motion-number';\nimport { WordRoll } from '@/components/core/word-roll';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { Badge } from '@/registry/ndeko/ui/badge';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport { Chip } from '@/registry/ndeko/ui/chip';\nimport { Tabs, TabsList, TabsTab } from '@/registry/ndeko/ui/tabs';\nimport { Wash } from '@/registry/ndeko/ui/wash';\n\nimport {\n  type BillingPeriod,\n  DEFAULT_PERIOD,\n  type Plan,\n  PLANS,\n  SECTION,\n} from './data';\n\nconst MONTHS_PER_YEAR = 12;\n\nconst PERIOD_ORDER: Record<BillingPeriod, number> = {\n  monthly: 0,\n  yearly: 1,\n};\n\nconst PRICE_FORMAT: Intl.NumberFormatOptions = {\n  style: 'currency',\n  currency: 'USD',\n  maximumFractionDigits: 0,\n};\n\nconst PRICE_FORMATTER = new Intl.NumberFormat('en-US', PRICE_FORMAT);\n\nconst PLAN_SURFACE =\n  'bg-card hairline-ring ring-border shadow-[0_1px_2px_rgb(0_0_0/0.04)] dark:bg-foreground/[0.03]';\n\nfunction isBillingPeriod(value: unknown): value is BillingPeriod {\n  const isMonthly = value === 'monthly';\n  const isYearly = value === 'yearly';\n  return isMonthly || isYearly;\n}\n\nfunction formatPrice(amount: number) {\n  return PRICE_FORMATTER.format(amount);\n}\n\nfunction monthlyFigureOf(plan: Plan, period: BillingPeriod) {\n  if (period === 'yearly') {\n    return plan.yearlyPrice / MONTHS_PER_YEAR;\n  }\n  return plan.monthlyPrice;\n}\n\nfunction billingNoteOf(plan: Plan, period: BillingPeriod) {\n  if (period === 'yearly') {\n    const total = formatPrice(plan.yearlyPrice);\n    return `Billed ${total} once a year`;\n  }\n  return 'Billed every month';\n}\n\nfunction surfaceOf(plan: Plan) {\n  if (plan.isFeatured) {\n    return 'surface-brand';\n  }\n  return PLAN_SURFACE;\n}\n\nfunction actionVariantOf(plan: Plan) {\n  if (plan.isFeatured) {\n    return 'default' as const;\n  }\n  return 'outline' as const;\n}\n\ntype PlanCardProps = {\n  plan: Plan;\n  period: BillingPeriod;\n};\n\nfunction PlanCard({ plan, period }: PlanCardProps) {\n  const figure = monthlyFigureOf(plan, period);\n  const note = billingNoteOf(plan, period);\n  const periodOrder = PERIOD_ORDER[period];\n  const surface = surfaceOf(plan);\n  const actionVariant = actionVariantOf(plan);\n\n  return (\n    <article\n      className={cn(\n        'relative isolate flex flex-col gap-6 rounded-xl p-6 sm:p-7',\n        surface\n      )}\n    >\n      {plan.isFeatured && <Wash />}\n      <div className='flex flex-col gap-1.5'>\n        <div className='flex items-center justify-between gap-3'>\n          <h3 className='text-sm font-medium'>{plan.name}</h3>\n          {plan.tag && <Chip>{plan.tag}</Chip>}\n        </div>\n        <p className='text-muted-foreground text-[13px]'>{plan.description}</p>\n      </div>\n      <div aria-live='polite' className='flex flex-col gap-1'>\n        <p className='flex items-baseline gap-1.5'>\n          <MotionNumber\n            value={figure}\n            format={PRICE_FORMAT}\n            className='text-4xl font-semibold'\n          />\n          <span className='text-muted-foreground text-[13px]'>per month</span>\n        </p>\n        <p className='text-muted-foreground text-xs tabular-nums'>\n          <WordRoll text={note} value={periodOrder} />\n        </p>\n      </div>\n      <Button\n        size='lg'\n        variant={actionVariant}\n        nativeButton={false}\n        render={<a href='#' />}\n      >\n        {plan.action}\n      </Button>\n      <ul className='flex flex-col gap-2.5 text-[13px]'>\n        {plan.features.map((feature) => (\n          <li key={feature} className='flex items-center gap-2.5'>\n            <span\n              aria-hidden='true'\n              className='bg-foreground/25 size-1 shrink-0 rounded-full'\n            />\n            {feature}\n          </li>\n        ))}\n      </ul>\n    </article>\n  );\n}\n\nexport default function Pricing01() {\n  const [period, setPeriod] = useState<BillingPeriod>(DEFAULT_PERIOD);\n\n  function changePeriod(value: unknown) {\n    if (isBillingPeriod(value)) {\n      setPeriod(value);\n    }\n  }\n\n  return (\n    <section className='px-4 py-16 sm:px-6 sm:py-24 lg:px-8'>\n      <div className='mx-auto flex max-w-4xl flex-col gap-10'>\n        <div className='grid gap-6 md:grid-cols-[minmax(0,1fr)_auto] md:items-end'>\n          <div className='flex flex-col gap-3'>\n            <h2 className='text-2xl font-semibold text-balance sm:text-3xl'>\n              {SECTION.title}\n            </h2>\n            <p className='text-muted-foreground max-w-lg text-base text-pretty'>\n              {SECTION.description}\n            </p>\n          </div>\n          <div className='flex items-center gap-3'>\n            <Tabs value={period} onValueChange={changePeriod}>\n              <TabsList variant='segmented' aria-label='Billing period'>\n                <TabsTab value='monthly'>Monthly</TabsTab>\n                <TabsTab value='yearly'>Yearly</TabsTab>\n              </TabsList>\n            </Tabs>\n            <Badge variant='secondary' className='text-muted-foreground'>\n              {SECTION.yearlyNote}\n            </Badge>\n          </div>\n        </div>\n        <div className='grid gap-4 md:grid-cols-2'>\n          {PLANS.map((plan) => (\n            <PlanCard key={plan.id} plan={plan} period={period} />\n          ))}\n        </div>\n        <p className='text-muted-foreground text-xs'>{SECTION.footnote}</p>\n      </div>\n    </section>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/pricing-01/index.tsx"
    },
    {
      "path": "registry/ndeko/blocks/pricing/pricing-01/data.ts",
      "content": "export type BillingPeriod = 'monthly' | 'yearly';\n\nexport type Plan = {\n  id: string;\n  name: string;\n  description: string;\n  monthlyPrice: number;\n  yearlyPrice: number;\n  features: string[];\n  action: string;\n  isFeatured: boolean;\n  tag?: string;\n};\n\nexport const DEFAULT_PERIOD: BillingPeriod = 'monthly';\n\nexport const SECTION = {\n  title: 'Two plans, both with every editor feature',\n  description:\n    'Start alone and move to Studio when other people write with you. Your subscribers and archive come along.',\n  yearlyNote: 'Two months free',\n  footnote: 'Example prices in US dollars, taxes added at checkout',\n};\n\nexport const PLANS: Plan[] = [\n  {\n    id: 'writer',\n    name: 'Writer',\n    description: 'For one person and one newsletter',\n    monthlyPrice: 12,\n    yearlyPrice: 120,\n    features: [\n      'One newsletter',\n      'Up to 2,000 subscribers',\n      'Scheduled sends',\n      'Your own domain',\n    ],\n    action: 'Start with Writer',\n    isFeatured: false,\n  },\n  {\n    id: 'studio',\n    name: 'Studio',\n    description: 'For a small team with several publications',\n    monthlyPrice: 30,\n    yearlyPrice: 300,\n    features: [\n      'Everything in Writer',\n      'Up to five newsletters',\n      'Up to 20,000 subscribers',\n      'Three editor seats',\n      'Paid subscriptions',\n    ],\n    action: 'Start with Studio',\n    isFeatured: true,\n    tag: 'For teams',\n  },\n];\n",
      "type": "registry:component",
      "target": "components/blocks/pricing-01/data.ts"
    }
  ],
  "categories": [
    "blocks",
    "pricing"
  ],
  "type": "registry:block"
}