# Add the "New Arrivals" block to this P1 project

Add a Puck component from P1 Blocks (https://p1-blocks.prolificdigital.io/blocks/new-arrivals) to this Pantheon Content Publisher (P1) Next.js project. A shelf of new titles with covers, authors and format badges that swipes sideways on phones and links to the catalog.

## Steps

1. Create `components/puck/new-arrivals-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 { newArrivalsBlock } from "./components/puck/new-arrivals-block";`
3. Register it under `components` as `NewArrivalsBlock: newArrivalsBlock`.
4. Add `"NewArrivalsBlock"` 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/new-arrivals-block.tsx`

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

/**
 * New Arrivals — a shelf of new titles: cover, title, author and format badge, each linking
 * to its catalog record. Scrolls sideways with snap on phones; becomes a grid on desktop.
 * Register: `NewArrivalsBlock: newArrivalsBlock` in puck.config.tsx.
 */

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

type Tone = "indigo" | "ink" | "paper" | "dusk";

type Title = {
  title: string;
  author: string;
  format: string;
  imageUrl: string;
  imageAlt: string;
  tone: Tone;
  href: string;
};

export type NewArrivalsProps = {
  heading: string;
  headingLevel: Heading;
  intro: string;
  allLabel: string;
  allHref: string;
  items: Title[];
};

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

const coverTones: Record<Tone, { bg: string; text: string; rule: string }> = {
  indigo: { bg: "bg-indigo-800", text: "text-white", rule: "bg-indigo-300" },
  ink: { bg: "bg-neutral-900", text: "text-neutral-50", rule: "bg-indigo-400" },
  paper: { bg: "bg-neutral-100", text: "text-neutral-900", rule: "bg-indigo-600" },
  dusk: { bg: "bg-indigo-200", text: "text-indigo-950", rule: "bg-indigo-700" },
};

export const newArrivalsBlock: ComponentConfig<NewArrivalsProps> = {
  label: "New Arrivals",
  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" },
    allLabel: { type: "text", label: "See all link text", metadata: { help: "Leave blank to hide it." } },
    allHref: { type: "text", label: "See all link" },
    items: {
      type: "array",
      label: "Titles",
      min: 1,
      max: 16,
      getItemSummary: (item) => item?.title || "Title",
      defaultItemProps: { title: "New title", author: "Author name", format: "Book", imageUrl: "", imageAlt: "", tone: "indigo", href: "" },
      arrayFields: {
        title: { type: "text", label: "Title" },
        author: { type: "text", label: "Author or creator" },
        format: { type: "text", label: "Format", metadata: { help: "Short badge, such as Book, Large print, Audiobook, DVD or Vinyl. Leave blank to hide it." } },
        imageUrl: { type: "text", label: "Cover image URL", metadata: { help: "Leave blank to show a typeset cover with the title instead." } },
        imageAlt: { type: "text", label: "Cover alt text", metadata: { help: "Usually blank: the title is already read out. Add text only if the cover shows something important." } },
        tone: {
          type: "select",
          label: "Typeset cover color",
          options: [
            { label: "Indigo", value: "indigo" },
            { label: "Ink", value: "ink" },
            { label: "Paper", value: "paper" },
            { label: "Dusk", value: "dusk" },
          ],
          metadata: { help: "Used only when there's no cover image." },
        },
        href: { type: "text", label: "Catalog link", metadata: { help: "The title's record in your catalog. Leave blank for no link." } },
      },
    },
  },
  defaultProps: {
    heading: "New on the shelf",
    headingLevel: "h2",
    intro: "Fresh arrivals picked by Cedar Valley librarians this month. Place a hold and pick it up at any branch.",
    allLabel: "See all new arrivals",
    allHref: "/catalog/new",
    items: [
      { title: "The Orchard Keeper's Daughter", author: "Mara Ellison", format: "Book", imageUrl: "https://picsum.photos/seed/orchardbook/400/600", imageAlt: "", tone: "indigo", href: "/catalog/record/1001" },
      { title: "Small Rivers", author: "Theo Okafor", format: "Audiobook", imageUrl: "", imageAlt: "", tone: "ink", href: "/catalog/record/1002" },
      { title: "A Field Guide to Kitchen Bread", author: "Ines Varga", format: "Book", imageUrl: "https://picsum.photos/seed/breadbook/400/600", imageAlt: "", tone: "paper", href: "/catalog/record/1003" },
      { title: "The Lighthouse at Gray Point", author: "June Halvorsen", format: "Large print", imageUrl: "", imageAlt: "", tone: "dusk", href: "/catalog/record/1004" },
      { title: "Winter Garden", author: "Directed by Sam Reyes", format: "DVD", imageUrl: "https://picsum.photos/seed/wintergarden/400/600", imageAlt: "", tone: "indigo", href: "/catalog/record/1005" },
      { title: "How Cities Remember", author: "Priya Natarajan", format: "Book", imageUrl: "", imageAlt: "", tone: "paper", href: "/catalog/record/1006" },
    ],
  },
  render: ({ id, heading, headingLevel, intro, allLabel, allHref, items }) => {
    const H = headingLevel || "h2";
    const Sub = childLevel[H] ?? "h3";
    const list = (items ?? []).filter((t) => t?.title);
    const headingId = `p1-new-arrivals-${id || "block"}-heading`;
    const hasHeader = Boolean(heading || intro || allLabel);

    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 max-w-7xl">
          {hasHeader ? (
            <div className="flex flex-col gap-6 sm:flex-row sm:items-end sm:justify-between">
              <div className="max-w-2xl">
                {heading ? (
                  <H id={headingId} className="font-serif text-3xl font-semibold tracking-tight text-balance text-neutral-950 sm:text-4xl">
                    {heading}
                  </H>
                ) : null}
                {intro ? <p className="mt-4 text-base leading-7 text-pretty text-neutral-600">{intro}</p> : null}
              </div>
              {allLabel ? (
                <a
                  href={allHref || "#"}
                  className="group inline-flex min-h-11 shrink-0 items-center gap-1.5 self-start rounded font-semibold text-indigo-700 underline decoration-indigo-300 underline-offset-4 hover:decoration-indigo-700 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600 sm:self-auto"
                >
                  {allLabel}
                  <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="size-5 transition group-hover:translate-x-0.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}
            </div>
          ) : null}

          {list.length ? (
            <div
              role="region"
              tabIndex={0}
              {...(heading ? { "aria-labelledby": headingId } : { "aria-label": "New arrivals" })}
              className={`relative -mx-4 overflow-x-auto overscroll-x-contain px-4 pb-4 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600 sm:-mx-6 sm:px-6 lg:mx-0 lg:overflow-visible lg:px-0 lg:pb-0 ${hasHeader ? "mt-10 sm:mt-12" : ""}`}
            >
              <ul role="list" className="flex snap-x snap-mandatory gap-5 lg:grid lg:grid-cols-6 lg:gap-6">
                {list.map((t, i) => {
                  const tone = coverTones[t.tone] ?? coverTones.indigo;
                  const Wrap = t.href ? "a" : "div";
                  return (
                    <li key={`${t.title}-${i}`} className="w-40 shrink-0 snap-start sm:w-44 lg:w-auto">
                      <article className="group relative flex h-full flex-col">
                        <div className="relative aspect-2/3 overflow-hidden rounded-r-md rounded-l-sm shadow-md ring-1 ring-neutral-950/10 transition duration-300 group-hover:-translate-y-1 group-hover:shadow-lg motion-reduce:transition-none motion-reduce:group-hover:translate-y-0">
                          {t.imageUrl ? (
                            <img src={t.imageUrl} alt={t.imageAlt || ""} loading="lazy" className="size-full object-cover" />
                          ) : (
                            <div aria-hidden="true" className={`flex size-full flex-col justify-between p-4 ${tone.bg} ${tone.text}`}>
                              <span className={`h-0.5 w-8 ${tone.rule}`} />
                              <span className="font-serif text-lg leading-tight font-semibold text-balance break-words">{t.title}</span>
                              <span className="text-xs font-medium tracking-widest uppercase opacity-80">{t.author}</span>
                            </div>
                          )}
                          <span aria-hidden="true" className="absolute inset-y-0 left-0 w-1.5 bg-linear-to-r from-neutral-950/25 to-transparent" />
                        </div>
                        <div className="mt-3 flex flex-1 flex-col">
                          {t.format ? (
                            <p className="mb-1.5 inline-flex self-start rounded-full bg-indigo-50 px-2 py-0.5 text-xs font-medium text-indigo-700 ring-1 ring-indigo-600/15 ring-inset">
                              <span className="sr-only">Format: </span>
                              {t.format}
                            </p>
                          ) : null}
                          <Sub className="text-sm leading-5 font-semibold text-pretty text-neutral-950">
                            <Wrap
                              {...(t.href ? { href: t.href } : {})}
                              className={t.href ? "rounded-sm outline-none after:absolute after:inset-0 after:rounded-md focus-visible:after:outline-2 focus-visible:after:outline-offset-4 focus-visible:after:outline-indigo-600 group-hover:text-indigo-700" : undefined}
                            >
                              {t.title}
                            </Wrap>
                          </Sub>
                          {t.author ? <p className="mt-1 text-sm leading-5 text-neutral-600">{t.author}</p> : null}
                        </div>
                      </article>
                    </li>
                  );
                })}
              </ul>
            </div>
          ) : null}
        </div>
      </section>
    );
  },
};
```
