# Add the "Case Study Cards" block to this P1 project

Add a Puck component from P1 Blocks (https://p1-blocks.prolificdigital.io/blocks/case-study-cards) to this Pantheon Content Publisher (P1) Next.js project. Clickable partner cards pairing the challenge they brought with one headline result metric.

## Steps

1. Create `components/puck/case-study-cards-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 { caseStudyCardsBlock } from "./components/puck/case-study-cards-block";`
3. Register it under `components` as `CaseStudyCardsBlock: caseStudyCardsBlock`.
4. Add `"CaseStudyCardsBlock"` to the best-fitting entry in `categories` (this block's library category is "Social proof"). 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/case-study-cards-block.tsx`

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

/**
 * Case Study Cards — partner stories as cards: who, the challenge they brought, the result
 * as one headline metric, and a link to the full write-up. Whole card is clickable.
 * Register: `CaseStudyCardsBlock: caseStudyCardsBlock` in puck.config.tsx.
 */

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

type CaseStudy = {
  partner: string;
  sector: string;
  challenge: string;
  metric: string;
  metricLabel: string;
  imageUrl: string;
  imageAlt: string;
  href: string;
};

export type CaseStudyCardsProps = {
  heading: string;
  headingLevel: Heading;
  intro: string;
  cases: CaseStudy[];
  linkLabel: string;
  source: string;
};

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

const gridCols = (count: number) => {
  if (count <= 1) return "max-w-xl";
  if (count === 2) return "md:grid-cols-2";
  if (count === 4) return "md:grid-cols-2";
  return "md:grid-cols-2 lg:grid-cols-3";
};

export const caseStudyCardsBlock: ComponentConfig<CaseStudyCardsProps> = {
  label: "Case Study Cards",
  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", metadata: { help: "Optional sentence under the heading. Leave blank to hide it." } },
    cases: {
      type: "array",
      label: "Case studies",
      min: 1,
      max: 9,
      getItemSummary: (item) => [item?.partner, item?.metric].filter(Boolean).join(" · ").slice(0, 48) || "Case study",
      defaultItemProps: {
        partner: "Partner name",
        sector: "",
        challenge: "The problem they came to us with, in a sentence.",
        metric: "2×",
        metricLabel: "What improved",
        imageUrl: "",
        imageAlt: "",
        href: "",
      },
      arrayFields: {
        partner: { type: "text", label: "Partner" },
        sector: { type: "text", label: "Sector", metadata: { help: "Small label such as \"Public library\" or \"County parks\". Optional." } },
        challenge: { type: "textarea", label: "Challenge", metadata: { help: "One or two sentences." } },
        metric: { type: "text", label: "Result", metadata: { help: "The headline number: 3×, +41% or 1,200 hours." } },
        metricLabel: { type: "text", label: "Result label", metadata: { help: "What the number measures, in a few words." } },
        imageUrl: { type: "text", label: "Image URL", metadata: { help: "Optional 3:2 photo. Leave blank for a text-only card." } },
        imageAlt: { type: "text", label: "Image alt text", metadata: { help: "Describe the photo, or leave blank if it's decorative." } },
        href: { type: "text", label: "Link", metadata: { help: "The full case study. Without a link, the card isn't clickable." } },
      },
    },
    linkLabel: { type: "text", label: "Link text", metadata: { help: "Shown on every card with a link, such as \"Read the story\"." } },
    source: { type: "text", label: "Source note", metadata: { help: "Where the results come from. Shown under the cards. Leave blank to hide it." } },
  },
  defaultProps: {
    heading: "Partners who changed the numbers",
    headingLevel: "h2",
    intro: "We measure success by what our partners can do afterward. A few of the results from the past two years.",
    linkLabel: "Read the case study",
    source: "Sample figures for illustration · Source: partner program reports, 2024–2025",
    cases: [
      {
        partner: "Millbrook Public Library",
        sector: "Public library",
        challenge: "Teen programs averaged four attendees, and the branch was considering cutting them.",
        metric: "6×",
        metricLabel: "Teen attendance in one school year",
        imageUrl: "https://picsum.photos/seed/millbrook-library/900/600",
        imageAlt: "",
        href: "#",
      },
      {
        partner: "Sycamore County Parks",
        sector: "Parks & recreation",
        challenge: "Summer camp registration opened at 9 a.m. and sold out by 9:20, mostly to the same families.",
        metric: "+38%",
        metricLabel: "First-time families enrolled",
        imageUrl: "https://picsum.photos/seed/sycamore-parks/900/600",
        imageAlt: "",
        href: "#",
      },
      {
        partner: "Harbor Light Food Pantry",
        sector: "Food security",
        challenge: "Volunteers spent Saturday mornings on paper sign-in sheets instead of with neighbors.",
        metric: "11 hrs",
        metricLabel: "Volunteer time saved each week",
        imageUrl: "https://picsum.photos/seed/harbor-pantry/900/600",
        imageAlt: "",
        href: "#",
      },
    ],
  },
  render: ({ heading, headingLevel, intro, cases, linkLabel, source }) => {
    const H = headingLevel || "h2";
    const Sub = subLevel[headingLevel || "h2"];
    const list = (cases ?? []).filter((c) => c?.partner || c?.metric || c?.challenge);
    const hasHeader = Boolean(heading || intro);
    const cta = linkLabel || "Read the case study";

    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 max-w-7xl">
          {hasHeader ? (
            <div className="max-w-2xl">
              {heading ? <H className="text-3xl font-semibold tracking-tight text-balance text-neutral-950 sm:text-4xl">{heading}</H> : null}
              {intro ? <p className="mt-4 text-lg leading-8 text-pretty text-neutral-600">{intro}</p> : null}
            </div>
          ) : null}

          {list.length > 0 ? (
            <ul role="list" className={`${hasHeader ? "mt-12 sm:mt-16" : ""} grid grid-cols-1 gap-6 lg:gap-8 ${gridCols(list.length)}`}>
              {list.map((c, i) => (
                <li key={`${c.partner}-${i}`} className="flex">
                  <article className="group relative flex w-full flex-col overflow-hidden rounded-2xl bg-white ring-1 ring-neutral-950/10 transition hover:ring-indigo-600/40 hover:shadow-lg hover:shadow-neutral-950/5">
                    {c.imageUrl ? (
                      <img src={c.imageUrl} alt={c.imageAlt || ""} className="aspect-3/2 w-full bg-neutral-100 object-cover" />
                    ) : null}
                    <div className="flex flex-1 flex-col p-6 sm:p-7">
                      {c.sector ? <p className="text-xs font-semibold tracking-widest text-neutral-600 uppercase">{c.sector}</p> : null}
                      {c.partner ? <Sub className={`${c.sector ? "mt-2" : ""} text-lg font-semibold text-pretty text-neutral-950`}>{c.partner}</Sub> : null}
                      {c.challenge ? (
                        <div className="mt-4">
                          <p className="text-sm font-medium text-neutral-950">The challenge</p>
                          <p className="mt-1 text-sm leading-6 text-pretty text-neutral-600">{c.challenge}</p>
                        </div>
                      ) : null}

                      {c.metric || c.metricLabel ? (
                        <div className="mt-6 flex items-start gap-3 border-t border-dashed border-neutral-300 pt-6">
                          <svg aria-hidden="true" viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth="1.75" className="mt-2 size-5 shrink-0 text-indigo-600">
                            <path d="M4 10h11m-4-4 4 4-4 4" strokeLinecap="round" strokeLinejoin="round" />
                          </svg>
                          <div className="min-w-0">
                            <p className="sr-only">The result</p>
                            {c.metric ? <p className="text-4xl font-semibold tracking-tight break-words text-indigo-700 tabular-nums">{c.metric}</p> : null}
                            {c.metricLabel ? <p className="mt-1 text-sm leading-6 font-medium text-pretty text-neutral-800">{c.metricLabel}</p> : null}
                          </div>
                        </div>
                      ) : null}

                      {c.href ? (
                        <p className="mt-auto pt-6">
                          <a
                            href={c.href}
                            className="inline-flex min-h-11 items-center gap-1.5 text-sm font-semibold text-indigo-700 after:absolute after:inset-0 after:rounded-2xl focus-visible:outline-none focus-visible:after:outline-2 focus-visible:after:outline-offset-2 focus-visible:after:outline-indigo-600"
                          >
                            {cta}
                            {c.partner ? <span className="sr-only">: {c.partner}</span> : null}
                            <svg aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" className="size-4 transition group-hover:translate-x-0.5">
                              <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>
                          </a>
                        </p>
                      ) : null}
                    </div>
                  </article>
                </li>
              ))}
            </ul>
          ) : null}

          {source ? <p className="mt-10 text-sm leading-6 text-neutral-600">{source}</p> : null}
        </div>
      </section>
    );
  },
};
```
