{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"hero-split","type":"registry:block","title":"Split hero","description":"The promise and three reasons beside the product itself: a live dashboard in a browser frame.","dependencies":["lucide-react"],"registryDependencies":["https://dashral.com/r/utils.json","https://dashral.com/r/lib-motion.json","https://dashral.com/r/bar-list.json","https://dashral.com/r/button.json","https://dashral.com/r/metric-card.json","https://dashral.com/r/segmented-control.json","https://dashral.com/r/sparkline.json"],"files":[{"path":"registry/dashral/blocks/hero-split.tsx","type":"registry:file","target":"components/dashral/blocks/hero-split.tsx","content":"\"use client\"\n\nimport { useState } from \"react\"\nimport { ArrowRight, Check, DollarSign, Users } from \"lucide-react\"\nimport { BarList } from \"../bar-list\"\nimport { Button } from \"../button\"\nimport { MetricCard } from \"../metric-card\"\nimport { SegmentedControl } from \"../segmented-control\"\nimport { Sparkline } from \"../sparkline\"\nimport { enterMotion, stagger } from \"../lib/motion\"\nimport { cn } from \"../lib/utils\"\n\n/** A button: a link with href, or your handler with onClick. */\nexport type BlockAction = { label: string; href?: string; onClick?: () => void }\n/** One period the preview can switch to: its figures, their trends and the top pages. */\nexport type HeroPeriod = {\n  value: string\n  label: string\n  revenue: number\n  revenueChange: number\n  users: number\n  usersChange: number\n  trend: number[]\n  usersTrend: number[]\n  pages: { label: string; value: number }[]\n}\n\nconst samplePeriods: HeroPeriod[] = [\n  {\n    value: \"week\",\n    label: \"7 days\",\n    revenue: 12840,\n    revenueChange: 8.2,\n    users: 1204,\n    usersChange: 3.1,\n    trend: [12, 14, 13, 17, 16, 19, 22],\n    usersTrend: [150, 162, 158, 171, 168, 180, 189],\n    pages: [\n      { label: \"/pricing\", value: 3120 },\n      { label: \"/\", value: 2650 },\n      { label: \"/docs/start\", value: 1480 },\n    ],\n  },\n  {\n    value: \"month\",\n    label: \"30 days\",\n    revenue: 48290,\n    revenueChange: 12.5,\n    users: 4810,\n    usersChange: 6.4,\n    trend: [31, 34, 33, 38, 36, 41, 40, 44, 43, 47, 46, 52],\n    usersTrend: [320, 338, 352, 349, 371, 380, 395, 402, 398, 415, 428, 441],\n    pages: [\n      { label: \"/\", value: 11800 },\n      { label: \"/pricing\", value: 9420 },\n      { label: \"/blog/launch\", value: 5210 },\n    ],\n  },\n]\n\n/**\n * A split hero: the promise, three reasons and the actions on one side; on the other, the product itself — a small\n * live dashboard in a browser frame, where switching the period moves every number. Stacks on phones. Every part\n * comes from props, the preview's numbers too.\n */\nexport function HeroSplit({\n  eyebrow = \"Analytics for product teams\",\n  title = \"Know what’s working, the day it starts working\",\n  description = \"Connect your store and your app once. Acme keeps every chart current, so Monday’s meeting starts with answers.\",\n  points = [\"Live numbers, no spreadsheets\", \"Sign-in, roles and an audit log\", \"Self-host it or let us run it\"],\n  primary = { label: \"Start free trial\", href: \"#\" },\n  secondary = { label: \"Talk to sales\", href: \"#\" },\n  address = \"app.acme.com/overview\",\n  periods = samplePeriods,\n  defaultPeriod = \"month\",\n  currency = \"USD\",\n}: {\n  eyebrow?: React.ReactNode\n  title?: React.ReactNode\n  description?: React.ReactNode\n  points?: string[]\n  primary?: BlockAction\n  /** The second button; null hides it. */\n  secondary?: BlockAction | null\n  /** The preview's address bar. */\n  address?: string\n  periods?: HeroPeriod[]\n  defaultPeriod?: string\n  currency?: string\n}) {\n  const [period, setPeriod] = useState(defaultPeriod)\n  const data = periods.find((p) => p.value === period) ?? periods[0]!\n\n  return (\n    <section className=\"relative isolate overflow-hidden bg-background px-4 py-16 sm:px-6 sm:py-24\">\n      <div aria-hidden className=\"absolute top-0 right-0 -z-10 size-[40rem] translate-x-1/3 -translate-y-1/3 rounded-full bg-primary/10 blur-3xl\" />\n\n      <div className=\"mx-auto grid max-w-6xl items-center gap-12 lg:grid-cols-[1fr_1.1fr] lg:gap-16\">\n        <div>\n          {eyebrow && (\n            <p className={cn(enterMotion, \"text-sm font-medium text-primary-text\")} style={stagger(0, 80)}>\n              {eyebrow}\n            </p>\n          )}\n          <h1 className={cn(enterMotion, \"mt-3 text-4xl leading-[1.08] font-semibold tracking-[-0.035em] text-balance sm:text-5xl\")} style={stagger(1, 80)}>\n            {title}\n          </h1>\n          {description && (\n            <p className={cn(enterMotion, \"mt-5 max-w-lg text-base leading-relaxed text-muted-foreground sm:text-lg\")} style={stagger(2, 80)}>\n              {description}\n            </p>\n          )}\n          <ul className={cn(enterMotion, \"mt-7 space-y-3 empty:hidden\")} style={stagger(3, 80)}>\n            {points.map((point) => (\n              <li key={point} className=\"flex items-center gap-3 text-sm\">\n                <span className=\"grid size-5 shrink-0 place-items-center rounded-full bg-success/15 text-success-text\">\n                  <Check className=\"size-3\" aria-hidden />\n                </span>\n                {point}\n              </li>\n            ))}\n          </ul>\n          <div className={cn(enterMotion, \"mt-9 flex flex-wrap gap-3\")} style={stagger(4, 80)}>\n            <Action action={primary}>\n              {primary.label} <ArrowRight aria-hidden />\n            </Action>\n            {secondary && (\n              <Action action={secondary} variant=\"ghost\">\n                {secondary.label}\n              </Action>\n            )}\n          </div>\n        </div>\n\n        {/* The product, live: a browser frame with real components inside. */}\n        <div className={cn(enterMotion, \"min-w-0\")} style={stagger(2, 80)}>\n          <div className=\"overflow-hidden rounded-2xl border bg-card shadow-[0_24px_80px_-24px_rgb(0_0_0/0.25)] dark:shadow-[0_24px_80px_-24px_rgb(0_0_0/0.8)]\">\n            <div aria-hidden className=\"flex h-10 items-center gap-1.5 border-b px-4\">\n              <span className=\"size-2.5 rounded-full bg-muted-foreground/25\" />\n              <span className=\"size-2.5 rounded-full bg-muted-foreground/25\" />\n              <span className=\"size-2.5 rounded-full bg-muted-foreground/25\" />\n              <span className=\"mx-auto rounded-md bg-muted px-3 py-0.5 text-xs text-muted-foreground\">{address}</span>\n            </div>\n            <div className=\"space-y-4 bg-muted/30 p-4 sm:p-5\">\n              <div className=\"flex items-center justify-between gap-3\">\n                <p className=\"text-sm font-medium\">Overview</p>\n                {periods.length > 1 && (\n                  <SegmentedControl aria-label=\"Period\" value={data.value} onValueChange={setPeriod} options={periods.map(({ value, label }) => ({ value, label }))} />\n                )}\n              </div>\n              <div className=\"grid gap-3 sm:grid-cols-2\">\n                <MetricCard\n                  label=\"Revenue\"\n                  value={data.revenue}\n                  formatOptions={{ style: \"currency\", currency, maximumFractionDigits: 0 }}\n                  change={data.revenueChange}\n                  changeLabel=\"vs last period\"\n                  icon={<DollarSign />}\n                >\n                  <Sparkline key={period} data={data.trend} variant=\"area\" className=\"h-9 text-primary\" aria-label=\"Revenue trend: rising\" />\n                </MetricCard>\n                <MetricCard label=\"Active users\" value={data.users} change={data.usersChange} changeLabel=\"vs last period\" icon={<Users />}>\n                  <Sparkline key={period} data={data.usersTrend} variant=\"bar\" min={0} className=\"h-9 text-primary\" aria-label=\"Active users trend: rising\" />\n                </MetricCard>\n              </div>\n              <div className=\"rounded-xl border bg-card p-4\">\n                <p className=\"mb-3 text-sm font-medium\">Top pages</p>\n                <BarList items={data.pages} />\n              </div>\n            </div>\n          </div>\n        </div>\n      </div>\n    </section>\n  )\n}\n\n/** A large button that follows its action: a link, or a handler. */\nfunction Action({ action, variant, className, children }: { action: BlockAction; variant?: \"outline\" | \"ghost\"; className?: string; children: React.ReactNode }) {\n  return action.href ? (\n    <Button size=\"lg\" variant={variant} className={className} asChild>\n      <a href={action.href}>{children}</a>\n    </Button>\n  ) : (\n    <Button size=\"lg\" variant={variant} className={className} onClick={action.onClick}>\n      {children}\n    </Button>\n  )\n}\n"}],"cssVars":{"theme":{"color-primary-text":"var(--primary-text, var(--primary))","color-success":"var(--success)","color-success-foreground":"var(--success-foreground)","color-success-text":"var(--success-text)"},"light":{"success":"oklch(0.508 0.118 165.612)","success-foreground":"oklch(0.985 0 0)","success-text":"oklch(0.432 0.095 166.913)"},"dark":{"success":"oklch(0.696 0.17 162.48)","success-foreground":"oklch(0.2 0.04 160)","success-text":"oklch(0.765 0.177 163.223)"}}}