# Add the "Theory of Change" block to this P1 project

Add a Puck component from P1 Blocks (https://p1-blocks.prolificdigital.io/blocks/theory-of-change) to this Pantheon Content Publisher (P1) Next.js project. Stages from inputs to impact as an ordered flow: left to right with arrows on desktop, stacked on phones.

## Steps

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

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

/**
 * Theory of Change — how your work turns resources into lasting change, shown as a flow of
 * stages that deepen in color from inputs to impact. Reads left to right on wide screens and
 * top to bottom on phones. Register: `TheoryOfChangeBlock: theoryOfChangeBlock` in puck.config.tsx.
 */

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

export type TheoryOfChangeProps = {
  eyebrow: string;
  heading: string;
  headingLevel: Heading;
  intro: string;
  stages: { label: string; description: string; items: string }[];
  footnote: string;
};

const childHeading = { h1: "h2", h2: "h3", h3: "h4", h4: "h5" } as const;

// Tints deepen toward the final stage; the last stage always gets the solid treatment.
const tints = [
  "bg-white ring-neutral-200",
  "bg-indigo-50 ring-indigo-100",
  "bg-indigo-100 ring-indigo-200",
  "bg-indigo-200 ring-indigo-300",
  "bg-indigo-200 ring-indigo-300",
];

export const theoryOfChangeBlock: ComponentConfig<TheoryOfChangeProps> = {
  label: "Theory of Change",
  fields: {
    eyebrow: {
      type: "text",
      label: "Eyebrow",
      metadata: {
        help: "Small line above the heading. Leave blank to hide it.",
      },
    },
    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. Stage names use the next level down.",
      },
    },
    intro: { type: "textarea", label: "Intro" },
    stages: {
      type: "array",
      label: "Stages",
      min: 2,
      max: 6,
      getItemSummary: (item, i) => item?.label || `Stage ${(i ?? 0) + 1}`,
      defaultItemProps: {
        label: "New stage",
        description: "What happens at this stage.",
        items: "",
      },
      arrayFields: {
        label: {
          type: "text",
          label: "Stage name",
          metadata: {
            help: "Like Inputs, Activities, Outputs, Outcomes or Impact.",
          },
        },
        description: {
          type: "textarea",
          label: "Description",
          metadata: { help: "One or two sentences." },
        },
        items: {
          type: "textarea",
          label: "Examples",
          metadata: { help: "One per line. Leave blank to hide the list." },
        },
      },
    },
    footnote: {
      type: "textarea",
      label: "Footnote",
      metadata: {
        help: "Small print under the flow, like how you measure progress. Leave blank to hide it.",
      },
    },
  },
  defaultProps: {
    eyebrow: "Our theory of change",
    heading: "How one steady adult changes a young person's path",
    headingLevel: "h2",
    intro:
      "Mentoring works when it lasts. Everything we do is built to keep matches together long enough for trust to turn into confidence, and confidence into choices.",
    stages: [
      {
        label: "Inputs",
        description: "The people and resources we bring.",
        items:
          "Screened, trained volunteer mentors\nSchool and library partners\nCase managers for every match",
      },
      {
        label: "Activities",
        description: "What mentors and mentees do together.",
        items:
          "Weekly one-on-one meetings\nMonthly group outings\nFamily check-ins",
      },
      {
        label: "Outputs",
        description: "What we can count each year.",
        items:
          "Matches made and sustained\nHours spent together\nReferrals to tutoring and services",
      },
      {
        label: "Outcomes",
        description: "Changes we see in young people.",
        items:
          "Better school attendance\nStronger sense of belonging\nClear plans after high school",
      },
      {
        label: "Impact",
        description: "The long-term change we are working toward.",
        items:
          "Young adults who finish school, find meaningful work and give back",
      },
    ],
    footnote:
      "We track outputs every quarter and outcomes through annual mentee and family surveys.",
  },
  render: ({ id, eyebrow, heading, headingLevel, intro, stages, footnote }) => {
    const H = headingLevel || "h2";
    const Sub = childHeading[headingLevel] || "h3";
    const list = (stages ?? []).filter((s) => s?.label);
    const headingId = `p1-toc-${id}-heading`;
    const count = list.length;

    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 max-w-7xl">
          <div className="max-w-3xl">
            {eyebrow ? (
              <p className="text-sm font-semibold tracking-widest text-indigo-700 uppercase">
                {eyebrow}
              </p>
            ) : null}
            {heading ? (
              <H
                id={headingId}
                className={`text-3xl font-semibold tracking-tight text-balance text-neutral-950 sm:text-4xl lg:text-5xl ${eyebrow ? "mt-3" : ""}`}
              >
                {heading}
              </H>
            ) : null}
            {intro ? (
              <p className="mt-5 text-lg leading-8 text-pretty text-neutral-600">
                {intro}
              </p>
            ) : null}
          </div>

          {count ? (
            <ol
              aria-labelledby={heading ? headingId : undefined}
              className="mt-12 grid grid-cols-1 gap-12 sm:mt-16 lg:auto-cols-fr lg:grid-flow-col lg:gap-6"
            >
              {list.map((stage, i) => {
                const last = i === count - 1;
                const examples = (stage.items || "")
                  .split("\n")
                  .map((l) => l.trim())
                  .filter(Boolean);
                return (
                  <li
                    key={`${stage.label}-${i}`}
                    className={`relative flex flex-col rounded-2xl p-6 ring-1 ring-inset lg:p-5 xl:p-6 ${last ? "bg-indigo-700 text-white ring-indigo-700 shadow-lg shadow-indigo-900/20" : `${tints[Math.min(i, tints.length - 1)]} text-neutral-950`}`}
                  >
                    <p
                      className={`text-xs font-semibold tracking-widest tabular-nums uppercase ${last ? "text-indigo-100" : "text-indigo-700"}`}
                    >
                      Stage {String(i + 1).padStart(2, "0")}
                    </p>
                    <Sub className="mt-2 text-xl font-semibold tracking-tight text-balance">
                      {stage.label}
                    </Sub>
                    {stage.description ? (
                      <p
                        className={`mt-2 text-base leading-7 text-pretty lg:text-sm lg:leading-6 xl:text-base xl:leading-7 ${last ? "text-indigo-50" : "text-neutral-700"}`}
                      >
                        {stage.description}
                      </p>
                    ) : null}
                    {examples.length ? (
                      <ul
                        role="list"
                        className={`mt-5 space-y-2.5 border-t pt-5 text-sm leading-6 ${last ? "border-white/20 text-white" : "border-neutral-900/10 text-neutral-800"}`}
                      >
                        {examples.map((ex, j) => (
                          <li key={j} className="flex gap-2.5">
                            <span
                              aria-hidden="true"
                              className={`mt-2.5 h-px w-3 shrink-0 ${last ? "bg-indigo-200" : "bg-indigo-600"}`}
                            />
                            <span className="min-w-0">{ex}</span>
                          </li>
                        ))}
                      </ul>
                    ) : null}
                    {!last ? (
                      <span
                        aria-hidden="true"
                        className="absolute -bottom-10 left-1/2 z-10 grid size-8 -translate-x-1/2 place-items-center rounded-full bg-white text-indigo-700 shadow-sm ring-1 ring-neutral-200 lg:top-1/2 lg:-right-7 lg:bottom-auto lg:left-auto lg:translate-x-0 lg:-translate-y-1/2"
                      >
                        <svg
                          viewBox="0 0 16 16"
                          fill="currentColor"
                          className="size-4 rotate-90 lg:rotate-0"
                        >
                          <path
                            fillRule="evenodd"
                            d="M2 8a.75.75 0 0 1 .75-.75h8.69L8.22 4.03a.75.75 0 0 1 1.06-1.06l4.5 4.5a.75.75 0 0 1 0 1.06l-4.5 4.5a.75.75 0 0 1-1.06-1.06l3.22-3.22H2.75A.75.75 0 0 1 2 8Z"
                            clipRule="evenodd"
                          />
                        </svg>
                      </span>
                    ) : null}
                  </li>
                );
              })}
            </ol>
          ) : null}

          {footnote ? (
            <p className="mt-10 max-w-3xl text-sm leading-6 text-pretty text-neutral-600">
              {footnote}
            </p>
          ) : null}
        </div>
      </section>
    );
  },
};
```
