# Add the "Library Card" block to this P1 project

Add a Puck component from P1 Blocks (https://p1-blocks.prolificdigital.io/blocks/library-card) to this Pantheon Content Publisher (P1) Next.js project. Get a library card: who's eligible, what to bring, what a card unlocks, an apply link and an illustrated card.

## Steps

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

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

/**
 * Library Card — "Get a library card" section: who's eligible, what to bring, what a card
 * unlocks (icon list), an apply-online button and an illustrated card drawn in CSS.
 * Register: `LibraryCardBlock: libraryCardBlock` in puck.config.tsx.
 */

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

type Icon = "book" | "device" | "film" | "room" | "pass" | "print";

type Perk = { icon: Icon; title: string; description: string };

export type LibraryCardProps = {
  eyebrow: string;
  heading: string;
  headingLevel: Heading;
  intro: string;
  eligibilityHeading: string;
  eligibility: string;
  needsHeading: string;
  needs: { item: string }[];
  perksHeading: string;
  perks: Perk[];
  applyLabel: string;
  applyHref: string;
  secondaryLabel: string;
  secondaryHref: string;
  cardName: string;
  cardTagline: string;
};

const childLevel = { h1: "h2", h2: "h3", h3: "h4", h4: "h5" } as const;

const iconPaths: Record<Icon, React.ReactNode> = {
  book: <path d="M10.75 16.82A7.462 7.462 0 0 1 15 15.5c.71 0 1.396.098 2.046.282A.75.75 0 0 0 18 15.06v-11a.75.75 0 0 0-.546-.721A9.006 9.006 0 0 0 15 3a8.963 8.963 0 0 0-4.25 1.065V16.82ZM9.25 4.065A8.963 8.963 0 0 0 5 3c-.85 0-1.673.118-2.454.339A.75.75 0 0 0 2 4.06v11a.75.75 0 0 0 .954.721A7.506 7.506 0 0 1 5 15.5c1.579 0 3.042.487 4.25 1.32V4.065Z" />,
  device: <path fillRule="evenodd" d="M5 1a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V3a2 2 0 0 0-2-2H5Zm3 15a.75.75 0 0 0 0 1.5h4a.75.75 0 0 0 0-1.5H8Z" clipRule="evenodd" />,
  film: <path fillRule="evenodd" d="M1 4.75C1 3.784 1.784 3 2.75 3h14.5c.966 0 1.75.784 1.75 1.75v10.515a1.75 1.75 0 0 1-1.75 1.75h-1.5c-.078 0-.155-.005-.23-.015H4.48c-.075.01-.152.015-.23.015h-1.5A1.75 1.75 0 0 1 1 15.265V4.75Zm16.5 7.385V11.01a.25.25 0 0 0-.25-.25h-1.5a.25.25 0 0 0-.25.25v1.125c0 .138.112.25.25.25h1.5a.25.25 0 0 0 .25-.25Zm0 2.005a.25.25 0 0 0-.25-.25h-1.5a.25.25 0 0 0-.25.25v1.125c0 .108.069.2.165.235h1.585a.25.25 0 0 0 .25-.25v-1.11Zm-15 1.11v-1.11a.25.25 0 0 1 .25-.25h1.5a.25.25 0 0 1 .25.25v1.125a.25.25 0 0 1-.164.235H2.75a.25.25 0 0 1-.25-.25Zm2-4.24v1.125a.25.25 0 0 1-.25.25h-1.5a.25.25 0 0 1-.25-.25V11.01a.25.25 0 0 1 .25-.25h1.5a.25.25 0 0 1 .25.25Zm13-2.005V7.88a.25.25 0 0 0-.25-.25h-1.5a.25.25 0 0 0-.25.25v1.125c0 .138.112.25.25.25h1.5a.25.25 0 0 0 .25-.25ZM4.25 7.63a.25.25 0 0 1 .25.25v1.125a.25.25 0 0 1-.25.25h-1.5a.25.25 0 0 1-.25-.25V7.88a.25.25 0 0 1 .25-.25h1.5Zm0-3.13a.25.25 0 0 1 .25.25v1.125a.25.25 0 0 1-.25.25h-1.5a.25.25 0 0 1-.25-.25V4.75a.25.25 0 0 1 .25-.25h1.5Zm11.5 1.625a.25.25 0 0 1-.25-.25V4.75a.25.25 0 0 1 .25-.25h1.5a.25.25 0 0 1 .25.25v1.125a.25.25 0 0 1-.25.25h-1.5Zm-9 3.125a.75.75 0 0 1 .75-.75h5a.75.75 0 0 1 0 1.5h-5a.75.75 0 0 1-.75-.75Z" clipRule="evenodd" />,
  room: <path fillRule="evenodd" d="M4 16.5v-13h-.25a.75.75 0 0 1 0-1.5h12.5a.75.75 0 0 1 0 1.5H16v13h.25a.75.75 0 0 1 0 1.5h-3.5a.75.75 0 0 1-.75-.75v-2.5a.75.75 0 0 0-.75-.75h-2.5a.75.75 0 0 0-.75.75v2.5a.75.75 0 0 1-.75.75h-3.5a.75.75 0 0 1 0-1.5H4Zm3-11a.5.5 0 0 1 .5-.5h1a.5.5 0 0 1 .5.5v1a.5.5 0 0 1-.5.5h-1a.5.5 0 0 1-.5-.5v-1ZM7.5 9a.5.5 0 0 0-.5.5v1a.5.5 0 0 0 .5.5h1a.5.5 0 0 0 .5-.5v-1a.5.5 0 0 0-.5-.5h-1ZM11 5.5a.5.5 0 0 1 .5-.5h1a.5.5 0 0 1 .5.5v1a.5.5 0 0 1-.5.5h-1a.5.5 0 0 1-.5-.5v-1Zm.5 3.5a.5.5 0 0 0-.5.5v1a.5.5 0 0 0 .5.5h1a.5.5 0 0 0 .5-.5v-1a.5.5 0 0 0-.5-.5h-1Z" clipRule="evenodd" />,
  pass: <path fillRule="evenodd" d="M1 4.75C1 3.784 1.784 3 2.75 3h14.5c.966 0 1.75.784 1.75 1.75v2.002a.75.75 0 0 1-.6.735 2.5 2.5 0 0 0 0 4.926.75.75 0 0 1 .6.735v2.102A1.75 1.75 0 0 1 17.25 17H2.75A1.75 1.75 0 0 1 1 15.25v-2.102a.75.75 0 0 1 .6-.735 2.5 2.5 0 0 0 0-4.926.75.75 0 0 1-.6-.735V4.75Z" clipRule="evenodd" />,
  print: <path fillRule="evenodd" d="M5 2.75C5 1.784 5.784 1 6.75 1h6.5c.966 0 1.75.784 1.75 1.75v3.552c.377.046.752.097 1.126.153A2.212 2.212 0 0 1 18 8.653v4.097A2.25 2.25 0 0 1 15.75 15h-.241l.305 1.984A1.75 1.75 0 0 1 14.084 19H5.915a1.75 1.75 0 0 1-1.73-2.016L4.492 15H4.25A2.25 2.25 0 0 1 2 12.75V8.653c0-1.082.775-2.034 1.874-2.198.374-.056.75-.107 1.127-.153L5 6.25v-3.5Zm8.5 3.397a41.533 41.533 0 0 0-7 0V2.75a.25.25 0 0 1 .25-.25h6.5a.25.25 0 0 1 .25.25v3.397ZM6.608 12.5a.25.25 0 0 0-.247.212l-.693 4.5a.25.25 0 0 0 .247.288h8.17a.25.25 0 0 0 .246-.288l-.692-4.5a.25.25 0 0 0-.247-.212H6.608Z" clipRule="evenodd" />,
};

const iconOptions = [
  { label: "Book", value: "book" },
  { label: "Phone / tablet", value: "device" },
  { label: "Film", value: "film" },
  { label: "Building / room", value: "room" },
  { label: "Ticket / pass", value: "pass" },
  { label: "Printer", value: "print" },
];

export const libraryCardBlock: ComponentConfig<LibraryCardProps> = {
  label: "Library Card",
  fields: {
    eyebrow: { type: "text", label: "Eyebrow", metadata: { help: "Small line above the heading, such as It's free. 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" },
    eligibilityHeading: { type: "text", label: "Eligibility heading" },
    eligibility: { type: "textarea", label: "Who can get a card", metadata: { help: "Leave blank to hide this part." } },
    needsHeading: { type: "text", label: "What to bring heading" },
    needs: {
      type: "array",
      label: "What to bring",
      min: 0,
      max: 6,
      getItemSummary: (item) => item?.item || "Item",
      defaultItemProps: { item: "A parent or guardian, for cardholders under 14" },
      arrayFields: { item: { type: "text", label: "Item" } },
    },
    perksHeading: { type: "text", label: "Benefits heading" },
    perks: {
      type: "array",
      label: "What a card gets you",
      min: 0,
      max: 8,
      getItemSummary: (item) => item?.title || "Benefit",
      defaultItemProps: { icon: "book", title: "New benefit", description: "" },
      arrayFields: {
        icon: { type: "select", label: "Icon", options: iconOptions },
        title: { type: "text", label: "Title" },
        description: { type: "textarea", label: "Description", metadata: { help: "One short sentence. Leave blank to hide it." } },
      },
    },
    applyLabel: { type: "text", label: "Apply button text", metadata: { help: "Leave blank to hide the button." } },
    applyHref: { type: "text", label: "Apply link", metadata: { help: "Your online card application." } },
    secondaryLabel: { type: "text", label: "Second link text", metadata: { help: "Such as Card policies or Renew your card. Leave blank to hide it." } },
    secondaryHref: { type: "text", label: "Second link" },
    cardName: { type: "text", label: "Name on illustrated card", metadata: { help: "Your library's name as printed on the card graphic. The graphic is decorative." } },
    cardTagline: { type: "text", label: "Tagline on illustrated card", metadata: { help: "Leave blank to hide it." } },
  },
  defaultProps: {
    eyebrow: "Free for everyone who lives, works or studies here",
    heading: "Get your library card",
    headingLevel: "h2",
    intro: "One card opens every branch, thousands of e-books, museum passes and a quiet room when you need one. Apply online in five minutes, then pick it up at any desk.",
    eligibilityHeading: "Who's eligible",
    eligibility: "Anyone who lives, works, owns property or attends school in Cedar Valley or Ash County. Kids of any age can have their own card with a grown-up's signature.",
    needsHeading: "What to bring",
    needs: [
      { item: "A photo ID, such as a driver's license, state ID, passport or school ID" },
      { item: "Proof of address dated in the last 60 days, such as a lease, utility bill or piece of mail" },
      { item: "A parent or guardian, for cardholders under 14" },
    ],
    perksHeading: "What your card gets you",
    perks: [
      { icon: "book", title: "Borrow up to 50 items", description: "Books, audiobooks, magazines and more, with three-week loans and free holds." },
      { icon: "device", title: "E-books & audiobooks app", description: "Read and listen on your phone, tablet or e-reader from home." },
      { icon: "film", title: "Movies & streaming", description: "DVDs from the shelf, plus films and TV through our streaming service." },
      { icon: "room", title: "Study & meeting rooms", description: "Book a free room for tutoring, interviews or your book club." },
      { icon: "pass", title: "Museum & park passes", description: "Free family admission to the zoo, science center and state parks." },
      { icon: "print", title: "Printing & Wi-Fi", description: "Twenty free pages a week and fast Wi-Fi at every branch." },
    ],
    applyLabel: "Apply online",
    applyHref: "/card/apply",
    secondaryLabel: "Read card policies",
    secondaryHref: "/card/policies",
    cardName: "Cedar Valley Public Library",
    cardTagline: "Read. Wonder. Belong.",
  },
  render: ({ eyebrow, heading, headingLevel, intro, eligibilityHeading, eligibility, needsHeading, needs, perksHeading, perks, applyLabel, applyHref, secondaryLabel, secondaryHref, cardName, cardTagline }) => {
    const H = headingLevel || "h2";
    const Sub = childLevel[H] ?? "h3";
    const needList = (needs ?? []).filter((n) => n?.item);
    const perkList = (perks ?? []).filter((p) => p?.title);

    return (
      <section className="overflow-hidden 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-7">
            {eyebrow ? <p className="text-sm font-semibold text-indigo-700">{eyebrow}</p> : null}
            {heading ? (
              <H className={`${eyebrow ? "mt-3" : ""} font-serif text-3xl font-semibold tracking-tight text-balance text-neutral-950 sm:text-5xl`}>{heading}</H>
            ) : null}
            {intro ? <p className="mt-5 max-w-2xl text-lg leading-8 text-pretty text-neutral-600">{intro}</p> : null}

            {eligibility || needList.length ? (
              <div className="mt-10 grid grid-cols-1 gap-8 sm:grid-cols-2">
                {eligibility ? (
                  <div>
                    <Sub className="text-base font-semibold text-neutral-950">{eligibilityHeading || "Who's eligible"}</Sub>
                    <p className="mt-2 text-sm leading-6 text-pretty text-neutral-700">{eligibility}</p>
                  </div>
                ) : null}
                {needList.length ? (
                  <div>
                    <Sub className="text-base font-semibold text-neutral-950">{needsHeading || "What to bring"}</Sub>
                    <ul role="list" className="mt-2 space-y-2">
                      {needList.map((n, i) => (
                        <li key={`${n.item}-${i}`} className="flex gap-2.5 text-sm leading-6 text-neutral-700">
                          <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="mt-0.5 size-5 shrink-0 text-indigo-600">
                            <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>
                          <span className="min-w-0">{n.item}</span>
                        </li>
                      ))}
                    </ul>
                  </div>
                ) : null}
              </div>
            ) : null}

            {applyLabel || secondaryLabel ? (
              <div className="mt-10 flex flex-col gap-3 sm:flex-row sm:items-center sm:gap-6">
                {applyLabel ? (
                  <a
                    href={applyHref || "#"}
                    className="inline-flex min-h-12 items-center justify-center gap-2 rounded-xl bg-indigo-600 px-6 py-3 text-base font-semibold text-white shadow-sm transition hover:bg-indigo-500 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600"
                  >
                    {applyLabel}
                    <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>
                  </a>
                ) : null}
                {secondaryLabel ? (
                  <a
                    href={secondaryHref || "#"}
                    className="inline-flex min-h-11 items-center justify-center rounded text-sm font-semibold text-neutral-900 underline decoration-neutral-300 underline-offset-4 hover:text-indigo-700 hover:decoration-indigo-400 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600 sm:justify-start"
                  >
                    {secondaryLabel}
                  </a>
                ) : null}
              </div>
            ) : null}
          </div>

          <div className="lg:col-span-5">
            <div aria-hidden="true" className="relative mx-auto w-full max-w-sm pt-4 pb-10 lg:mt-6">
              <div className="absolute inset-x-6 top-10 bottom-4 rotate-6 rounded-2xl bg-indigo-100" />
              <div className="relative aspect-8/5 -rotate-3 overflow-hidden rounded-2xl bg-indigo-700 p-5 text-white shadow-xl ring-1 ring-indigo-950/20 transition duration-500 motion-safe:hover:rotate-0">
                <svg viewBox="0 0 200 126" fill="none" className="absolute inset-0 size-full text-indigo-500/40" preserveAspectRatio="none">
                  <path d="M0 96c40-18 70 10 110-6s60-40 90-30v66H0Z" fill="currentColor" />
                  <path d="M0 110c40-12 80 8 120-4s60-22 80-18v38H0Z" fill="currentColor" />
                </svg>
                <div className="relative flex h-full flex-col justify-between">
                  <div className="flex items-start justify-between gap-3">
                    <p className="font-serif text-base leading-tight font-semibold sm:text-lg">{cardName || "Public Library"}</p>
                    <svg viewBox="0 0 20 20" fill="currentColor" className="size-7 shrink-0 text-indigo-200">
                      {iconPaths.book}
                    </svg>
                  </div>
                  <div>
                    {cardTagline ? <p className="text-xs font-medium tracking-widest text-indigo-100 uppercase">{cardTagline}</p> : null}
                    <div className="mt-3 flex items-end justify-between gap-3">
                      <div className="flex h-8 items-end gap-px">
                        {[3, 1, 2, 1, 3, 2, 1, 1, 3, 1, 2, 3, 1, 2, 1, 3, 1, 1, 2, 3].map((w, i) => (
                          <span key={i} className={`h-full bg-white ${w === 1 ? "w-px" : w === 2 ? "w-0.5" : "w-1"}`} />
                        ))}
                      </div>
                      <p className="font-mono text-xs tracking-wider text-indigo-100 tabular-nums">2 1234 0056 7890</p>
                    </div>
                  </div>
                </div>
              </div>
            </div>

            {perkList.length ? (
              <div className="mt-4">
                <Sub className="text-base font-semibold text-neutral-950">{perksHeading || "What your card gets you"}</Sub>
                <ul role="list" className="mt-4 grid grid-cols-1 gap-x-6 gap-y-5 sm:grid-cols-2 lg:grid-cols-1 xl:grid-cols-2">
                  {perkList.map((p, i) => (
                    <li key={`${p.title}-${i}`} className="flex gap-3">
                      <span className="grid size-10 shrink-0 place-items-center rounded-full bg-indigo-50 text-indigo-700 ring-1 ring-indigo-600/10">
                        <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="size-5">
                          {iconPaths[p.icon] ?? iconPaths.book}
                        </svg>
                      </span>
                      <div className="min-w-0">
                        <p className="text-sm font-semibold text-neutral-950">{p.title}</p>
                        {p.description ? <p className="mt-0.5 text-sm leading-6 text-neutral-600">{p.description}</p> : null}
                      </div>
                    </li>
                  ))}
                </ul>
              </div>
            ) : null}
          </div>
        </div>
      </section>
    );
  },
};
```
