{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "insights-01",
  "description": "A list of plain-language insights, each with its kind as a coloured word, its topic, the key figures picked out, an optional line on the drivers and a link to explore.",
  "registryDependencies": [
    "card",
    "button",
    "https://www.dashboardblocks.com/r/radix/block-state.json",
    "https://www.dashboardblocks.com/r/radix/details.json",
    "https://www.dashboardblocks.com/r/radix/insights.json"
  ],
  "files": [
    {
      "path": "registry/components/dashboardblocks/insights/insights-01.tsx",
      "content": "'use client'\n\nimport {\n  BlockStateProvider,\n  BlockStateRows,\n  type BlockStateProps,\n  getBlockState,\n} from '@/registry/components/dashboardblocks/block-state'\nimport { Details } from '@/registry/components/dashboardblocks/details'\nimport {\n  type InsightDriver,\n  InsightDrivers,\n  type InsightKind,\n  InsightLabel,\n  type InsightSegment,\n  InsightText,\n  insightToString,\n} from '@/registry/components/dashboardblocks/insights'\nimport { IconPlaceholder } from '@/registry/icons/icon-placeholder'\n\nimport { buttonVariants } from '@/components/ui/button'\nimport { Card, CardContent } from '@/components/ui/card'\n\ninterface InsightItem {\n  /** @default 'Explore' */\n  actionLabel?: string\n  drivers?: InsightDriver[]\n  href?: string\n  id: string\n  kind: InsightKind\n  segments: InsightSegment[]\n  topic: string\n}\n\ninterface Insights1Props extends BlockStateProps {\n  description: string\n  /** Leave out, or pass none, to show the empty state. */\n  insights?: InsightItem[]\n  title: string\n}\n\nconst exampleProps: Insights1Props = {\n  description: 'What moved from Sep 14 to 20, against the week before.',\n  insights: [\n    {\n      drivers: [\n        { label: 'Organic search', tone: 'positive', value: '+812' },\n        { label: 'Referral', tone: 'positive', value: '+264' },\n      ],\n      href: '#',\n      id: 'i1',\n      kind: 'positive',\n      segments: [\n        'Signups ',\n        { text: 'up 24%', tone: 'positive' },\n        ' to ',\n        { text: '6,634' },\n        ', driven by organic search after the pricing page launch.',\n      ],\n      topic: 'Acquisition',\n    },\n    {\n      actionLabel: 'Investigate',\n      href: '#',\n      id: 'i2',\n      kind: 'anomaly',\n      segments: [\n        'Checkout conversions dropped to ',\n        { text: '212', tone: 'negative' },\n        ' on Tuesday, ',\n        { text: '42% below', tone: 'negative' },\n        ' what was expected. Traffic was normal that day.',\n      ],\n      topic: 'Checkout',\n    },\n    {\n      drivers: [\n        { label: 'Starter plan', tone: 'negative', value: '+0.6 pp' },\n        { label: 'Annual plans', tone: 'positive', value: '−0.1 pp' },\n      ],\n      href: '#',\n      id: 'i3',\n      kind: 'negative',\n      segments: [\n        'Monthly churn ',\n        { text: 'rose to 3.1%', tone: 'negative' },\n        ' from 2.6%, mostly among Starter customers in their first 60 days.',\n      ],\n      topic: 'Retention',\n    },\n    {\n      href: '#',\n      id: 'i4',\n      kind: 'neutral',\n      segments: [\n        'Mobile now accounts for ',\n        { text: '52%' },\n        ' of sessions, the first week it has passed desktop.',\n      ],\n      topic: 'Traffic',\n    },\n  ],\n  title: 'Insights',\n}\n\nconst Insights1 = (props: Insights1Props) => {\n  const { description, insights = [], errorMessage, status, title } = props\n\n  return (\n    <Card>\n      <CardContent>\n        <BlockStateProvider\n          errorMessage={errorMessage}\n          state={getBlockState(status, insights)}\n        >\n          <section className='@container flex flex-col gap-4'>\n            <header className='flex flex-col gap-0.5'>\n              <h2 className='font-semibold tracking-tight'>{title}</h2>\n              <p className='text-muted-foreground text-sm'>{description}</p>\n            </header>\n            <BlockStateRows className='border-t' />\n            {!status && insights.length > 0 && (\n              <ul className='divide-y border-t'>\n                {insights.map((insight) => (\n                  <li\n                    key={insight.id}\n                    className='flex flex-col gap-3 py-4 @lg:flex-row @lg:items-start @lg:gap-6'\n                  >\n                    <div className='flex min-w-0 flex-1 flex-col gap-1.5'>\n                      <Details className='text-muted-foreground text-xs'>\n                        <InsightLabel\n                          className='text-xs'\n                          kind={insight.kind}\n                          variant='text'\n                        />\n                        {insight.topic}\n                      </Details>\n                      <InsightText segments={insight.segments} />\n                      {insight.drivers && <InsightDrivers drivers={insight.drivers} />}\n                    </div>\n                    {insight.href && (\n                      <a\n                        href={insight.href}\n                        aria-label={`${insight.actionLabel ?? 'Explore'}: ${insightToString(insight.segments)}`}\n                        className={buttonVariants({\n                          className: 'self-start',\n                          size: 'sm',\n                          variant: 'outline',\n                        })}\n                      >\n                        {insight.actionLabel ?? 'Explore'}\n                        <IconPlaceholder\n                          lucide='ArrowRightIcon'\n                          tabler='IconArrowRight'\n                          hugeicons='ArrowRight01Icon'\n                          phosphor='ArrowRightIcon'\n                          remixicon='RiArrowRightLine'\n                          data-icon='inline-end'\n                        />\n                      </a>\n                    )}\n                  </li>\n                ))}\n              </ul>\n            )}\n          </section>\n        </BlockStateProvider>\n      </CardContent>\n    </Card>\n  )\n}\n\nexport { Insights1, exampleProps as insights1ExampleProps, type Insights1Props }\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/insights/insights-01.tsx"
    }
  ],
  "meta": {
    "shows": "A list of plain-language insights, each with its kind as a coloured word, its topic, the key figures picked out, an optional line on the drivers and a link to explore.",
    "size": "half",
    "usedWith": [
      "insights-02",
      "insights-03",
      "stat-group-02"
    ],
    "component": "Insights1",
    "props": "{ description: string; insights?: { actionLabel?: string; drivers?: { label: string; value: string; tone?: \"neutral\" | \"positive\" | \"negative\" }[]; href?: string; id: string; kind: \"neutral\" | \"positive\" | \"negative\" | \"anomaly\"; segments: (string | { text: string; tone?: \"neutral\" | \"positive\" | \"negative\" })[]; topic: string }[]; title: string; errorMessage?: string; status?: \"loading\" | \"error\" }"
  },
  "type": "registry:component"
}
