# Add the "Donation Form" block to this P1 project

Add a Puck component from P1 Blocks (https://p1-blocks.prolificdigital.io/blocks/donation-form) to this Pantheon Content Publisher (P1) Next.js project. Amount radio cards, other amount, one-time or monthly, and a CSS-revealed tribute field that posts to your checkout.

## Steps

1. Create `components/puck/donation-form-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 { donationFormBlock } from "./components/puck/donation-form-block";`
3. Register it under `components` as `DonationFormBlock: donationFormBlock`.
4. Add `"DonationFormBlock"` 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/donation-form-block.tsx`

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

/**
 * Donation Form — suggested amounts as radio cards, an "other amount" field, one-time or monthly,
 * and an optional tribute name revealed with CSS :has(). Posts to your payment page, no JavaScript.
 * Register: `DonationFormBlock: donationFormBlock` in puck.config.tsx.
 */

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

type Amount = { amount: string; impact: string; preselected: boolean };

export type DonationFormProps = {
  eyebrow: string;
  heading: string;
  headingLevel: Heading;
  body: string;
  imageUrl: string;
  imageAlt: string;
  formAction: string;
  currencySymbol: string;
  amounts: Amount[];
  allowMonthly: boolean;
  defaultMonthly: boolean;
  allowDedication: boolean;
  submitLabel: string;
  secureNote: string;
  taxNote: string;
};

const toValue = (s: string) => (s || "").replace(/[^\d.]/g, "");

export const donationFormBlock: ComponentConfig<DonationFormProps> = {
  label: "Donation Form",
  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." },
    },
    body: { type: "textarea", label: "Body" },
    imageUrl: { type: "text", label: "Image URL", metadata: { help: "Shown beside the copy on wide screens. Leave blank to hide it." } },
    imageAlt: { type: "text", label: "Image alt text", metadata: { help: "Describe what the photo shows. Leave blank only if it's purely decorative." } },
    formAction: {
      type: "text",
      label: "Form action URL",
      metadata: { help: "Your donation or checkout page. The form sends amount, other_amount, frequency, dedication, tribute_type and tribute_name with GET, so the page can read them from the URL." },
    },
    currencySymbol: { type: "text", label: "Currency symbol" },
    amounts: {
      type: "array",
      label: "Suggested amounts",
      min: 2,
      max: 6,
      getItemSummary: (item) => `${item?.amount || "Amount"}${item?.preselected ? " (selected)" : ""}`,
      defaultItemProps: { amount: "$75", impact: "", preselected: false },
      arrayFields: {
        amount: { type: "text", label: "Amount", metadata: { help: "Type it as it should appear, such as $50. Only the digits are sent." } },
        impact: { type: "text", label: "What it does", metadata: { help: "A few words, such as \"Feeds a family for a week\"." } },
        preselected: {
          type: "radio",
          label: "Selected at first",
          options: [
            { label: "Yes", value: true },
            { label: "No", value: false },
          ],
          metadata: { help: "Pick one amount at most. If none is picked, visitors must choose." },
        },
      },
    },
    allowMonthly: {
      type: "radio",
      label: "Offer monthly giving",
      options: [
        { label: "Yes", value: true },
        { label: "No", value: false },
      ],
    },
    defaultMonthly: {
      type: "radio",
      label: "Monthly selected at first",
      options: [
        { label: "Yes", value: true },
        { label: "No", value: false },
      ],
      metadata: { help: "Only applies when monthly giving is offered." },
    },
    allowDedication: {
      type: "radio",
      label: "Offer a tribute gift",
      options: [
        { label: "Yes", value: true },
        { label: "No", value: false },
      ],
      metadata: { help: "Adds a checkbox that reveals \"in honor of\" or \"in memory of\" fields." },
    },
    submitLabel: { type: "text", label: "Button text" },
    secureNote: { type: "text", label: "Security note", metadata: { help: "Shown beside the button. Leave blank to hide it." } },
    taxNote: { type: "textarea", label: "Tax note", metadata: { help: "Small print under the form. Leave blank to hide it." } },
  },
  defaultProps: {
    eyebrow: "Winter meals drive",
    heading: "Put a hot meal on the table tonight",
    headingLevel: "h2",
    body: "Our kitchen serves 1,400 meals a week to neighbors who are elderly, recovering or between homes. Your gift buys groceries, keeps the delivery vans running and pays our cooks a living wage.",
    imageUrl: "https://picsum.photos/seed/kitchen/900/1100",
    imageAlt: "Volunteers in aprons packing meal containers at a long steel kitchen table",
    formAction: "/donate/checkout",
    currencySymbol: "$",
    amounts: [
      { amount: "$25", impact: "Five hot meals", preselected: false },
      { amount: "$50", impact: "A week of groceries", preselected: true },
      { amount: "$100", impact: "A month of deliveries", preselected: false },
      { amount: "$250", impact: "A Saturday kitchen shift", preselected: false },
    ],
    allowMonthly: true,
    defaultMonthly: false,
    allowDedication: true,
    submitLabel: "Continue to payment",
    secureNote: "Secure, encrypted checkout",
    taxNote: "Riverbend Community Kitchen is a 501(c)(3) nonprofit. Gifts are tax-deductible to the extent allowed by law. Meal figures are sample data.",
  },
  render: ({ id, eyebrow, heading, headingLevel, body, imageUrl, imageAlt, formAction, currencySymbol, amounts, allowMonthly, defaultMonthly, allowDedication, submitLabel, secureNote, taxNote }) => {
    const H = headingLevel || "h2";
    const uid = `df-${id || "donate"}`;
    const symbol = currencySymbol || "$";
    const list = (amounts ?? []).filter((a) => a?.amount && toValue(a.amount));
    const preIndex = list.findIndex((a) => a.preselected);
    const monthlyOn = allowMonthly !== false;
    const legendClass = "text-sm leading-6 font-semibold text-neutral-950";

    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 grid-cols-1 items-start gap-10 lg:gap-16 ${imageUrl || heading || body ? "max-w-6xl lg:grid-cols-2" : "max-w-xl"}`}>
          {imageUrl || heading || body || eyebrow ? (
            <div className="lg:sticky lg:top-8">
              {eyebrow ? <p className="text-sm font-semibold tracking-wide 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}
              {body ? <p className="mt-5 max-w-xl text-lg leading-8 text-pretty text-neutral-600">{body}</p> : null}
              {imageUrl ? (
                <img src={imageUrl} alt={imageAlt || ""} className="mt-10 hidden aspect-4/5 w-full max-w-md rounded-2xl object-cover shadow-lg ring-1 ring-neutral-950/5 lg:block" />
              ) : null}
            </div>
          ) : null}

          <form action={formAction || undefined} method="get" className="rounded-2xl bg-white p-6 shadow-sm ring-1 ring-neutral-200 sm:p-8">
            {monthlyOn ? (
              <fieldset>
                <legend className={legendClass}>How often?</legend>
                <div className="mt-3 flex gap-1 rounded-xl bg-neutral-100 p-1">
                  {[
                    { value: "one-time", label: "Give once", checked: !defaultMonthly },
                    { value: "monthly", label: "Monthly", checked: Boolean(defaultMonthly) },
                  ].map((o) => (
                    <label
                      key={o.value}
                      className="flex min-h-11 flex-1 cursor-pointer items-center justify-center gap-2 rounded-lg px-3 text-sm font-semibold text-neutral-700 transition select-none hover:text-neutral-950 has-checked:bg-white has-checked:text-neutral-950 has-checked:shadow-sm has-checked:ring-1 has-checked:ring-neutral-200 has-focus-visible:outline-2 has-focus-visible:outline-offset-2 has-focus-visible:outline-indigo-600"
                    >
                      <input type="radio" name="frequency" value={o.value} defaultChecked={o.checked} className="sr-only" />
                      {o.value === "monthly" ? (
                        <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="size-4 text-indigo-600">
                          <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>
                      ) : null}
                      {o.label}
                    </label>
                  ))}
                </div>
              </fieldset>
            ) : (
              <input type="hidden" name="frequency" value="one-time" />
            )}

            {list.length ? (
              <fieldset className={monthlyOn ? "mt-8" : ""}>
                <legend className={legendClass}>Choose an amount</legend>
                <div className="mt-3 grid grid-cols-1 gap-3 sm:grid-cols-2">
                  {list.map((a, i) => (
                    <label
                      key={`${a.amount}-${i}`}
                      className="relative flex min-h-14 cursor-pointer flex-wrap items-center gap-x-3 rounded-xl bg-white py-3 pr-10 pl-4 sm:min-h-20 sm:flex-col sm:items-start sm:justify-center sm:gap-x-0 ring-1 ring-neutral-300 transition select-none ring-inset hover:ring-indigo-400 has-checked:bg-indigo-50 has-checked:ring-2 has-checked:ring-indigo-600 has-focus-visible:outline-2 has-focus-visible:outline-offset-2 has-focus-visible:outline-indigo-600"
                    >
                      <input type="radio" name="amount" value={toValue(a.amount)} defaultChecked={i === preIndex} className="peer sr-only" />
                      <span className="text-2xl font-semibold tracking-tight text-neutral-950 tabular-nums">{a.amount}</span>
                      {a.impact ? <span className="text-sm leading-5 text-neutral-600 sm:mt-0.5">{a.impact}</span> : null}
                      <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="absolute top-1/2 right-3 hidden size-5 -translate-y-1/2 sm:top-3 sm:translate-y-0 text-indigo-600 peer-checked:block">
                        <path fillRule="evenodd" d="M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16Zm3.857-9.809a.75.75 0 0 0-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 1 0-1.06 1.061l2.5 2.5a.75.75 0 0 0 1.137-.089l4-5.5Z" clipRule="evenodd" />
                      </svg>
                    </label>
                  ))}
                </div>
              </fieldset>
            ) : null}

            <div className="mt-6">
              <label htmlFor={`${uid}-other`} className="block text-sm leading-6 font-medium text-neutral-900">
                Other amount <span className="font-normal text-neutral-600">(optional)</span>
              </label>
              <div className="mt-2 flex min-h-11 items-center rounded-lg bg-white ring-1 ring-neutral-300 ring-inset focus-within:ring-2 focus-within:ring-indigo-600">
                <span aria-hidden="true" className="pl-3.5 text-base text-neutral-600">
                  {symbol}
                </span>
                <input
                  id={`${uid}-other`}
                  name="other_amount"
                  type="number"
                  inputMode="decimal"
                  min="1"
                  step="any"
                  autoComplete="transaction-amount"
                  aria-describedby={`${uid}-other-hint`}
                  className="block min-w-0 flex-1 border-0 bg-transparent py-2.5 pr-3.5 pl-1.5 text-base text-neutral-950 placeholder:text-neutral-500 focus:ring-0 focus:outline-none"
                />
              </div>
              <p id={`${uid}-other-hint`} className="mt-2 text-sm leading-6 text-neutral-600">
                Typing an amount here replaces the one picked above.
              </p>
            </div>

            {allowDedication !== false ? (
              <div className="group/dedicate mt-8 border-t border-neutral-200 pt-6">
                <div className="flex gap-3">
                  <div className="flex h-11 shrink-0 items-center">
                    <input
                      id={`${uid}-dedicate`}
                      name="dedication"
                      type="checkbox"
                      value="yes"
                      aria-controls={`${uid}-tribute`}
                      className="size-5 rounded border-neutral-400 accent-indigo-600 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600"
                    />
                  </div>
                  <label htmlFor={`${uid}-dedicate`} className="flex min-h-11 cursor-pointer flex-col justify-center text-sm leading-6">
                    <span className="font-medium text-neutral-900">Dedicate this gift</span>
                    <span className="text-neutral-600">Give in honor or in memory of someone.</span>
                  </label>
                </div>
                <div id={`${uid}-tribute`} className="mt-4 hidden grid-cols-1 gap-4 rounded-xl bg-neutral-50 p-4 ring-1 ring-neutral-200 group-has-checked/dedicate:grid sm:grid-cols-5">
                  <div className="sm:col-span-2">
                    <label htmlFor={`${uid}-tribute-type`} className="block text-sm leading-6 font-medium text-neutral-900">
                      Type
                    </label>
                    <select
                      id={`${uid}-tribute-type`}
                      name="tribute_type"
                      className="mt-2 block min-h-11 w-full rounded-lg border-0 bg-white px-3 py-2.5 text-base text-neutral-950 ring-1 ring-neutral-300 ring-inset focus:ring-2 focus:ring-indigo-600 focus:outline-none"
                    >
                      <option value="honor">In honor of</option>
                      <option value="memory">In memory of</option>
                    </select>
                  </div>
                  <div className="sm:col-span-3">
                    <label htmlFor={`${uid}-tribute-name`} className="block text-sm leading-6 font-medium text-neutral-900">
                      Their name
                    </label>
                    <input
                      id={`${uid}-tribute-name`}
                      name="tribute_name"
                      type="text"
                      autoComplete="off"
                      className="mt-2 block min-h-11 w-full rounded-lg border-0 bg-white px-3.5 py-2.5 text-base text-neutral-950 ring-1 ring-neutral-300 ring-inset focus:ring-2 focus:ring-indigo-600 focus:outline-none"
                    />
                  </div>
                </div>
              </div>
            ) : null}

            <div className="mt-8 flex flex-col gap-4">
              <button
                type="submit"
                className="inline-flex min-h-12 w-full items-center justify-center gap-2 rounded-lg bg-indigo-600 px-6 py-3 text-base font-semibold text-white shadow-xs transition hover:bg-indigo-700 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600"
              >
                {submitLabel || "Continue to payment"}
                <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="size-5">
                  <path fillRule="evenodd" d="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" clipRule="evenodd" />
                </svg>
              </button>
              {secureNote ? (
                <p className="flex items-center justify-center gap-2 text-sm text-neutral-600">
                  <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="size-4 shrink-0 text-neutral-500">
                    <path fillRule="evenodd" d="M10 1a4.5 4.5 0 0 0-4.5 4.5V9H5a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-6a2 2 0 0 0-2-2h-.5V5.5A4.5 4.5 0 0 0 10 1Zm3 8V5.5a3 3 0 1 0-6 0V9h6Z" clipRule="evenodd" />
                  </svg>
                  {secureNote}
                </p>
              ) : null}
            </div>
            {taxNote ? <p className="mt-6 border-t border-neutral-200 pt-6 text-xs leading-5 text-pretty text-neutral-600">{taxNote}</p> : null}
          </form>
        </div>
      </section>
    );
  },
};
```
