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

Add a Puck component from P1 Blocks (https://p1-blocks.prolificdigital.io/blocks/contact-form) to this Pantheon Content Publisher (P1) Next.js project. Plain HTML contact form with name, email, optional phone, topic menu and message beside a contact details sidebar.

## Steps

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

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

/**
 * Contact Form — a plain HTML contact form (name, email, optional phone, topic, message)
 * beside a sidebar of direct contact details. Posts to any form endpoint, no JavaScript.
 * Register: `ContactFormBlock: contactFormBlock` in puck.config.tsx.
 */

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

export type ContactFormProps = {
  heading: string;
  headingLevel: Heading;
  intro: string;
  formAction: string;
  topics: { label: string }[];
  messageHint: string;
  submitLabel: string;
  privacyNote: string;
  sidebarHeading: string;
  phone: string;
  phoneHours: string;
  email: string;
  address: string;
  sidebarNote: string;
};

const childHeading: Record<Heading, "h2" | "h3" | "h4" | "h5"> = { h1: "h2", h2: "h3", h3: "h4", h4: "h5" };

const inputClass =
  "block min-h-11 w-full rounded-lg border-0 bg-white px-3.5 py-2.5 text-base text-neutral-950 shadow-xs ring-1 ring-neutral-300 ring-inset placeholder:text-neutral-500 focus:ring-2 focus:ring-indigo-600 focus:outline-none";
const labelClass = "block text-sm leading-6 font-medium text-neutral-900";

const icons = {
  phone:
    "M2.25 6.75c0 8.284 6.716 15 15 15h2.25a2.25 2.25 0 0 0 2.25-2.25v-1.372c0-.516-.351-.966-.852-1.091l-4.423-1.106c-.44-.11-.902.055-1.173.417l-.97 1.293c-.282.376-.769.542-1.21.38a12.035 12.035 0 0 1-7.143-7.143c-.162-.441.004-.928.38-1.21l1.293-.97c.363-.271.527-.734.417-1.173L6.963 3.102a1.125 1.125 0 0 0-1.091-.852H4.5A2.25 2.25 0 0 0 2.25 4.5v2.25Z",
  mail: "M21.75 6.75v10.5a2.25 2.25 0 0 1-2.25 2.25h-15a2.25 2.25 0 0 1-2.25-2.25V6.75m19.5 0A2.25 2.25 0 0 0 19.5 4.5h-15a2.25 2.25 0 0 0-2.25 2.25m19.5 0v.243a2.25 2.25 0 0 1-1.07 1.916l-7.5 4.615a2.25 2.25 0 0 1-2.36 0L3.32 8.91a2.25 2.25 0 0 1-1.07-1.916V6.75",
  pin: "M15 10.5a3 3 0 1 1-6 0 3 3 0 0 1 6 0ZM19.5 10.5c0 7.142-7.5 11.25-7.5 11.25S4.5 17.642 4.5 10.5a7.5 7.5 0 1 1 15 0Z",
};

const Icon = ({ d }: { d: string }) => (
  <span className="mt-0.5 flex size-9 shrink-0 items-center justify-center rounded-full bg-white ring-1 ring-neutral-200">
    <svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" className="size-4.5 text-indigo-600">
      <path strokeLinecap="round" strokeLinejoin="round" d={d} />
    </svg>
  </span>
);

export const contactFormBlock: ComponentConfig<ContactFormProps> = {
  label: "Contact Form",
  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" },
    formAction: {
      type: "text",
      label: "Form action URL",
      metadata: { help: "Where the form is sent (your form service or site endpoint). Sent with POST using the field names name, email, phone, topic and message." },
    },
    topics: {
      type: "array",
      label: "Topics",
      min: 1,
      max: 12,
      getItemSummary: (item) => item?.label || "Topic",
      defaultItemProps: { label: "New topic" },
      arrayFields: { label: { type: "text", label: "Topic" } },
      metadata: { help: "Choices in the \"What's this about?\" menu, so messages reach the right person." },
    },
    messageHint: { type: "text", label: "Message hint", metadata: { help: "Short guidance under the message box. Leave blank to hide it." } },
    submitLabel: { type: "text", label: "Button text" },
    privacyNote: { type: "textarea", label: "Privacy note", metadata: { help: "Shown under the button. Leave blank to hide it." } },
    sidebarHeading: { type: "text", label: "Sidebar heading", metadata: { help: "Leave every sidebar field blank to hide the sidebar." } },
    phone: { type: "text", label: "Phone", metadata: { help: "Shown as typed and linked for tap-to-call." } },
    phoneHours: { type: "text", label: "Phone hours" },
    email: { type: "text", label: "Email" },
    address: { type: "textarea", label: "Address", metadata: { help: "One line per row of the address." } },
    sidebarNote: { type: "textarea", label: "Sidebar note", metadata: { help: "Small print at the bottom of the sidebar, such as an urgent-help line." } },
  },
  defaultProps: {
    heading: "Send us a message",
    headingLevel: "h2",
    intro: "Questions about programs, partnerships or your gift? Write to us and a real person on our team will reply.",
    formAction: "/contact",
    topics: [
      { label: "Programs and enrollment" },
      { label: "Volunteering" },
      { label: "Donations and receipts" },
      { label: "Partnerships" },
      { label: "Media inquiries" },
      { label: "Something else" },
    ],
    messageHint: "Include dates, program names or a receipt number if it applies.",
    submitLabel: "Send message",
    privacyNote: "We use your details only to answer this message. We never sell or share them.",
    sidebarHeading: "Other ways to reach us",
    phone: "(502) 555-0148",
    phoneHours: "Mon–Fri, 9 a.m. – 5 p.m.",
    email: "hello@riverbendalliance.org",
    address: "Riverbend Community Alliance\n410 West Market Street, Suite 2\nLouisville, KY 40202",
    sidebarNote: "We reply to most messages within two business days.",
  },
  render: ({ id, heading, headingLevel, intro, formAction, topics, messageHint, submitLabel, privacyNote, sidebarHeading, phone, phoneHours, email, address, sidebarNote }) => {
    const H = headingLevel || "h2";
    const Sub = childHeading[H] || "h3";
    const uid = `cf-${id || "form"}`;
    const topicList = (topics ?? []).map((t) => t?.label?.trim()).filter(Boolean) as string[];
    const addressLines = (address || "").split("\n").map((l) => l.trim()).filter(Boolean);
    const tel = (phone || "").replace(/[^\d+]/g, "");
    const hasSidebar = Boolean(sidebarHeading || phone || email || addressLines.length || sidebarNote);

    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 grid-cols-1 gap-12 lg:gap-16 ${hasSidebar ? "max-w-6xl lg:grid-cols-12" : "max-w-2xl"}`}>
          <div className={hasSidebar ? "lg:col-span-7" : ""}>
            {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 max-w-xl text-lg leading-8 text-pretty text-neutral-600">{intro}</p> : null}

            <form action={formAction || undefined} method="post" className={`grid grid-cols-1 gap-x-6 gap-y-6 sm:grid-cols-2 ${heading || intro ? "mt-10" : ""}`}>
              <p className="text-sm leading-6 text-neutral-600 sm:col-span-2">All fields are required unless marked optional.</p>
              <div className="sm:col-span-2">
                <label htmlFor={`${uid}-name`} className={labelClass}>Full name</label>
                <input id={`${uid}-name`} name="name" type="text" required autoComplete="name" className={`mt-2 ${inputClass}`} />
              </div>
              <div>
                <label htmlFor={`${uid}-email`} className={labelClass}>Email</label>
                <input id={`${uid}-email`} name="email" type="email" required autoComplete="email" inputMode="email" placeholder="you@example.org" className={`mt-2 ${inputClass}`} />
              </div>
              <div>
                <label htmlFor={`${uid}-phone`} className={labelClass}>
                  Phone <span className="font-normal text-neutral-600">(optional)</span>
                </label>
                <input id={`${uid}-phone`} name="phone" type="tel" autoComplete="tel" inputMode="tel" className={`mt-2 ${inputClass}`} />
              </div>
              {topicList.length ? (
                <div className="sm:col-span-2">
                  <label htmlFor={`${uid}-topic`} className={labelClass}>What&rsquo;s this about?</label>
                  <div className="relative mt-2">
                    <select id={`${uid}-topic`} name="topic" required defaultValue="" className={`appearance-none pr-10 ${inputClass}`}>
                      <option value="" disabled>
                        Choose a topic
                      </option>
                      {topicList.map((t, i) => (
                        <option key={`${t}-${i}`} value={t}>
                          {t}
                        </option>
                      ))}
                    </select>
                    <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="pointer-events-none absolute top-1/2 right-3 size-5 -translate-y-1/2 text-neutral-500">
                      <path fillRule="evenodd" d="M5.22 8.22a.75.75 0 0 1 1.06 0L10 11.94l3.72-3.72a.75.75 0 1 1 1.06 1.06l-4.25 4.25a.75.75 0 0 1-1.06 0L5.22 9.28a.75.75 0 0 1 0-1.06Z" clipRule="evenodd" />
                    </svg>
                  </div>
                </div>
              ) : null}
              <div className="sm:col-span-2">
                <label htmlFor={`${uid}-message`} className={labelClass}>Message</label>
                <textarea
                  id={`${uid}-message`}
                  name="message"
                  rows={5}
                  required
                  minLength={10}
                  aria-describedby={messageHint ? `${uid}-message-hint` : undefined}
                  className={`mt-2 ${inputClass}`}
                />
                {messageHint ? (
                  <p id={`${uid}-message-hint`} className="mt-2 text-sm leading-6 text-neutral-600">
                    {messageHint}
                  </p>
                ) : null}
              </div>
              <div className="flex flex-col gap-4 sm:col-span-2 sm:flex-row sm:items-center sm:gap-6">
                <button
                  type="submit"
                  className="inline-flex min-h-11 shrink-0 items-center justify-center 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 || "Send message"}
                </button>
                {privacyNote ? <p className="text-sm leading-6 text-pretty text-neutral-600">{privacyNote}</p> : null}
              </div>
            </form>
          </div>

          {hasSidebar ? (
            <aside aria-labelledby={sidebarHeading ? `${uid}-aside` : undefined} aria-label={sidebarHeading ? undefined : "Contact details"} className="lg:col-span-5">
              <div className="rounded-2xl bg-neutral-50 p-6 ring-1 ring-neutral-200 sm:p-8 lg:sticky lg:top-8">
                {sidebarHeading ? (
                  <Sub id={`${uid}-aside`} className="text-lg leading-7 font-semibold text-neutral-950">
                    {sidebarHeading}
                  </Sub>
                ) : null}
                <dl className={`space-y-6 ${sidebarHeading ? "mt-6" : ""}`}>
                  {phone ? (
                    <div className="flex gap-4">
                      <dt>
                        <span className="sr-only">Phone</span>
                        <Icon d={icons.phone} />
                      </dt>
                      <dd className="min-w-0 text-base leading-7">
                        <a href={`tel:${tel}`} className="-mx-1 inline-flex min-h-11 items-center rounded px-1 font-semibold text-neutral-950 hover:text-indigo-700 focus-visible:outline-2 focus-visible:outline-indigo-600">
                          {phone}
                        </a>
                        {phoneHours ? <span className="-mt-2 block text-sm leading-6 text-neutral-600">{phoneHours}</span> : null}
                      </dd>
                    </div>
                  ) : null}
                  {email ? (
                    <div className="flex gap-4">
                      <dt>
                        <span className="sr-only">Email</span>
                        <Icon d={icons.mail} />
                      </dt>
                      <dd className="min-w-0 text-base leading-7">
                        <a href={`mailto:${email}`} className="-mx-1 inline-flex min-h-11 items-center rounded px-1 font-semibold break-all text-neutral-950 hover:text-indigo-700 focus-visible:outline-2 focus-visible:outline-indigo-600">
                          {email}
                        </a>
                      </dd>
                    </div>
                  ) : null}
                  {addressLines.length ? (
                    <div className="flex gap-4">
                      <dt>
                        <span className="sr-only">Address</span>
                        <Icon d={icons.pin} />
                      </dt>
                      <dd className="min-w-0 pt-1.5 text-base leading-7 text-neutral-700">
                        <address className="not-italic">
                          {addressLines.map((line, i) => (
                            <span key={i} className={`block ${i === 0 ? "font-semibold text-neutral-950" : ""}`}>
                              {line}
                            </span>
                          ))}
                        </address>
                      </dd>
                    </div>
                  ) : null}
                </dl>
                {sidebarNote ? <p className="mt-8 border-t border-neutral-200 pt-6 text-sm leading-6 text-pretty text-neutral-600">{sidebarNote}</p> : null}
              </div>
            </aside>
          ) : null}
        </div>
      </section>
    );
  },
};
```
