# Add the "Budget Snapshot" block to this P1 project

Add a Puck component from P1 Blocks (https://p1-blocks.prolificdigital.io/blocks/budget-snapshot) to this Pantheon Content Publisher (P1) Next.js project. Where tax dollars go: spending categories as sorted bars labeled with dollars and percent of total.

## Steps

1. Create `components/puck/budget-snapshot-block.tsx` with the exact file contents below. If `components/puck/` doesn't exist, find the folder where this project keeps its Puck components (look at the imports in `puck.config.tsx`) and put it there.
2. In `puck.config.tsx`, import it: `import { budgetSnapshotBlock } from "./components/puck/budget-snapshot-block";`
3. Register it under `components` as `BudgetSnapshotBlock: budgetSnapshotBlock`.
4. Add `"BudgetSnapshotBlock"` to the best-fitting entry in `categories` (this block's library category is "Municipal"). Create a category only if none fits.
5. Run the project's type check (usually `pnpm typecheck`) and resolve anything project-specific.
6. If `package.json` has a `sync:registry` script, tell the user it must run (or that CI will run it) before the new component appears in the P1 editor.

## Rules

- Do not add dependencies. The block is self-contained by design: one type-only import from `@puckeditor/core`, Tailwind v4 classes, no client JavaScript.
- Keep the files as-is unless the user asks for changes. The accent color is `indigo-*`; if the project has brand colors, offer to swap them with a find-and-replace on `indigo-`.
- Images are plain `imageUrl` + `imageAlt` text fields. If this project defines a P1 media-library field (search for `"p1-media"`), offer to switch to it.
- Don't change prop names in `defaultProps`. Content editors' saved pages depend on them.

## File: `components/puck/budget-snapshot-block.tsx`

```tsx
import type { ComponentConfig } from "@puckeditor/core";

/**
 * Budget Snapshot — where tax dollars go, as a sorted bar list. Every bar states its dollar
 * amount and share as text, computed from the amounts you enter, with a required source line.
 * Register: `BudgetSnapshotBlock: budgetSnapshotBlock` in puck.config.tsx.
 */

type Heading = "h1" | "h2" | "h3" | "h4";

export type BudgetSnapshotProps = {
  heading: string;
  headingLevel: Heading;
  intro: string;
  fiscalYear: string;
  totalLabel: string;
  categories: {
    name: string;
    amount: number;
    description: string;
  }[];
  source: string;
  exploreLabel: string;
  exploreHref: string;
  downloadLabel: string;
  downloadHref: string;
};

const focusRing = "focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600";

const money = new Intl.NumberFormat("en-US", { style: "currency", currency: "USD", notation: "compact", maximumFractionDigits: 1 });

const percent = (share: number) => {
  if (share <= 0) return "0%";
  if (share < 0.01) return "Under 1%";
  return `${Math.round(share * 100)}%`;
};

export const budgetSnapshotBlock: ComponentConfig<BudgetSnapshotProps> = {
  label: "Budget Snapshot",
  fields: {
    heading: { type: "text", label: "Heading" },
    headingLevel: {
      type: "select",
      label: "Heading level",
      options: [
        { label: "H1", value: "h1" },
        { label: "H2", value: "h2" },
        { label: "H3", value: "h3" },
        { label: "H4", value: "h4" },
      ],
      metadata: { help: "Sets the page outline for screen readers and search. The look doesn't change." },
    },
    intro: { type: "textarea", label: "Intro" },
    fiscalYear: { type: "text", label: "Fiscal year", metadata: { help: "Like Fiscal year 2027 (July 2026 to June 2027)." } },
    totalLabel: { type: "text", label: "Total budget", metadata: { help: "Shown as written, like $48.6 million. Percentages are calculated from the category amounts below." } },
    categories: {
      type: "array",
      label: "Spending categories",
      min: 1,
      max: 12,
      getItemSummary: (item) => (item?.name ? `${item.name} · ${money.format(Number(item.amount) || 0)}` : "Category"),
      defaultItemProps: { name: "New category", amount: 0, description: "" },
      arrayFields: {
        name: { type: "text", label: "Category" },
        amount: { type: "number", label: "Amount (dollars)", min: 0, metadata: { help: "Whole dollars, no commas, like 12400000. Bars are sorted largest first." } },
        description: { type: "text", label: "What it pays for", metadata: { help: "Optional. A short phrase, like Patrol, 911 dispatch and investigations." } },
      },
    },
    source: { type: "text", label: "Source", metadata: { help: "Required for public trust. Name the document the figures come from." } },
    exploreLabel: { type: "text", label: "Explore link text", metadata: { help: "Leave blank to hide it." } },
    exploreHref: { type: "text", label: "Explore link", metadata: { help: "Your open budget or transparency portal." } },
    downloadLabel: { type: "text", label: "Download link text", metadata: { help: "Leave blank to hide it." } },
    downloadHref: { type: "text", label: "Download link", metadata: { help: "Link to the adopted budget file." } },
  },
  defaultProps: {
    heading: "Where your tax dollars go",
    headingLevel: "h2",
    intro: "Every year the City Council adopts a balanced budget after public hearings. Here's how the general fund is divided among city services.",
    fiscalYear: "Fiscal year 2027",
    totalLabel: "$48.6 million",
    categories: [
      { name: "Public safety", amount: 17800000, description: "Police, fire, EMS and 911 dispatch" },
      { name: "Streets and transportation", amount: 9200000, description: "Paving, snow removal, sidewalks and signals" },
      { name: "Parks and recreation", amount: 6100000, description: "Parks, pools, trails and community centers" },
      { name: "General government", amount: 5400000, description: "Council, clerk, finance, IT and legal" },
      { name: "Debt service", amount: 4300000, description: "Payments on bonds for past capital projects" },
      { name: "Community development", amount: 3200000, description: "Planning, permits, inspections and housing" },
      { name: "Library", amount: 2600000, description: "Two branches, programs and digital lending" },
    ],
    source: "Source: Adopted FY2027 budget, City of Millbrook. Sample data.",
    exploreLabel: "Explore the full budget",
    exploreHref: "/budget",
    downloadLabel: "Download budget (PDF, 4.1 MB)",
    downloadHref: "/documents/fy2027-adopted-budget.pdf",
  },
  render: ({ heading, headingLevel, intro, fiscalYear, totalLabel, categories, source, exploreLabel, exploreHref, downloadLabel, downloadHref }) => {
    const H = headingLevel || "h2";
    const rows = (categories ?? [])
      .filter((c) => c?.name)
      .map((c) => ({ ...c, amount: Math.max(0, Number(c.amount) || 0) }))
      .sort((a, b) => b.amount - a.amount);
    const total = rows.reduce((sum, r) => sum + r.amount, 0);
    const largest = rows[0]?.amount || 0;
    return (
      <section className="bg-white px-4 py-16 sm:px-6 sm:py-20 lg:px-8 lg:py-24">
        <div className="mx-auto grid max-w-7xl grid-cols-1 gap-10 lg:grid-cols-12 lg:gap-16">
          <div className="lg:col-span-5">
            {fiscalYear ? <p className="text-sm font-semibold tracking-wide text-indigo-700 uppercase">{fiscalYear}</p> : null}
            {heading ? (
              <H className={`text-3xl font-semibold tracking-tight text-balance text-neutral-950 sm:text-4xl ${fiscalYear ? "mt-3" : ""}`}>{heading}</H>
            ) : null}
            {intro ? <p className="mt-4 text-base leading-7 text-pretty text-neutral-600">{intro}</p> : null}
            {totalLabel ? (
              <div className="mt-8 border-l-4 border-indigo-600 pl-5">
                <p className="text-sm font-medium text-neutral-600">Total general fund</p>
                <p className="mt-1 text-4xl font-semibold tracking-tight text-neutral-950 tabular-nums sm:text-5xl">{totalLabel}</p>
              </div>
            ) : null}
            {exploreLabel || downloadLabel ? (
              <div className="mt-8 flex flex-col gap-3 sm:flex-row sm:flex-wrap sm:items-center sm:gap-x-6">
                {exploreLabel ? (
                  <a
                    href={exploreHref || "#"}
                    className={`inline-flex min-h-11 items-center justify-center rounded-lg bg-indigo-600 px-5 py-2.5 text-sm font-semibold text-white shadow-sm transition hover:bg-indigo-500 ${focusRing}`}
                  >
                    {exploreLabel}
                  </a>
                ) : null}
                {downloadLabel ? (
                  <a
                    href={downloadHref || "#"}
                    className={`group inline-flex min-h-11 items-center justify-center gap-2 rounded-lg px-1 text-sm font-semibold text-neutral-900 ${focusRing}`}
                  >
                    <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="size-5 text-indigo-600 transition group-hover:translate-y-0.5">
                      <path d="M10.75 2.75a.75.75 0 0 0-1.5 0v8.614L6.295 8.235a.75.75 0 1 0-1.09 1.03l4.25 4.5a.75.75 0 0 0 1.09 0l4.25-4.5a.75.75 0 0 0-1.09-1.03l-2.955 3.129V2.75Z" />
                      <path d="M3.5 12.75a.75.75 0 0 0-1.5 0v2.5A2.75 2.75 0 0 0 4.75 18h10.5A2.75 2.75 0 0 0 18 15.25v-2.5a.75.75 0 0 0-1.5 0v2.5c0 .69-.56 1.25-1.25 1.25H4.75c-.69 0-1.25-.56-1.25-1.25v-2.5Z" />
                    </svg>
                    {downloadLabel}
                  </a>
                ) : null}
              </div>
            ) : null}
          </div>

          {rows.length || source ? (
            <div className="lg:col-span-7">
              {rows.length ? (
                <ol role="list" className="space-y-6">
                  {rows.map((row, i) => {
                    const share = total > 0 ? row.amount / total : 0;
                    const width = largest > 0 ? (row.amount / largest) * 100 : 0;
                    return (
                      <li key={`${row.name}-${i}`}>
                        <div className="flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1">
                          <p className="text-base font-semibold text-neutral-950">{row.name}</p>
                          <p className="text-sm text-neutral-700 tabular-nums">
                            <span className="font-semibold text-neutral-950">{money.format(row.amount)}</span>
                            <span aria-hidden="true" className="px-1.5 text-neutral-400">·</span>
                            <span className="sr-only">, </span>
                            {total > 0 ? `${percent(share)} of total` : "Share not available"}
                          </p>
                        </div>
                        <div aria-hidden="true" className="mt-2 h-3 overflow-hidden rounded-full bg-neutral-100">
                          <div
                            className={`h-full rounded-full ${i === 0 ? "bg-indigo-700" : "bg-indigo-500"}`}
                            style={{ width: `${width > 0 ? Math.max(width, 1.5) : 0}%` }}
                          />
                        </div>
                        {row.description ? <p className="mt-2 text-sm leading-6 text-pretty text-neutral-600">{row.description}</p> : null}
                      </li>
                    );
                  })}
                </ol>
              ) : null}
              {source ? <p className={`text-sm leading-6 text-neutral-600 ${rows.length ? "mt-8 border-t border-neutral-200 pt-4" : ""}`}>{source}</p> : null}
            </div>
          ) : null}
        </div>
      </section>
    );
  },
};
```
