# Add the "Lead Magnet" block to this P1 project

Add a Puck component from P1 Blocks (https://p1-blocks.prolificdigital.io/blocks/lead-magnet) to this Pantheon Content Publisher (P1) Next.js project. Free guide offer with a book-style cover, a what's-inside list and an email form for the download.

## Steps

1. Create `components/puck/lead-magnet-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 { leadMagnetBlock } from "./components/puck/lead-magnet-block";`
3. Register it under `components` as `LeadMagnetBlock: leadMagnetBlock`.
4. Add `"LeadMagnetBlock"` 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/lead-magnet-block.tsx`

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

/**
 * Lead Magnet — offer a free guide or toolkit in exchange for an email: book-style cover,
 * a "what's inside" list and a short form that posts to your list provider. No JavaScript.
 * Register: `LeadMagnetBlock: leadMagnetBlock` in puck.config.tsx.
 */

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

export type LeadMagnetProps = {
  eyebrow: string;
  heading: string;
  headingLevel: Heading;
  body: string;
  coverUrl: string;
  coverAlt: string;
  format: string;
  insideHeading: string;
  inside: { title: string; detail: string }[];
  formAction: string;
  emailFieldName: string;
  askName: boolean;
  buttonLabel: string;
  privacyNote: string;
};

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

const inputClass =
  "block min-h-12 w-full rounded-lg border-0 bg-white px-4 py-3 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";

export const leadMagnetBlock: ComponentConfig<LeadMagnetProps> = {
  label: "Lead Magnet",
  fields: {
    eyebrow: { type: "text", label: "Eyebrow", metadata: { help: "Small line above the heading, such as Free guide. 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" },
    coverUrl: { type: "text", label: "Cover image URL", metadata: { help: "A portrait image works best (3:4). Leave blank to hide the cover." } },
    coverAlt: { type: "text", label: "Cover alt text", metadata: { help: "Name the guide, such as \"Cover of the Neighborhood Tree Care Handbook\"." } },
    format: { type: "text", label: "Format", metadata: { help: "Such as PDF · 24 pages. Shown on the cover. Leave blank to hide it." } },
    insideHeading: { type: "text", label: "List heading" },
    inside: {
      type: "array",
      label: "What's inside",
      min: 0,
      max: 6,
      getItemSummary: (item) => item?.title || "Item",
      defaultItemProps: { title: "New chapter", detail: "" },
      arrayFields: {
        title: { type: "text", label: "Title" },
        detail: { type: "textarea", label: "Detail", metadata: { help: "One short sentence. Leave blank to hide it." } },
      },
    },
    formAction: {
      type: "text",
      label: "Form action URL",
      metadata: { help: "Your list provider's form endpoint, from its embed code. Sent with POST. Have it email the download link, or redirect to the file." },
    },
    emailFieldName: { type: "text", label: "Email field name", metadata: { help: "The name your provider expects, like email or EMAIL." } },
    askName: {
      type: "radio",
      label: "Ask for first name",
      options: [
        { label: "Yes", value: true },
        { label: "No", value: false },
      ],
      metadata: { help: "Optional first-name field, sent as first_name." },
    },
    buttonLabel: { type: "text", label: "Button text" },
    privacyNote: { type: "textarea", label: "Privacy note", metadata: { help: "Shown under the form. Leave blank to hide it." } },
  },
  defaultProps: {
    eyebrow: "Free guide",
    heading: "The Neighborhood Tree Care Handbook",
    headingLevel: "h2",
    body: "Everything our urban forestry crew wishes every block captain knew, from choosing a native species to the first three summers of watering.",
    coverUrl: "https://picsum.photos/seed/canopy/600/800",
    coverAlt: "Cover of the Neighborhood Tree Care Handbook, showing sunlight through a leafy canopy",
    format: "PDF · 28 pages",
    insideHeading: "What's inside",
    inside: [
      { title: "Picking the right tree", detail: "Twelve native species matched to sidewalk strips, yards and overhead wires." },
      { title: "Planting day, step by step", detail: "Digging depth, mulch rings, and the mistakes that kill young trees." },
      { title: "The first three summers", detail: "A printable watering calendar for the years that matter most." },
      { title: "Organizing your block", detail: "Sign-up sheets and a letter template for recruiting neighbors." },
    ],
    formAction: "/guides/tree-care",
    emailFieldName: "email",
    askName: true,
    buttonLabel: "Email me the guide",
    privacyNote: "We'll send the download link right away, plus a monthly stewardship note. Unsubscribe any time.",
  },
  render: ({ id, eyebrow, heading, headingLevel, body, coverUrl, coverAlt, format, insideHeading, inside, formAction, emailFieldName, askName, buttonLabel, privacyNote }) => {
    const H = headingLevel || "h2";
    const Sub = childHeading[H] || "h3";
    const uid = `lm-${id || "guide"}`;
    const items = (inside ?? []).filter((it) => it?.title);

    return (
      <section className="overflow-hidden 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-center gap-12 ${coverUrl ? "max-w-6xl lg:grid-cols-12 lg:gap-16" : "max-w-3xl"}`}>
          {coverUrl ? (
            <div className="relative mx-auto w-full max-w-64 sm:max-w-72 lg:col-span-5 lg:max-w-sm">
              <div aria-hidden="true" className="absolute inset-0 translate-x-3 translate-y-3 rotate-3 rounded-r-xl rounded-l-sm bg-white shadow-md ring-1 ring-neutral-200" />
              <div aria-hidden="true" className="absolute inset-0 translate-x-1.5 translate-y-1.5 rotate-1 rounded-r-xl rounded-l-sm bg-white ring-1 ring-neutral-200" />
              <figure className="relative -rotate-1 overflow-hidden rounded-r-xl rounded-l-sm bg-neutral-900 shadow-2xl shadow-neutral-900/30 ring-1 ring-neutral-950/10">
                <img src={coverUrl} alt={coverAlt || ""} className="aspect-3/4 w-full object-cover" />
                <div aria-hidden="true" className="absolute inset-y-0 left-0 w-3 bg-linear-to-r from-neutral-950/40 to-transparent" />
                {format ? (
                  <figcaption className="absolute right-3 bottom-3 rounded-full bg-white px-3 py-1 text-xs font-semibold text-neutral-900 shadow-sm">{format}</figcaption>
                ) : null}
              </figure>
            </div>
          ) : null}

          <div className={coverUrl ? "lg:col-span-7" : ""}>
            {eyebrow ? (
              <p className="inline-flex items-center gap-2 text-sm font-semibold text-indigo-700">
                <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="size-4">
                  <path d="M10.75 2.75a.75.75 0 0 0-1.5 0v8.614L6.295 8.235a.75.75 0 1 0-1.09 1.03l4.25 4.5a.75.75 0 0 0 1.09 0l4.25-4.5a.75.75 0 0 0-1.09-1.03l-2.955 3.129V2.75Z" />
                  <path d="M3.5 12.75a.75.75 0 0 0-1.5 0v2.5A2.75 2.75 0 0 0 4.75 18h10.5A2.75 2.75 0 0 0 18 15.25v-2.5a.75.75 0 0 0-1.5 0v2.5c0 .69-.56 1.25-1.25 1.25H4.75c-.69 0-1.25-.56-1.25-1.25v-2.5Z" />
                </svg>
                {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-4 max-w-2xl text-lg leading-8 text-pretty text-neutral-600">{body}</p> : null}

            {items.length ? (
              <div className="mt-8">
                {insideHeading ? <Sub className="text-sm font-semibold text-neutral-950">{insideHeading}</Sub> : null}
                <ol role="list" className={`grid grid-cols-1 gap-x-8 gap-y-5 sm:grid-cols-2 ${insideHeading ? "mt-4" : ""}`}>
                  {items.map((it, i) => (
                    <li key={`${it.title}-${i}`} className="flex gap-4">
                      <span aria-hidden="true" className="w-6 shrink-0 pt-0.5 text-sm font-semibold text-indigo-700 tabular-nums">
                        {String(i + 1).padStart(2, "0")}
                      </span>
                      <div className="min-w-0 border-l border-neutral-300 pl-4">
                        <p className="text-base leading-6 font-semibold text-neutral-950">{it.title}</p>
                        {it.detail ? <p className="mt-1 text-sm leading-6 text-pretty text-neutral-600">{it.detail}</p> : null}
                      </div>
                    </li>
                  ))}
                </ol>
              </div>
            ) : null}

            <form action={formAction || undefined} method="post" className="mt-10 rounded-2xl bg-white p-4 shadow-sm ring-1 ring-neutral-200 sm:p-5">
              <div className={`flex flex-col gap-3 ${askName ? "lg:flex-row" : "sm:flex-row"}`}>
                {askName ? (
                  <div className="min-w-0 lg:basis-2/5">
                    <label htmlFor={`${uid}-name`} className="sr-only">
                      First name (optional)
                    </label>
                    <input id={`${uid}-name`} name="first_name" type="text" autoComplete="given-name" placeholder="First name (optional)" className={inputClass} />
                  </div>
                ) : null}
                <div className="min-w-0 flex-1">
                  <label htmlFor={`${uid}-email`} className="sr-only">
                    Email address
                  </label>
                  <input
                    id={`${uid}-email`}
                    name={emailFieldName || "email"}
                    type="email"
                    required
                    autoComplete="email"
                    inputMode="email"
                    placeholder="Email address"
                    className={inputClass}
                  />
                </div>
                <button
                  type="submit"
                  className={`inline-flex min-h-12 shrink-0 items-center justify-center gap-2 rounded-lg bg-indigo-600 px-5 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`}
                >
                  {buttonLabel || "Get the guide"}
                </button>
              </div>
              {privacyNote ? <p className="mt-3 px-1 text-sm leading-6 text-pretty text-neutral-600">{privacyNote}</p> : null}
            </form>
          </div>
        </div>
      </section>
    );
  },
};
```
