# Add the "Amenity Matrix" block to this P1 project

Add a Puck component from P1 Blocks (https://p1-blocks.prolificdigital.io/blocks/amenity-matrix) to this Pantheon Content Publisher (P1) Next.js project. Find a park by amenity: a parks-by-amenities table with check marks and a sticky park column that scrolls on phones.

## Steps

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

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

/**
 * Amenity Matrix — "find a park by amenity": parks down the side, amenities across the top,
 * a check (with Yes/No text for screen readers) where a park has it. The park column stays put
 * while the table scrolls sideways on phones.
 * Register: `AmenityMatrixBlock: amenityMatrixBlock` in puck.config.tsx.
 */

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

export type AmenityMatrixProps = {
  heading: string;
  headingLevel: Heading;
  intro: string;
  amenities: string;
  parks: { name: string; detail: string; href: string; has: string }[];
  footnote: string;
  linkLabel: string;
  linkHref: string;
};

const focusRing = "focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-700";

const splitList = (value: string | undefined) =>
  (value ?? "")
    .split(",")
    .map((v) => v.trim())
    .filter(Boolean);

const norm = (value: string) => value.toLowerCase().replace(/\s+/g, " ").trim();

export const amenityMatrixBlock: ComponentConfig<AmenityMatrixProps> = {
  label: "Amenity Matrix",
  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", metadata: { help: "Leave blank to hide it." } },
    amenities: {
      type: "textarea",
      label: "Amenity columns",
      metadata: { help: "Separate with commas, like Playground, Restrooms, Dog park. Each becomes a column, in this order." },
    },
    parks: {
      type: "array",
      label: "Parks",
      min: 1,
      max: 60,
      getItemSummary: (item) => item?.name || "Park",
      defaultItemProps: { name: "New park", detail: "", href: "", has: "" },
      arrayFields: {
        name: { type: "text", label: "Park name" },
        detail: { type: "text", label: "Detail", metadata: { help: "A short line under the name, like the neighborhood or acreage. Leave blank to hide it." } },
        href: { type: "text", label: "Park page link", metadata: { help: "Makes the park name a link. Leave blank for plain text." } },
        has: {
          type: "textarea",
          label: "Amenities it has",
          metadata: { help: "Separate with commas, spelled the same as the amenity columns. Capitals don't matter." },
        },
      },
    },
    footnote: { type: "textarea", label: "Footnote", metadata: { help: "Like seasonal notes. Leave blank to hide it." } },
    linkLabel: { type: "text", label: "Link text", metadata: { help: "Like View the parks map. Leave blank to hide it." } },
    linkHref: { type: "text", label: "Link" },
  },
  defaultProps: {
    heading: "Find a park by amenity",
    headingLevel: "h2",
    intro: "Every Cedar Valley park at a glance. Scroll sideways on a phone to see every amenity.",
    amenities: "Playground, Restrooms, Picnic shelter, Trails, Dog park, Splash pad, Sports fields, Fishing, ADA accessible",
    parks: [
      { name: "Willow Creek Park", detail: "North side · 48 acres", href: "/parks/willow-creek", has: "Playground, Restrooms, Picnic shelter, Trails, Splash pad, ADA accessible" },
      { name: "Oak Hollow Park", detail: "West side · 22 acres", href: "/parks/oak-hollow", has: "Playground, Picnic shelter, Trails, Fishing" },
      { name: "Hillcrest Commons", detail: "Downtown · 6 acres", href: "/parks/hillcrest", has: "Playground, Restrooms, Dog park, ADA accessible" },
      { name: "Cedar Run Sports Complex", detail: "East side · 35 acres", href: "/parks/cedar-run", has: "Restrooms, Sports fields, ADA accessible" },
      { name: "Heron Lake Preserve", detail: "South side · 110 acres", href: "/parks/heron-lake", has: "Trails, Fishing, Restrooms" },
      { name: "Maple Street Tot Lot", detail: "Old Town · 1 acre", href: "/parks/maple-street", has: "Playground, ADA accessible" },
    ],
    footnote: "Restrooms and splash pads are open Memorial Day to Labor Day. The Cedar Run restrooms stay open year round.",
    linkLabel: "View the parks map",
    linkHref: "/parks/map",
  },
  render: ({ id, heading, headingLevel, intro, amenities, parks, footnote, linkLabel, linkHref }) => {
    const H = headingLevel || "h2";
    const baseId = id || "amenity-matrix";
    const cols = splitList(amenities);
    const rows = (parks ?? []).filter((p) => p?.name);
    const hasHeader = Boolean(heading || intro);
    const captionId = `${baseId}-caption`;
    return (
      <section aria-labelledby={heading ? `${baseId}-heading` : undefined} 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 || linkLabel ? (
            <div className="flex flex-col gap-4 sm:flex-row sm:items-end sm:justify-between sm:gap-10">
              <div className="max-w-2xl">
                {heading ? (
                  <H id={`${baseId}-heading`} className="text-3xl font-semibold tracking-tight text-balance text-neutral-950 sm:text-4xl">
                    {heading}
                  </H>
                ) : null}
                {intro ? <p className="mt-4 text-lg leading-8 text-pretty text-neutral-600">{intro}</p> : null}
              </div>
              {linkLabel ? (
                <a
                  href={linkHref || "#"}
                  className={`group inline-flex min-h-11 shrink-0 items-center gap-1.5 self-start rounded text-base font-semibold text-indigo-700 hover:text-indigo-900 sm:self-auto ${focusRing}`}
                >
                  {linkLabel}
                  <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="size-5 transition motion-safe: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}

          {cols.length && rows.length ? (
            <div
              role="region"
              aria-labelledby={captionId}
              tabIndex={0}
              className={`relative -mx-4 overflow-x-auto sm:mx-0 sm:rounded-2xl sm:ring-1 sm:ring-neutral-950/10 ${focusRing} focus-visible:-outline-offset-2 ${hasHeader || linkLabel ? "mt-10 sm:mt-12" : ""}`}
            >
              <table className="w-full border-separate border-spacing-0 text-left text-sm">
                <caption id={captionId} className="sr-only">
                  {heading || "Park amenities"}: {rows.length} parks and the amenities each one has
                </caption>
                <thead>
                  <tr>
                    <th
                      scope="col"
                      className="sticky left-0 z-10 min-w-40 border-r border-b border-neutral-200 bg-neutral-50 px-4 py-3 align-bottom text-xs font-semibold tracking-wide text-neutral-700 uppercase sm:min-w-56 sm:px-6"
                    >
                      Park
                    </th>
                    {cols.map((col, c) => (
                      <th key={`${col}-${c}`} scope="col" className="min-w-24 border-b border-neutral-200 bg-neutral-50 px-3 py-3 text-center align-bottom text-xs leading-4 font-semibold text-balance text-neutral-800">
                        {col}
                      </th>
                    ))}
                  </tr>
                </thead>
                <tbody>
                  {rows.map((park, r) => {
                    const has = new Set(splitList(park.has).map(norm));
                    const count = cols.filter((c) => has.has(norm(c))).length;
                    return (
                      <tr key={`${park.name}-${r}`} className="group">
                        <th
                          scope="row"
                          className="sticky left-0 z-10 border-r border-b border-neutral-200 bg-white px-4 py-3.5 align-middle font-normal group-hover:bg-indigo-50 sm:px-6"
                        >
                          <span className="block font-semibold text-neutral-950">
                            {park.href ? (
                              <a href={park.href} className={`rounded underline decoration-neutral-300 underline-offset-4 hover:text-indigo-800 hover:decoration-indigo-700 ${focusRing}`}>
                                {park.name}
                              </a>
                            ) : (
                              park.name
                            )}
                          </span>
                          <span className="mt-0.5 block text-xs leading-5 text-neutral-600">
                            {park.detail ? `${park.detail} · ` : ""}
                            {count} of {cols.length}
                            <span className="sr-only"> amenities</span>
                          </span>
                        </th>
                        {cols.map((col, c) => {
                          const yes = has.has(norm(col));
                          return (
                            <td key={`${col}-${c}`} className={`border-b border-neutral-200 px-3 py-3.5 text-center align-middle ${yes ? "group-hover:bg-indigo-50" : "group-hover:bg-neutral-50"}`}>
                              {yes ? (
                                <span className="inline-grid size-7 place-items-center rounded-full bg-indigo-700 text-white">
                                  <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="size-4">
                                    <path fillRule="evenodd" d="M16.704 4.153a.75.75 0 0 1 .143 1.052l-8 10.5a.75.75 0 0 1-1.127.075l-4.5-4.5a.75.75 0 0 1 1.06-1.06l3.894 3.893 7.48-9.817a.75.75 0 0 1 1.05-.143Z" clipRule="evenodd" />
                                  </svg>
                                  <span className="sr-only">Yes</span>
                                </span>
                              ) : (
                                <span className="inline-grid size-7 place-items-center text-neutral-500">
                                  <span aria-hidden="true" className="h-0.5 w-3 rounded-full bg-current" />
                                  <span className="sr-only">No</span>
                                </span>
                              )}
                            </td>
                          );
                        })}
                      </tr>
                    );
                  })}
                </tbody>
              </table>
            </div>
          ) : null}

          {footnote || (cols.length && rows.length) ? (
            <div className="mt-5 flex flex-col gap-3 text-sm leading-6 text-neutral-600 sm:flex-row sm:items-start sm:justify-between sm:gap-10">
              {footnote ? <p className="max-w-3xl text-pretty">{footnote}</p> : <span />}
              {cols.length && rows.length ? (
                <p aria-hidden="true" className="flex shrink-0 items-center gap-4 text-xs text-neutral-700">
                  <span className="inline-flex items-center gap-1.5">
                    <span className="inline-grid size-5 place-items-center rounded-full bg-indigo-700 text-white">
                      <svg viewBox="0 0 20 20" fill="currentColor" className="size-3">
                        <path fillRule="evenodd" d="M16.704 4.153a.75.75 0 0 1 .143 1.052l-8 10.5a.75.75 0 0 1-1.127.075l-4.5-4.5a.75.75 0 0 1 1.06-1.06l3.894 3.893 7.48-9.817a.75.75 0 0 1 1.05-.143Z" clipRule="evenodd" />
                      </svg>
                    </span>
                    Available
                  </span>
                  <span className="inline-flex items-center gap-1.5">
                    <span className="inline-grid size-5 place-items-center text-neutral-500">
                      <span className="h-0.5 w-3 rounded-full bg-current" />
                    </span>
                    Not available
                  </span>
                </p>
              ) : null}
            </div>
          ) : null}
        </div>
      </section>
    );
  },
};
```
