{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "growth",
  "type": "registry:block",
  "title": "Growth block",
  "description": "Twelve weeks of growth as one screen: sign-ups by source as thin stacked columns with a legend and a week range that filter them, the funnel from visit to paid and retention by signup week. Each source keeps one data hue.",
  "registryDependencies": [
    "https://littmd.vercel.app/r/litt.json",
    "https://littmd.vercel.app/r/chart.json",
    "https://littmd.vercel.app/r/cohort-grid.json",
    "https://littmd.vercel.app/r/funnel.json",
    "https://littmd.vercel.app/r/legend.json",
    "https://littmd.vercel.app/r/slider.json",
    "https://littmd.vercel.app/r/sparkline.json",
    "https://littmd.vercel.app/r/stat.json",
    "https://littmd.vercel.app/r/tag.json"
  ],
  "files": [
    {
      "path": "registry/litt/components/litt-blocks/growth.tsx",
      "type": "registry:component",
      "content": "\"use client\";\n// @litt/growth 2026.10.26. What changed: https://littmd.vercel.app/changelog.md\n\n/**\n * Growth: twelve weeks of a store's growth, drawn in rails. A block: a whole screen built from the litt parts, to copy\n * and make your own. Swap the sample data at the top for yours; the layout, the hues and the words around them stay.\n *\n * Sign-ups by source stack into thin columns you can filter by source (the Legend) and by week (the RangeSlider), then\n * the funnel from visit to paid and retention by signup week. Each source keeps one hue (R7), everything else stays in\n * the foreground, and only the chart's entrance moves. The grid measures itself, so it stacks in a narrow box.\n */\nimport { useId, useState, type ReactNode } from \"react\";\nimport { StackedBarChart, type ChartSeries } from \"../litt/chart\";\nimport { CohortGrid, type Cohort } from \"../litt/cohort-grid\";\nimport { Funnel } from \"../litt/funnel\";\nimport { Legend } from \"../litt/legend\";\nimport { RangeSlider } from \"../litt/slider\";\nimport { Sparkline } from \"../litt/sparkline\";\nimport { Stat, StatGroup } from \"../litt/stat\";\nimport { Tag } from \"../litt/tag\";\n\n/* ----------------------------------------------------------------- data */\n\n/** A seeded generator (mulberry32), so the block draws the same data on every load and on the server. */\nfunction seeded(seed: number) {\n  let a = seed >>> 0;\n  return () => {\n    a = (a + 0x6d2b79f5) >>> 0;\n    let t = a;\n    t = Math.imul(t ^ (t >>> 15), t | 1);\n    t ^= t + Math.imul(t ^ (t >>> 7), t | 61);\n    return ((t ^ (t >>> 14)) >>> 0) / 4294967296;\n  };\n}\n\nconst WEEKS = [\"4 Aug\", \"11 Aug\", \"18 Aug\", \"25 Aug\", \"1 Sep\", \"8 Sep\", \"15 Sep\", \"22 Sep\", \"29 Sep\", \"6 Oct\", \"13 Oct\", \"20 Oct\"];\n\n/** Twelve weeks that grow from a level, with some noise. */\nfunction weekly(seed: number, level: number, growth: number) {\n  const next = seeded(seed);\n  return WEEKS.map((_, i) => Math.max(0, Math.round(level * (1 + growth * i) * (0.85 + next() * 0.3))));\n}\n\n/* Each source keeps one hue everywhere on the page (R7): the legend, the chart and the tooltip agree. */\nconst SOURCES: ChartSeries[] = [\n  { name: \"Search\", values: weekly(11, 120, 0.06), hue: \"blue\" },\n  { name: \"Social\", values: weekly(12, 70, 0.11), hue: \"amber\" },\n  { name: \"Referral\", values: weekly(13, 40, 0.09), hue: \"teal\" },\n  { name: \"Direct\", values: weekly(14, 30, 0.03), hue: \"violet\" },\n];\n\nconst total = (values: number[]) => values.reduce((s, v) => s + v, 0);\nconst groupDigits = (n: number) => n.toLocaleString(\"en-GB\");\n\n/** Retention by signup week: each cohort starts at 100% and settles, and later cohorts have fewer weeks behind them. */\nfunction cohorts(): Cohort[] {\n  const next = seeded(21);\n  return WEEKS.slice(-8).map((label, c) => {\n    const weeks = 8 - c;\n    let level = 100;\n    const values = Array.from({ length: weeks }, (_, w) => {\n      if (w === 0) return 100;\n      level = level * (w === 1 ? 0.46 + next() * 0.06 : 0.86 + next() * 0.06);\n      return Math.round(level);\n    });\n    return { label: `Week of ${label}`, size: Math.round(260 + next() * 120 + c * 18), values };\n  });\n}\nconst COHORTS = cohorts();\n\n/* ----------------------------------------------------------------- the page */\n\n/** A section of the page: a small heading, a quiet note, and its rails. No box: the air does the separating. */\nfunction Section({ title, note, children }: { title: string; note: string; children: ReactNode }) {\n  const id = useId();\n  return (\n    <section aria-labelledby={id} className=\"grid min-w-0 content-start gap-6\">\n      <div className=\"grid gap-1\">\n        <h4 id={id} className=\"text-litt-body text-litt-fg\">\n          {title}\n        </h4>\n        <p className=\"text-litt-small text-litt-fg-subtle\">{note}</p>\n      </div>\n      {children}\n    </section>\n  );\n}\n\nexport function Growth() {\n  const [hidden, setHidden] = useState<string[]>([]);\n  const [range, setRange] = useState<[number, number]>([0, WEEKS.length - 1]);\n  const [from, to] = range;\n  const labels = WEEKS.slice(from, to + 1);\n  const shown = SOURCES.filter((s) => !hidden.includes(s.name)).map((s) => ({ ...s, values: s.values.slice(from, to + 1) }));\n  const signups = SOURCES.map((s) => total(s.values.slice(from, to + 1)));\n\n  return (\n    <div className=\"@container w-full\">\n      <div className=\"grid grid-cols-1 gap-16\">\n        <header className=\"flex flex-wrap items-center gap-3\">\n          <h3 className=\"text-litt-h3 text-litt-fg\">Halo templates</h3>\n          <Tag>Store</Tag>\n          <Tag>Last 12 weeks</Tag>\n        </header>\n\n        <StatGroup>\n          <Stat label=\"Visitors\" value=\"64,210\" delta=\"Up 18% on the 12 weeks before\" tone=\"good\" trend={<Sparkline label=\"Visitors per week\" values={weekly(31, 4200, 0.05)} />} />\n          <Stat label=\"Sign-ups\" value={groupDigits(total(SOURCES.flatMap((s) => s.values)))} delta=\"Up 24%\" tone=\"good\" trend={<Sparkline label=\"Sign-ups per week\" values={WEEKS.map((_, i) => total(SOURCES.map((s) => s.values[i] ?? 0)))} />} />\n          <Stat label=\"Paid\" value={748} delta=\"Up 9%\" tone=\"good\" trend={<Sparkline label=\"New paid accounts per week\" values={weekly(33, 52, 0.03)} />} />\n          <Stat label=\"Week 4 retention\" value={34} unit=\"%\" delta=\"Down 2 points\" tone=\"bad\" />\n        </StatGroup>\n\n        <Section title=\"Sign-ups by source\" note=\"Each week is one rail, a hue per source. Hide a source or narrow the weeks, and the colors stay with their sources.\">\n          <div className=\"grid gap-6 @min-[44rem]:grid-cols-[minmax(0,1fr)_16rem] @min-[44rem]:items-end\">\n            <Legend\n              label=\"Sources\"\n              items={SOURCES.map((s, i) => ({ name: s.name, hue: s.hue, value: groupDigits(signups[i]!) }))}\n              hidden={hidden}\n              onHiddenChange={setHidden}\n            />\n            <RangeSlider\n              label=\"Weeks\"\n              min={0}\n              max={WEEKS.length - 1}\n              value={range}\n              onValueChange={setRange}\n              minStepsBetweenThumbs={1}\n              showValue\n              formatValue={(i) => WEEKS[i] ?? \"\"}\n              thumbLabels={[\"First week\", \"Last week\"]}\n            />\n          </div>\n          <StackedBarChart label=\"Sign-ups per week by source\" labels={labels} series={shown} unit={[\"sign-up\", \"sign-ups\"]} xTitle=\"Week of\" height={256} legend={false} />\n        </Section>\n\n        <div className=\"grid grid-cols-1 gap-16 @min-[52rem]:grid-cols-[minmax(0,2fr)_minmax(0,3fr)]\">\n          <Section title=\"Funnel\" note=\"October, from a first visit to a paid plan. One quantity, one hue.\">\n            <Funnel\n              label=\"Visit to paid, October\"\n              steps={[\n                { label: \"Visited\", value: 18240 },\n                { label: \"Signed up\", value: 6930 },\n                { label: \"Made a site\", value: 2840 },\n                { label: \"Paid\", value: 748 },\n              ]}\n            />\n          </Section>\n          <Section title=\"Retention\" note=\"The share of each signup week still active, week by week. Later weeks have less behind them.\">\n            <CohortGrid label=\"Retention by signup week\" cohorts={COHORTS} average />\n          </Section>\n        </div>\n      </div>\n    </div>\n  );\n}\n",
      "target": "components/litt-blocks/growth.tsx"
    }
  ],
  "docs": "Import Growth from components/litt-blocks/growth. The sample weeks and sources sit at the top of the file: give each of your sources its own hue and keep it when the legend hides one. See it live at https://littmd.vercel.app/#growth.",
  "meta": {
    "version": "2026.10.26",
    "released": "2026-10-26",
    "changelog": "https://littmd.vercel.app/changelog.md"
  }
}
