# Add the "Named Funds" block to this P1 project

Add a Puck component from P1 Blocks (https://p1-blocks.prolificdigital.io/blocks/named-funds) to this Pantheon Content Publisher (P1) Next.js project. Directory of named and donor funds grouped by type with jump links, purpose, year established and give links.

## Steps

1. Create `components/puck/named-funds-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 { namedFundsBlock } from "./components/puck/named-funds-block";`
3. Register it under `components` as `NamedFundsBlock: namedFundsBlock`.
4. Add `"NamedFundsBlock"` 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/named-funds-block.tsx`

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

/**
 * Named Funds — a directory of named and donor funds grouped by type (field of interest,
 * designated, scholarship, donor-advised), with jump links and a give link per fund.
 * Register: `NamedFundsBlock: namedFundsBlock` in puck.config.tsx.
 */

type Heading = "h1" | "h2" | "h3" | "h4";
type FundType = "interest" | "designated" | "scholarship" | "advised";

type Fund = { name: string; type: FundType; purpose: string; established: string; giveHref: string };

export type NamedFundsProps = {
  eyebrow: string;
  heading: string;
  headingLevel: Heading;
  intro: string;
  funds: Fund[];
  giveLabel: string;
  footnote: string;
  ctaLabel: string;
  ctaHref: string;
};

const childHeading: Record<Heading, "h2" | "h3" | "h4" | "h5"> = { h1: "h2", h2: "h3", h3: "h4", h4: "h5" };
const grandchildHeading: Record<Heading, "h3" | "h4" | "h5" | "h6"> = { h1: "h3", h2: "h4", h3: "h5", h4: "h6" };
const focusRing = "focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600";

const types: { value: FundType; label: string; blurb: string }[] = [
  { value: "interest", label: "Field of interest funds", blurb: "Support a cause, like the arts or the environment. Our grants staff choose the most effective grantees each year." },
  { value: "designated", label: "Designated funds", blurb: "Provide lasting support to one or more specific nonprofits named by the donor." },
  { value: "scholarship", label: "Scholarship funds", blurb: "Help Harlow County students pay for college, trade school or certification programs." },
  { value: "advised", label: "Donor-advised funds", blurb: "Recommend grants to the charities you choose, on your own timeline." },
];

export const namedFundsBlock: ComponentConfig<NamedFundsProps> = {
  label: "Named Funds",
  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" },
    funds: {
      type: "array",
      label: "Funds",
      min: 1,
      max: 80,
      getItemSummary: (item) => item?.name || "Fund",
      defaultItemProps: { name: "New Fund", type: "interest", purpose: "", established: "", giveHref: "/give" },
      arrayFields: {
        name: { type: "text", label: "Fund name" },
        type: {
          type: "select",
          label: "Fund type",
          options: types.map((t) => ({ label: t.label.replace(/ funds$/, ""), value: t.value })),
          metadata: { help: "Funds are grouped by type, in a fixed order." },
        },
        purpose: { type: "textarea", label: "Purpose", metadata: { help: "One or two sentences." } },
        established: { type: "text", label: "Year established" },
        giveHref: { type: "text", label: "Give link", metadata: { help: "Your donation page for this fund. Leave blank to hide the link." } },
      },
      metadata: { help: "Within each group, funds are sorted alphabetically." },
    },
    giveLabel: { type: "text", label: "Give link text" },
    footnote: { type: "textarea", label: "Footnote", metadata: { help: "Small print under the directory. Leave blank to hide it." } },
    ctaLabel: { type: "text", label: "Button text", metadata: { help: "Leave blank to hide the button." } },
    ctaHref: { type: "text", label: "Button link" },
  },
  defaultProps: {
    eyebrow: "Named funds",
    heading: "Find a fund to support",
    headingLevel: "h2",
    intro: "More than 400 families, businesses and community groups have created named funds at Harlow Community Foundation. Gifts of any size are welcome, and every one is acknowledged to the fund's founders.",
    funds: [
      { name: "Harlow Arts Endowment", type: "interest", purpose: "Free and low-cost arts programs for every neighborhood in the county.", established: "1988", giveHref: "/give/harlow-arts-endowment" },
      { name: "Clearwater River Fund", type: "interest", purpose: "Watershed restoration, river access and environmental education along the Clearwater.", established: "2004", giveHref: "/give/clearwater-river" },
      { name: "Ada and Thomas Greer Fund for Seniors", type: "interest", purpose: "Home repair, transportation and companionship for older adults aging in place.", established: "1997", giveHref: "/give/greer-seniors" },
      { name: "Harlow County Public Library Fund", type: "designated", purpose: "Permanent support for children's programs at the Harlow County Public Library.", established: "1976", giveHref: "/give/library-fund" },
      { name: "Second Harvest Pantry Endowment", type: "designated", purpose: "Annual operating support for Second Harvest Community Pantry.", established: "2011", giveHref: "/give/second-harvest" },
      { name: "Lillian Marsh Nursing Scholarship", type: "scholarship", purpose: "Renewable awards for Harlow County residents entering registered nursing programs.", established: "2009", giveHref: "/give/marsh-nursing" },
      { name: "Eastside Trades Scholarship", type: "scholarship", purpose: "Tuition, tools and licensing fees for students in welding, electrical and HVAC programs.", established: "2019", giveHref: "/give/eastside-trades" },
      { name: "The Okonkwo Family Fund", type: "advised", purpose: "Advised by the Okonkwo family, supporting education and immigrant services.", established: "2015", giveHref: "/give/okonkwo-family" },
      { name: "Millbrook Neighbors Giving Circle", type: "advised", purpose: "A giving circle of 60 households pooling gifts for small, resident-led nonprofits.", established: "2021", giveHref: "/give/millbrook-circle" },
    ],
    giveLabel: "Give",
    footnote: "Some donor-advised funds are listed with the family's permission; others remain anonymous and are not shown.",
    ctaLabel: "Start a named fund",
    ctaHref: "/give/start-a-fund",
  },
  render: ({ id, eyebrow, heading, headingLevel, intro, funds, giveLabel, footnote, ctaLabel, ctaHref }) => {
    const H = headingLevel || "h2";
    const Sub = childHeading[H] ?? "h3";
    const Sub2 = grandchildHeading[H] ?? "h4";
    const uid = `nf-${id || "funds"}`;
    const all = (funds ?? []).filter((f) => f?.name);
    const groups = types
      .map((t) => ({
        ...t,
        funds: all.filter((f) => (types.some((x) => x.value === f.type) ? f.type : "interest") === t.value).sort((a, b) => a.name.localeCompare(b.name)),
      }))
      .filter((g) => g.funds.length);

    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-12 lg:grid-cols-12 lg:gap-16">
          <div className="lg:col-span-4">
            <div className="lg:sticky lg:top-8">
              {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-base leading-7 text-pretty text-neutral-600">{intro}</p> : null}

              {groups.length > 1 ? (
                <nav aria-label="Fund types" className="mt-8">
                  <ul role="list" className="border-l border-neutral-200">
                    {groups.map((g) => (
                      <li key={g.value}>
                        <a href={`#${uid}-${g.value}`} className={`-ml-px flex min-h-11 items-center justify-between gap-4 border-l-2 border-transparent py-2 pr-2 pl-4 text-sm font-medium text-neutral-700 hover:border-indigo-600 hover:text-indigo-800 ${focusRing}`}>
                          {g.label}
                          <span className="rounded-full bg-neutral-100 px-2 py-0.5 text-xs font-semibold text-neutral-700 tabular-nums">
                            {g.funds.length}
                            <span className="sr-only"> {g.funds.length === 1 ? "fund" : "funds"}</span>
                          </span>
                        </a>
                      </li>
                    ))}
                  </ul>
                </nav>
              ) : null}

              {ctaLabel ? (
                <a href={ctaHref || "#"} className={`mt-8 inline-flex min-h-11 items-center justify-center rounded-lg bg-indigo-600 px-5 py-3 text-base font-semibold text-white shadow-xs transition hover:bg-indigo-700 ${focusRing}`}>
                  {ctaLabel}
                </a>
              ) : null}
            </div>
          </div>

          <div className="min-w-0 space-y-14 lg:col-span-8">
            {groups.map((g) => (
              <section key={g.value} id={`${uid}-${g.value}`} aria-labelledby={`${uid}-${g.value}-h`} className="scroll-mt-8">
                <div className="border-b border-neutral-950 pb-4">
                  <Sub id={`${uid}-${g.value}-h`} className="text-xl font-semibold tracking-tight text-neutral-950">{g.label}</Sub>
                  <p className="mt-1 max-w-2xl text-sm leading-6 text-pretty text-neutral-600">{g.blurb}</p>
                </div>
                <ul role="list" className="divide-y divide-neutral-200">
                  {g.funds.map((f, i) => (
                    <li key={`${f.name}-${i}`} className="grid grid-cols-1 gap-3 py-5 sm:grid-cols-12 sm:items-start sm:gap-6">
                      <div className="min-w-0 sm:col-span-9">
                        <Sub2 className="text-base leading-7 font-semibold text-neutral-950">{f.name}</Sub2>
                        {f.purpose ? <p className="mt-1 text-sm leading-6 text-pretty text-neutral-600">{f.purpose}</p> : null}
                        {f.established ? <p className="mt-1.5 text-xs font-medium text-neutral-600 tabular-nums">Established {f.established}</p> : null}
                      </div>
                      {f.giveHref && giveLabel ? (
                        <div className="sm:col-span-3 sm:text-right">
                          <a href={f.giveHref} className={`inline-flex min-h-11 items-center gap-1.5 rounded-lg px-4 py-2 text-sm font-semibold text-indigo-700 ring-1 ring-indigo-200 transition ring-inset hover:bg-indigo-50 hover:ring-indigo-400 ${focusRing}`}>
                            <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="size-4">
                              <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>
                            {giveLabel}
                            <span className="sr-only">: {f.name}</span>
                          </a>
                        </div>
                      ) : null}
                    </li>
                  ))}
                </ul>
              </section>
            ))}
            {footnote ? <p className="border-t border-neutral-200 pt-6 text-sm leading-6 text-pretty text-neutral-600">{footnote}</p> : null}
          </div>
        </div>
      </section>
    );
  },
};
```
