# Add the "Bento Grid" block to this P1 project

Add a Puck component from P1 Blocks (https://p1-blocks.prolificdigital.io/blocks/bento-grid) to this Pantheon Content Publisher (P1) Next.js project. An asymmetric mosaic of five to seven small, wide and tall tiles with optional photos, tones and links.

## Steps

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

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

/**
 * Bento Grid — an asymmetric mosaic of five to seven tiles. Each tile picks a size
 * (small, wide or tall) and a tone, and can carry a photo, so one section shows a whole program at a glance.
 * Register: `BentoGridBlock: bentoGridBlock` in puck.config.tsx.
 */

type Heading = "h1" | "h2" | "h3" | "h4";
type TileSize = "small" | "wide" | "tall";
type TileTone = "light" | "accent" | "dark";

export type BentoGridProps = {
  eyebrow: string;
  heading: string;
  headingLevel: Heading;
  intro: string;
  tiles: {
    size: TileSize;
    tone: TileTone;
    kicker: string;
    title: string;
    text: string;
    imageUrl: string;
    imageAlt: string;
    linkLabel: string;
    linkHref: string;
  }[];
};

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

// Six-column desktop track: small = 2, wide = 4, tall = 2 columns over 2 rows. Dense flow backfills gaps.
const sizeClass: Record<TileSize, string> = {
  small: "lg:col-span-2",
  wide: "sm:col-span-2 lg:col-span-4",
  tall: "sm:row-span-2 lg:col-span-2 lg:row-span-2",
};

const toneClass: Record<TileTone, { tile: string; kicker: string; title: string; text: string; link: string }> = {
  light: {
    tile: "bg-neutral-50 ring-1 ring-neutral-950/5",
    kicker: "text-indigo-700",
    title: "text-neutral-950",
    text: "text-neutral-600",
    link: "text-indigo-700 hover:text-indigo-900 focus-visible:outline-indigo-600",
  },
  accent: {
    tile: "bg-indigo-600",
    kicker: "text-indigo-100",
    title: "text-white",
    text: "text-indigo-50",
    link: "text-white underline decoration-indigo-300 underline-offset-4 hover:decoration-white focus-visible:outline-white",
  },
  dark: {
    tile: "bg-neutral-950",
    kicker: "text-indigo-300",
    title: "text-white",
    text: "text-neutral-300",
    link: "text-white underline decoration-neutral-500 underline-offset-4 hover:decoration-white focus-visible:outline-white",
  },
};

export const bentoGridBlock: ComponentConfig<BentoGridProps> = {
  label: "Bento Grid",
  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. Tile titles use the next level down." },
    },
    intro: { type: "textarea", label: "Intro" },
    tiles: {
      type: "array",
      label: "Tiles",
      min: 1,
      max: 7,
      getItemSummary: (item) => `${item?.title?.slice(0, 40) || "Tile"} (${item?.size || "small"})`,
      defaultItemProps: {
        size: "small",
        tone: "light",
        kicker: "",
        title: "New tile",
        text: "One or two sentences that earn the space.",
        imageUrl: "",
        imageAlt: "",
        linkLabel: "",
        linkHref: "",
      },
      arrayFields: {
        size: {
          type: "select",
          label: "Size",
          options: [
            { label: "Small", value: "small" },
            { label: "Wide", value: "wide" },
            { label: "Tall", value: "tall" },
          ],
          metadata: { help: "On wide screens: small takes a third of a row, wide two thirds, tall a third across two rows. Phones stack every tile." },
        },
        tone: {
          type: "select",
          label: "Tone",
          options: [
            { label: "Light", value: "light" },
            { label: "Accent", value: "accent" },
            { label: "Dark", value: "dark" },
          ],
          metadata: { help: "Use Accent or Dark on one or two tiles at most so they stand out." },
        },
        kicker: { type: "text", label: "Kicker", metadata: { help: "Short label or figure above the title, like “New in 2026”. Leave blank to hide it." } },
        title: { type: "text", label: "Title" },
        text: { type: "textarea", label: "Text" },
        imageUrl: { type: "text", label: "Image URL", metadata: { help: "Optional. Wide tiles show it beside the text; small and tall tiles show it above." } },
        imageAlt: { type: "text", label: "Image alt text", metadata: { help: "Describe the photo for screen reader users. Leave blank only if it's purely decorative." } },
        linkLabel: { type: "text", label: "Link text", metadata: { help: "Leave blank to hide the link." } },
        linkHref: { type: "text", label: "Link" },
      },
    },
  },
  defaultProps: {
    eyebrow: "Parks & Recreation",
    heading: "A year outside, all in one place",
    headingLevel: "h2",
    intro: "From the first spring planting to the winter lantern walk, here is what our 41 parks and six community centers have planned this season.",
    tiles: [
      {
        size: "wide",
        tone: "light",
        kicker: "Opening June 14",
        title: "Riverside Greenway, phase two",
        text: "Two more miles of paved, lit trail connect the Eastside library to the Falls overlook, with water fountains and bike repair stands every half mile.",
        imageUrl: "https://picsum.photos/seed/greenway/900/700",
        imageAlt: "A paved trail curving along a wooded riverbank in early morning light",
        linkLabel: "See the trail map",
        linkHref: "/parks/greenway",
      },
      {
        size: "tall",
        tone: "dark",
        kicker: "Summer camps",
        title: "Registration opens March 3",
        text: "Nature, art, swim and STEM camps for ages 5 to 14. Half of every session is held for families using fee assistance.",
        imageUrl: "https://picsum.photos/seed/campers/700/900",
        imageAlt: "Kids in matching camp shirts gathered around a counselor at a picnic table",
        linkLabel: "Browse camps",
        linkHref: "/camps",
      },
      {
        size: "small",
        tone: "accent",
        kicker: "Free",
        title: "Pools are open to all",
        text: "Daily open swim at all four neighborhood pools, no pass required, June through Labor Day.",
        imageUrl: "",
        imageAlt: "",
        linkLabel: "",
        linkHref: "",
      },
      {
        size: "small",
        tone: "light",
        kicker: "Get involved",
        title: "Adopt a garden bed",
        text: "Pick a bed, plant natives and keep it weeded. We supply the soil, seedlings and a crew lead.",
        imageUrl: "",
        imageAlt: "",
        linkLabel: "Claim a bed",
        linkHref: "/volunteer/gardens",
      },
      {
        size: "small",
        tone: "light",
        kicker: "Every Friday",
        title: "Movies under the oaks",
        text: "Family films at dusk on the Central Park lawn. Bring a blanket; popcorn is on us.",
        imageUrl: "",
        imageAlt: "",
        linkLabel: "",
        linkHref: "",
      },
      {
        size: "wide",
        tone: "light",
        kicker: "Rentals",
        title: "Host it in a park",
        text: "Picnic shelters, the boathouse and three community rooms can be booked online up to a year ahead.",
        imageUrl: "https://picsum.photos/seed/shelter/900/700",
        imageAlt: "An open-sided timber picnic shelter with long tables beside a meadow",
        linkLabel: "Book a space",
        linkHref: "/rentals",
      },
    ],
  },
  render: ({ eyebrow, heading, headingLevel, intro, tiles }) => {
    const H = headingLevel || "h2";
    const Item = childHeading[H] ?? "h3";
    const list = (tiles ?? []).filter((t) => t?.title || t?.text);
    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="grid grid-cols-1 gap-4 lg:grid-cols-2 lg:items-end lg:gap-16">
              <div>
                {eyebrow ? <p className="text-sm font-semibold tracking-wide text-indigo-700 uppercase">{eyebrow}</p> : null}
                {heading ? (
                  <H className={`${eyebrow ? "mt-3" : ""} text-3xl font-semibold tracking-tight text-balance text-neutral-950 sm:text-4xl`}>{heading}</H>
                ) : null}
              </div>
              {intro ? <p className="text-lg leading-8 text-pretty text-neutral-600">{intro}</p> : null}
            </div>
          ) : null}

          {list.length > 0 ? (
            <ul role="list" className={`${hasHeader ? "mt-12 sm:mt-16" : ""} grid grid-flow-dense grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-6 lg:gap-5`}>
              {list.map((tile, i) => {
                const size: TileSize = sizeClass[tile.size] ? tile.size : "small";
                const tone = toneClass[tile.tone] ?? toneClass.light;
                const sideImage = size === "wide" && Boolean(tile.imageUrl);
                return (
                  <li
                    key={`${tile.title}-${i}`}
                    className={`flex overflow-hidden rounded-3xl ${tone.tile} ${sizeClass[size]} ${sideImage ? "flex-col md:flex-row" : "flex-col"}`}
                  >
                    {tile.imageUrl ? (
                      <img
                        src={tile.imageUrl}
                        alt={tile.imageAlt || ""}
                        className={`w-full bg-neutral-200 object-cover ${
                          sideImage ? "aspect-16/10 md:aspect-auto md:w-1/2 md:shrink-0" : size === "tall" ? "aspect-4/3 sm:aspect-auto sm:min-h-56 sm:flex-1" : "aspect-16/10"
                        }`}
                      />
                    ) : null}
                    <div className={`flex flex-col p-6 sm:p-8 ${tile.imageUrl ? "" : "flex-1"} ${sideImage ? "md:justify-center" : ""}`}>
                      {tile.kicker ? <p className={`text-xs font-semibold tracking-widest uppercase ${tone.kicker}`}>{tile.kicker}</p> : null}
                      {tile.title ? (
                        <Item className={`${tile.kicker ? "mt-2" : ""} text-xl font-semibold tracking-tight text-balance ${tone.title} ${size === "small" && !tile.imageUrl ? "sm:text-2xl" : ""}`}>
                          {tile.title}
                        </Item>
                      ) : null}
                      {tile.text ? <p className={`mt-3 text-base leading-7 text-pretty ${tone.text}`}>{tile.text}</p> : null}
                      {tile.linkLabel ? (
                        <p className="mt-auto pt-4">
                          <a
                            href={tile.linkHref || "#"}
                            className={`group inline-flex min-h-11 items-center gap-1.5 rounded-sm text-sm font-semibold focus-visible:outline-2 focus-visible:outline-offset-2 ${tone.link}`}
                          >
                            {tile.linkLabel}
                            <svg aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" className="size-4 transition group-hover:translate-x-0.5">
                              <path fillRule="evenodd" d="M2 8a.75.75 0 0 1 .75-.75h8.69L8.22 4.03a.75.75 0 0 1 1.06-1.06l4.5 4.5a.75.75 0 0 1 0 1.06l-4.5 4.5a.75.75 0 0 1-1.06-1.06l3.22-3.22H2.75A.75.75 0 0 1 2 8Z" clipRule="evenodd" />
                            </svg>
                          </a>
                        </p>
                      ) : null}
                    </div>
                  </li>
                );
              })}
            </ul>
          ) : null}
        </div>
      </section>
    );
  },
};
```
