# Add the "Shop Categories" block to this P1 project

Add a Puck component from P1 Blocks (https://p1-blocks.prolificdigital.io/blocks/shop-categories) to this Pantheon Content Publisher (P1) Next.js project. Gift shop departments as an asymmetric photo mosaic, the first tile large, each with a name, item count and link.

## Steps

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

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

/**
 * Shop Categories — gift shop departments as an asymmetric mosaic of photo tiles, the first one
 * large, each with a name, item count and link. Text sits on a solid scrim so it stays readable.
 * Register: `ShopCategoriesBlock: shopCategoriesBlock` in puck.config.tsx.
 */

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

type Category = { name: string; count: string; blurb: string; href: string; imageUrl: string; imageAlt: string };

export type ShopCategoriesProps = {
  eyebrow: string;
  heading: string;
  headingLevel: Heading;
  intro: string;
  categories: Category[];
  ctaLabel: string;
  ctaHref: string;
};

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

// Tile spans for the 4-column desktop mosaic: the feature tile fills the left half, the rest fill in around it.
const tileSpan = (i: number, count: number) => {
  if (i === 0) return "min-h-80 sm:col-span-2 lg:row-span-2 lg:min-h-0";
  if (count === 2) return "min-h-64 lg:col-span-2 lg:row-span-2";
  if (count === 3) return "min-h-64 lg:col-span-2";
  if (count >= 6 && i >= 5) return "min-h-64 sm:col-span-2";
  return "min-h-64";
};

export const shopCategoriesBlock: ComponentConfig<ShopCategoriesProps> = {
  label: "Shop Categories",
  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." },
    },
    intro: { type: "textarea", label: "Intro" },
    categories: {
      type: "array",
      label: "Categories",
      min: 1,
      max: 7,
      getItemSummary: (item) => item?.name || "Category",
      defaultItemProps: { name: "New category", count: "", blurb: "", href: "#", imageUrl: "https://picsum.photos/seed/shopcategory/900/700", imageAlt: "" },
      arrayFields: {
        name: { type: "text", label: "Name" },
        count: { type: "text", label: "Item count", metadata: { help: "Such as \"48 items\". Can be bound to a data source. Leave blank to hide it." } },
        blurb: { type: "text", label: "Short line", metadata: { help: "Shown on the large first tile only." } },
        href: { type: "text", label: "Link" },
        imageUrl: { type: "text", label: "Image URL" },
        imageAlt: { type: "text", label: "Image alt text", metadata: { help: "The category name is already read out; leave blank unless the photo adds something." } },
      },
      metadata: { help: "The first category gets the large tile. Five or seven tiles fill the mosaic evenly on wide screens." },
    },
    ctaLabel: { type: "text", label: "Link text", metadata: { help: "A link under the mosaic, such as to the full shop. Leave blank to hide it." } },
    ctaHref: { type: "text", label: "Link URL" },
  },
  defaultProps: {
    eyebrow: "Museum Store",
    heading: "Shop the collection",
    headingLevel: "h2",
    intro: "Books, replicas and handmade gifts chosen by our curators. Open in the Great Hall daily and online any time.",
    categories: [
      {
        name: "Fossils & replicas",
        count: "64 items",
        blurb: "Museum-quality casts made from specimens in our own collection.",
        href: "/shop/fossils",
        imageUrl: "https://picsum.photos/seed/fossilshop/1200/1200",
        imageAlt: "",
      },
      { name: "Books & field guides", count: "112 items", blurb: "", href: "/shop/books", imageUrl: "https://picsum.photos/seed/bookshelf/800/600", imageAlt: "" },
      { name: "Kids & science kits", count: "58 items", blurb: "", href: "/shop/kids", imageUrl: "https://picsum.photos/seed/sciencekit/800/600", imageAlt: "" },
      { name: "Home & kitchen", count: "41 items", blurb: "", href: "/shop/home", imageUrl: "https://picsum.photos/seed/ceramics/1200/600", imageAlt: "" },
      { name: "Jewelry", count: "37 items", blurb: "", href: "/shop/jewelry", imageUrl: "https://picsum.photos/seed/gemstone/800/600", imageAlt: "" },
    ],
    ctaLabel: "Browse every department",
    ctaHref: "/shop",
  },
  render: ({ eyebrow, heading, headingLevel, intro, categories, ctaLabel, ctaHref }) => {
    const H = headingLevel || "h2";
    const Sub = childHeading[H] || "h3";
    const list = (categories ?? []).filter((c) => c?.name).slice(0, 7);
    const hasHeader = Boolean(eyebrow || heading || intro);

    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="max-w-2xl">
              {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}
              {intro ? <p className="mt-4 text-lg leading-8 text-pretty text-neutral-600">{intro}</p> : null}
            </div>
          ) : null}

          {list.length ? (
            <ul role="list" className={`grid grid-cols-1 gap-4 sm:grid-cols-2 lg:auto-rows-fr lg:grid-cols-4 ${hasHeader ? "mt-12" : ""}`}>
              {list.map((c, i) => {
                const feature = i === 0;
                return (
                  <li key={`${c.name}-${i}`} className={`flex ${tileSpan(i, list.length)}`}>
                    <a
                      href={c.href || "#"}
                      className="group relative isolate flex w-full flex-col justify-end overflow-hidden rounded-2xl bg-neutral-900 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600"
                    >
                      {c.imageUrl ? (
                        <img src={c.imageUrl} alt={c.imageAlt || ""} className="absolute inset-0 -z-10 size-full object-cover transition duration-700 group-hover:scale-105" />
                      ) : null}
                      <div aria-hidden="true" className="absolute inset-x-0 bottom-0 -z-10 h-3/4 bg-linear-to-t from-neutral-950 via-neutral-950/70 to-transparent" />
                      <div className={`flex items-end justify-between gap-4 bg-neutral-950/40 ${feature ? "p-6 sm:p-8" : "p-5"}`}>
                        <div className="min-w-0">
                          <Sub className={`font-semibold tracking-tight text-white ${feature ? "text-2xl sm:text-3xl" : "text-lg"}`}>{c.name}</Sub>
                          {feature && c.blurb ? <p className="mt-2 max-w-sm text-base leading-7 text-pretty text-neutral-100">{c.blurb}</p> : null}
                          {c.count ? <p className="mt-1 text-sm font-medium text-neutral-200 tabular-nums">{c.count}</p> : null}
                        </div>
                        <span aria-hidden="true" className="flex size-11 shrink-0 items-center justify-center rounded-full bg-white text-neutral-950 transition group-hover:translate-x-1">
                          <svg 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>
                        </span>
                      </div>
                    </a>
                  </li>
                );
              })}
            </ul>
          ) : null}

          {ctaLabel ? (
            <p className="mt-10">
              <a
                href={ctaHref || "#"}
                className="inline-flex min-h-11 items-center justify-center rounded-lg bg-neutral-950 px-6 py-3 text-base font-semibold text-white transition hover:bg-neutral-800 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600"
              >
                {ctaLabel}
              </a>
            </p>
          ) : null}
        </div>
      </section>
    );
  },
};
```
