# Add the "Grantee Stories" block to this P1 project

Add a Puck component from P1 Blocks (https://p1-blocks.prolificdigital.io/blocks/grantee-stories) to this Pantheon Content Publisher (P1) Next.js project. Story cards for funded organizations with grant purpose, a sourced outcome figure, a photo and a read-more link.

## Steps

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

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

/**
 * Grantee Stories — story cards for funded organizations: what the grant paid for, one
 * sourced outcome figure, a photo and a read-more link. The first story leads, larger.
 * Register: `GranteeStoriesBlock: granteeStoriesBlock` in puck.config.tsx.
 */

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

type Story = {
  grantee: string;
  title: string;
  purpose: string;
  grantLine: string;
  metricValue: string;
  metricLabel: string;
  imageUrl: string;
  imageAlt: string;
  href: string;
};

export type GranteeStoriesProps = {
  eyebrow: string;
  heading: string;
  headingLevel: Heading;
  intro: string;
  stories: Story[];
  featureFirst: boolean;
  linkLabel: string;
  source: string;
  ctaLabel: string;
  ctaHref: string;
};

const childHeading: Record<Heading, "h2" | "h3" | "h4" | "h5"> = { h1: "h2", h2: "h3", h3: "h4", h4: "h5" };
const focusRing = "focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-indigo-600";
const arrow = "M3 10a.75.75 0 0 1 .75-.75h10.64l-3.22-3.22a.75.75 0 1 1 1.06-1.06l4.5 4.5a.75.75 0 0 1 0 1.06l-4.5 4.5a.75.75 0 1 1-1.06-1.06l3.22-3.22H3.75A.75.75 0 0 1 3 10Z";

export const granteeStoriesBlock: ComponentConfig<GranteeStoriesProps> = {
  label: "Grantee Stories",
  fields: {
    eyebrow: { type: "text", label: "Eyebrow", metadata: { help: "Small line above the heading. Leave blank to hide it." } },
    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" },
    stories: {
      type: "array",
      label: "Stories",
      min: 1,
      max: 7,
      getItemSummary: (item) => item?.grantee || item?.title || "Story",
      defaultItemProps: {
        grantee: "Grantee organization",
        title: "Story headline",
        purpose: "",
        grantLine: "",
        metricValue: "",
        metricLabel: "",
        imageUrl: "https://picsum.photos/seed/grantee/1200/800",
        imageAlt: "",
        href: "/stories",
      },
      arrayFields: {
        grantee: { type: "text", label: "Grantee" },
        title: { type: "text", label: "Headline" },
        purpose: { type: "textarea", label: "What the grant supports" },
        grantLine: { type: "text", label: "Grant details", metadata: { help: "Like $40,000 · Early Learning · 2025. Leave blank to hide it." } },
        metricValue: { type: "text", label: "Outcome figure", metadata: { help: "One number, like 212 or 94%. Leave blank to hide it." } },
        metricLabel: { type: "text", label: "Outcome label", metadata: { help: "What the number counts, like families kept in their homes." } },
        imageUrl: { type: "text", label: "Image URL", metadata: { help: "Use a photo you have rights to. Landscape works best." } },
        imageAlt: { type: "text", label: "Image alt text", metadata: { help: "Describe the photo for people who can't see it. Leave blank only if it's purely decorative." } },
        href: { type: "text", label: "Story link", metadata: { help: "Leave blank if there's no full story page." } },
      },
    },
    featureFirst: {
      type: "radio",
      label: "Feature the first story",
      options: [
        { label: "Yes", value: true },
        { label: "No", value: false },
      ],
      metadata: { help: "Shows the first story larger, across the full width on wide screens." },
    },
    linkLabel: { type: "text", label: "Read more text" },
    source: { type: "text", label: "Source line", metadata: { help: "Where the outcome figures come from." } },
    ctaLabel: { type: "text", label: "Button text", metadata: { help: "Leave blank to hide the button." } },
    ctaHref: { type: "text", label: "Button link" },
  },
  defaultProps: {
    eyebrow: "Grantee stories",
    heading: "What your gifts made possible",
    headingLevel: "h2",
    intro: "Our grantees do the work. These are a few of the people and organizations behind the numbers in our annual report.",
    stories: [
      {
        grantee: "Eastside Tenant Legal Services",
        title: "A lawyer in the room changes the outcome",
        purpose: "Two staff attorneys now take eviction cases in Harlow County housing court every weekday morning, so tenants no longer face a hearing alone.",
        grantLine: "$60,000 · Thriving Neighborhoods · 2025",
        metricValue: "212",
        metricLabel: "households kept in their homes in the first year",
        imageUrl: "https://picsum.photos/seed/tenantlaw/1200/800",
        imageAlt: "An attorney reviewing papers with a tenant at a courthouse hallway bench",
        href: "/stories/eastside-tenant-legal",
      },
      {
        grantee: "Little Acorns Child Development Center",
        title: "Teachers who stay",
        purpose: "Wage supplements and paid coursework for infant and toddler teachers working toward their Child Development Associate credential.",
        grantLine: "$35,000 · Early Learning · 2025",
        metricValue: "93%",
        metricLabel: "of teachers stayed through the full year",
        imageUrl: "https://picsum.photos/seed/acorns/800/600",
        imageAlt: "A teacher sitting on a classroom rug reading a picture book to three toddlers",
        href: "/stories/little-acorns",
      },
      {
        grantee: "Riverbend Arts Collective",
        title: "Thirty walls, thirty teen artists",
        purpose: "A paid summer apprenticeship pairing teenagers with working muralists on public walls across the east side.",
        grantLine: "$8,000 · Arts Access · 2025",
        metricValue: "30",
        metricLabel: "paid teen apprenticeships",
        imageUrl: "https://picsum.photos/seed/muralteens/800/600",
        imageAlt: "Two teenagers on a scaffold painting a large, colorful mural on a brick wall",
        href: "/stories/riverbend-murals",
      },
    ],
    featureFirst: true,
    linkLabel: "Read the story",
    source: "Sample figures. Source: grantee final reports to Harlow Community Foundation, 2025.",
    ctaLabel: "See all stories",
    ctaHref: "/stories",
  },
  render: ({ eyebrow, heading, headingLevel, intro, stories, featureFirst, linkLabel, source, ctaLabel, ctaHref }) => {
    const H = headingLevel || "h2";
    const Sub = childHeading[H] ?? "h3";
    const list = (stories ?? []).filter((s) => s?.grantee || s?.title);
    const hasMetric = list.some((s) => s.metricValue);
    const lead = featureFirst !== false && list.length > 1;
    const rest = lead ? list.slice(1) : list;
    const restCols = rest.length >= 3 ? "lg:grid-cols-3" : "";

    const metric = (s: Story) =>
      s.metricValue ? (
        <p className="mt-6 flex items-baseline gap-3 border-t border-neutral-200 pt-5">
          <span className="text-3xl font-semibold tracking-tight text-indigo-700 tabular-nums sm:text-4xl">{s.metricValue}</span>
          {s.metricLabel ? <span className="text-sm leading-5 text-pretty text-neutral-600">{s.metricLabel}</span> : null}
        </p>
      ) : null;

    const readMore = (s: Story) =>
      s.href && linkLabel ? (
        <p aria-hidden="true" className="mt-auto inline-flex items-center gap-1.5 pt-6 text-sm font-semibold text-neutral-950 group-hover:text-indigo-700">
          {linkLabel}
          <svg viewBox="0 0 20 20" fill="currentColor" className="size-4 transition group-hover:translate-x-0.5">
            <path fillRule="evenodd" d={arrow} clipRule="evenodd" />
          </svg>
        </p>
      ) : null;

    const title = (s: Story) => {
      const text = s.title || s.grantee;
      return s.href ? (
        <a href={s.href} className={`rounded-sm ${focusRing}`}>
          <span aria-hidden="true" className="absolute inset-0" />
          {text}
        </a>
      ) : (
        <>{text}</>
      );
    };

    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">
          <div className="flex flex-col gap-6 lg:flex-row lg:items-end lg:justify-between lg:gap-16">
            <div className="max-w-2xl">
              {eyebrow ? <p className="text-sm font-semibold tracking-widest text-indigo-700 uppercase">{eyebrow}</p> : null}
              {heading ? <H className={`text-3xl font-semibold tracking-tight text-balance text-neutral-950 sm:text-4xl ${eyebrow ? "mt-3" : ""}`}>{heading}</H> : null}
              {intro ? <p className="mt-4 text-lg leading-8 text-pretty text-neutral-600">{intro}</p> : null}
            </div>
            {ctaLabel ? (
              <a href={ctaHref || "#"} className="inline-flex min-h-11 shrink-0 items-center gap-1.5 self-start rounded-lg px-1 text-base font-semibold text-indigo-700 hover:text-indigo-900 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600 lg:self-auto">
                {ctaLabel}
                <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="size-4">
                  <path fillRule="evenodd" d={arrow} clipRule="evenodd" />
                </svg>
              </a>
            ) : null}
          </div>

          {list.length ? (
            <div className="mt-12 space-y-6 lg:mt-14 lg:space-y-8">
              {lead ? (
                <div>
                  <article className="group relative grid grid-cols-1 overflow-hidden rounded-2xl bg-neutral-50 ring-1 ring-neutral-200 transition hover:ring-indigo-300 lg:grid-cols-12">
                    {list[0].imageUrl ? (
                      <div className="relative aspect-16/10 overflow-hidden bg-neutral-200 lg:col-span-7 lg:aspect-auto lg:min-h-96">
                        <img src={list[0].imageUrl} alt={list[0].imageAlt || ""} loading="lazy" className="absolute inset-0 size-full object-cover transition duration-700 group-hover:scale-102" />
                      </div>
                    ) : null}
                    <div className={`flex flex-col p-6 sm:p-8 lg:p-10 ${list[0].imageUrl ? "lg:col-span-5" : "lg:col-span-12"}`}>
                      <p className="text-sm font-semibold text-indigo-700">{list[0].grantee}</p>
                      <Sub className="mt-2 text-2xl leading-tight font-semibold tracking-tight text-balance text-neutral-950 sm:text-3xl">
                        {title(list[0])}
                      </Sub>
                      {list[0].purpose ? <p className="mt-4 text-base leading-7 text-pretty text-neutral-600">{list[0].purpose}</p> : null}
                      {list[0].grantLine ? <p className="mt-4 text-sm font-medium text-neutral-700 tabular-nums">{list[0].grantLine}</p> : null}
                      {metric(list[0])}
                      {readMore(list[0])}
                    </div>
                  </article>
                </div>
              ) : null}
              {rest.length ? (
                  <ul role="list" className={`grid grid-cols-1 gap-6 md:grid-cols-2 lg:gap-8 ${restCols}`}>
                    {rest.map((s, i) => (
                      <li key={`${s.grantee}-${i}`} className="flex">
                        <article className="group relative flex w-full flex-col overflow-hidden rounded-2xl bg-white ring-1 ring-neutral-200 transition hover:ring-indigo-300">
                          {s.imageUrl ? (
                            <div className="aspect-3/2 overflow-hidden bg-neutral-100">
                              <img src={s.imageUrl} alt={s.imageAlt || ""} loading="lazy" className="size-full object-cover transition duration-700 group-hover:scale-102" />
                            </div>
                          ) : null}
                          <div className="flex flex-1 flex-col p-6">
                            <p className="text-sm font-semibold text-indigo-700">{s.grantee}</p>
                            <Sub className="mt-2 text-xl leading-7 font-semibold tracking-tight text-balance text-neutral-950">
                              {title(s)}
                            </Sub>
                            {s.purpose ? <p className="mt-3 text-base leading-7 text-pretty text-neutral-600">{s.purpose}</p> : null}
                            {s.grantLine ? <p className="mt-3 text-sm font-medium text-neutral-700 tabular-nums">{s.grantLine}</p> : null}
                            {metric(s)}
                            {readMore(s)}
                          </div>
                        </article>
                      </li>
                    ))}
                  </ul>
              ) : null}
            </div>
          ) : null}

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