# Add the "Fundraising Progress" block to this P1 project

Add a Puck component from P1 Blocks (https://p1-blocks.prolificdigital.io/blocks/impact-progress) to this Pantheon Content Publisher (P1) Next.js project. A campaign goal with an accessible progress bar and quick-give amounts.

## Steps

1. Create `components/puck/impact-progress-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 { impactProgressBlock } from "./components/puck/impact-progress-block";`
3. Register it under `components` as `ImpactProgressBlock: impactProgressBlock`.
4. Add `"ImpactProgressBlock"` to the best-fitting entry in `categories` (this block's library category is "Conversion"). 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/impact-progress-block.tsx`

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

/**
 * Impact Progress — a fundraising or goal tracker with a progress bar, campaign stats and
 * quick-give amounts. Update the raised figure as gifts come in.
 * Register: `ImpactProgressBlock: impactProgressBlock` in puck.config.tsx.
 */

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

export type ImpactProgressProps = {
  heading: string;
  headingLevel: Heading;
  body: string;
  raised: number;
  goal: number;
  currency: string;
  donors: string;
  deadline: string;
  amountsLabel: string;
  amounts: { label: string; href: string }[];
  ctaLabel: string;
  ctaHref: string;
};

const formatNumber = (n: number) => Math.round(n).toLocaleString("en-US");

export const impactProgressBlock: ComponentConfig<ImpactProgressProps> = {
  label: "Impact Progress",
  fields: {
    heading: { type: "textarea", 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." },
    },
    body: { type: "textarea", label: "Body" },
    raised: { type: "number", label: "Amount raised", min: 0, metadata: { help: "Whole number, no symbols or commas." } },
    goal: { type: "number", label: "Goal", min: 0, metadata: { help: "Whole number. Set to 0 to hide the bar and show only the total raised." } },
    currency: { type: "text", label: "Currency symbol", metadata: { help: "Shown before each amount, like $ or €." } },
    donors: { type: "text", label: "Donors", metadata: { help: "Free text, like 312 donors. Leave blank to hide it." } },
    deadline: { type: "text", label: "Deadline", metadata: { help: "Free text, like Ends December 31. Leave blank to hide it." } },
    amountsLabel: { type: "text", label: "Quick-give label", metadata: { help: "Small line above the amount buttons." } },
    amounts: {
      type: "array",
      label: "Quick-give amounts",
      min: 0,
      max: 6,
      getItemSummary: (item) => item?.label || "Amount",
      defaultItemProps: { label: "$50", href: "/donate?amount=50" },
      arrayFields: {
        label: { type: "text", label: "Button text", metadata: { help: "Include the symbol, like $50." } },
        href: { type: "text", label: "Link", metadata: { help: "Your donation form with the amount preset, if it supports that." } },
      },
    },
    ctaLabel: { type: "text", label: "Button text", metadata: { help: "Leave blank to hide it." } },
    ctaHref: { type: "text", label: "Button link" },
  },
  defaultProps: {
    heading: "Help us replant 2,000 trees along Mill Creek",
    headingLevel: "h2",
    body: "Last spring's floods took out a mile of shade canopy. Every gift buys native saplings, mulch and volunteer tools, and a local match doubles donations until the end of the year.",
    raised: 48250,
    goal: 75000,
    currency: "$",
    donors: "312 donors",
    deadline: "Ends December 31",
    amountsLabel: "Choose an amount",
    amounts: [
      { label: "$25", href: "/donate?amount=25" },
      { label: "$50", href: "/donate?amount=50" },
      { label: "$100", href: "/donate?amount=100" },
    ],
    ctaLabel: "Give any amount",
    ctaHref: "/donate",
  },
  render: ({ heading, headingLevel, body, raised, goal, currency, donors, deadline, amountsLabel, amounts, ctaLabel, ctaHref }) => {
    const H = headingLevel || "h2";
    const sym = currency ?? "";
    const raisedN = Math.max(0, Number(raised) || 0);
    const goalN = Math.max(0, Number(goal) || 0);
    const hasGoal = goalN > 0;
    const pct = hasGoal ? Math.min(100, Math.max(0, (raisedN / goalN) * 100)) : 0;
    const pctLabel = Math.floor(pct);
    const raisedText = `${sym}${formatNumber(raisedN)}`;
    const goalText = `${sym}${formatNumber(goalN)}`;
    const quick = (amounts ?? []).filter((a) => a?.label);
    const stats = [hasGoal ? `${pctLabel}% funded` : "", donors || "", deadline || ""].filter(Boolean);

    return (
      <section className="bg-neutral-50 px-4 py-16 sm:px-6 sm:py-20 lg:px-8 lg:py-24">
        <div className="mx-auto grid max-w-7xl items-center gap-10 lg:grid-cols-12 lg:gap-16">
          <div className="lg:col-span-6">
            {heading ? <H className="text-3xl font-semibold tracking-tight text-balance text-neutral-950 sm:text-4xl lg:text-5xl">{heading}</H> : null}
            {body ? <p className="mt-6 max-w-xl text-lg leading-8 text-pretty text-neutral-600">{body}</p> : null}
          </div>
          <div className="rounded-3xl bg-white p-6 shadow-xl ring-1 ring-neutral-900/5 sm:p-10 lg:col-span-6">
            <p className="flex flex-wrap items-baseline gap-x-3 gap-y-1">
              <span className="text-4xl font-semibold tracking-tight text-neutral-950 tabular-nums sm:text-5xl">{raisedText}</span>
              <span className="text-base text-neutral-600">
                raised{hasGoal ? <> of <span className="font-semibold text-neutral-950 tabular-nums">{goalText}</span> goal</> : null}
              </span>
            </p>
            {hasGoal ? (
              <div
                role="progressbar"
                aria-label="Fundraising progress"
                aria-valuemin={0}
                aria-valuemax={100}
                aria-valuenow={pctLabel}
                aria-valuetext={`${raisedText} raised of ${goalText} goal, ${pctLabel}%`}
                className="mt-6 h-3 w-full overflow-hidden rounded-full bg-neutral-200"
              >
                <div className="h-full rounded-full bg-indigo-600" style={{ width: `${pct}%` }} />
              </div>
            ) : null}
            {stats.length ? (
              <ul role="list" className="mt-4 flex flex-wrap gap-x-2 gap-y-1 text-sm font-medium text-neutral-600">
                {stats.map((s, i) => (
                  <li key={i} className="flex items-center gap-2">
                    {i > 0 ? <span aria-hidden="true" className="size-1 rounded-full bg-neutral-400" /> : null}
                    <span className={i === 0 && hasGoal ? "text-indigo-700" : undefined}>{s}</span>
                  </li>
                ))}
              </ul>
            ) : null}
            {quick.length || ctaLabel ? (
              <div className="mt-8 border-t border-neutral-200 pt-8">
                {quick.length ? (
                  <>
                    {amountsLabel ? <p className="text-sm font-semibold text-neutral-950">{amountsLabel}</p> : null}
                    <ul role="list" className={`grid grid-cols-2 gap-3 sm:grid-cols-3 ${amountsLabel ? "mt-3" : ""}`}>
                      {quick.map((a, i) => (
                        <li key={`${a.label}-${i}`}>
                          <a
                            href={a.href || ctaHref || "#"}
                            className="flex min-h-12 items-center justify-center rounded-lg bg-white px-3 py-2 text-lg font-semibold text-neutral-950 tabular-nums ring-1 ring-neutral-300 transition ring-inset hover:-translate-y-0.5 hover:bg-indigo-50 hover:text-indigo-700 hover:ring-indigo-600 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600"
                          >
                            {a.label}
                          </a>
                        </li>
                      ))}
                    </ul>
                  </>
                ) : null}
                {ctaLabel ? (
                  <a
                    href={ctaHref || "#"}
                    className={`flex min-h-12 w-full items-center justify-center gap-2 rounded-lg bg-indigo-600 px-5 py-3 text-base font-semibold text-white shadow-sm transition hover:bg-indigo-700 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600 ${quick.length ? "mt-4" : ""}`}
                  >
                    <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="size-5">
                      <path d="m9.653 16.915-.005-.003-.019-.01a20.759 20.759 0 0 1-1.162-.682 22.045 22.045 0 0 1-2.582-1.9C4.045 12.733 2 10.352 2 7.5a4.5 4.5 0 0 1 8-2.828A4.5 4.5 0 0 1 18 7.5c0 2.852-2.044 5.233-3.885 6.82a22.049 22.049 0 0 1-3.744 2.582l-.019.01-.005.003h-.002a.739.739 0 0 1-.69.001l-.002-.001Z" />
                    </svg>
                    {ctaLabel}
                  </a>
                ) : null}
              </div>
            ) : null}
          </div>
        </div>
      </section>
    );
  },
};
```
