# Add the "Park Map Legend" block to this P1 project

Add a Puck component from P1 Blocks (https://p1-blocks.prolificdigital.io/blocks/park-map-legend) to this Pantheon Content Publisher (P1) Next.js project. A park map with numbered markers placed by percentage, a matching accessible legend, and a PDF download link.

## Steps

1. Create `components/puck/park-map-legend-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 { parkMapLegendBlock } from "./components/puck/park-map-legend-block";`
3. Register it under `components` as `ParkMapLegendBlock: parkMapLegendBlock`.
4. Add `"ParkMapLegendBlock"` 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/park-map-legend-block.tsx`

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

/**
 * Park Map Legend — a park or site map image with up to 12 numbered markers placed by x/y
 * percentage, and a matching numbered legend. The legend is the accessible source of truth;
 * markers are a pointer shortcut (hidden from assistive tech) that jump to their legend entry.
 * Register: `ParkMapLegendBlock: parkMapLegendBlock` in puck.config.tsx.
 */

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

export type ParkMapLegendProps = {
  heading: string;
  headingLevel: Heading;
  intro: string;
  mapImageUrl: string;
  mapImageAlt: string;
  legendLabel: string;
  markers: { label: string; description: string; x: string; y: string; href: string }[];
  downloadLabel: string;
  downloadHref: string;
  downloadMeta: string;
};

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

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

/** Accepts "42", "42%" or "42.5 %"; returns a 0–100 number, or null if it isn't one. */
const pct = (value: string | undefined) => {
  const n = Number.parseFloat((value ?? "").replace(/[^\d.-]/g, ""));
  return Number.isFinite(n) ? Math.min(100, Math.max(0, n)) : null;
};

export const parkMapLegendBlock: ComponentConfig<ParkMapLegendProps> = {
  label: "Park Map Legend",
  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." } },
    mapImageUrl: { type: "text", label: "Map image URL", metadata: { help: "A flat, top-down map works best. Markers are placed on top of it." } },
    mapImageAlt: {
      type: "text",
      label: "Map description",
      metadata: { help: "A short summary, like Map of Willow Creek Park. The numbered list below the map describes each spot." },
    },
    legendLabel: { type: "text", label: "Legend heading", metadata: { help: "Like Map key. Leave blank to hide the heading." } },
    markers: {
      type: "array",
      label: "Markers",
      min: 1,
      max: 12,
      getItemSummary: (item, i) => `${(i ?? 0) + 1}. ${item?.label || "Marker"}`,
      defaultItemProps: { label: "New spot", description: "", x: "50", y: "50", href: "" },
      arrayFields: {
        label: { type: "text", label: "Name" },
        description: { type: "textarea", label: "Description", metadata: { help: "One short sentence. Leave blank to hide it." } },
        x: { type: "text", label: "Across (%)", metadata: { help: "0 is the left edge of the map, 100 the right edge. Leave blank to list it without a marker." } },
        y: { type: "text", label: "Down (%)", metadata: { help: "0 is the top edge of the map, 100 the bottom edge." } },
        href: { type: "text", label: "Link", metadata: { help: "Makes the name a link, like a shelter's rental page. Leave blank for plain text." } },
      },
    },
    downloadLabel: { type: "text", label: "Download link text", metadata: { help: "Like Download the park map. Leave blank to hide it." } },
    downloadHref: { type: "text", label: "Download link", metadata: { help: "A PDF of the map, ideally an accessible one." } },
    downloadMeta: { type: "text", label: "File details", metadata: { help: "Like PDF, 1.2 MB. Leave blank to hide it." } },
  },
  defaultProps: {
    heading: "Willow Creek Park map",
    headingLevel: "h2",
    intro: "Find the pavilion, restrooms, trailheads and parking before you go. The main entrance is on Willow Creek Road.",
    mapImageUrl: "https://picsum.photos/seed/parkmap/1200/800",
    mapImageAlt: "Map of Willow Creek Park",
    legendLabel: "Map key",
    markers: [
      { label: "Main entrance and parking", description: "120 spaces, including 8 accessible spaces by the path.", x: "12", y: "78", href: "" },
      { label: "Willow Creek Pavilion", description: "Reservable shelter for up to 120 people.", x: "34", y: "56", href: "/rentals/willow-creek-pavilion" },
      { label: "Restrooms", description: "Accessible. Open April to October.", x: "41", y: "68", href: "" },
      { label: "Adventure playground", description: "Ages 2–12, with a rubber surface and shade sails.", x: "52", y: "44", href: "" },
      { label: "Splash pad", description: "Open Memorial Day to Labor Day, 10 a.m. to 8 p.m.", x: "58", y: "62", href: "" },
      { label: "Creek trailhead", description: "1.8-mile paved loop along Willow Creek.", x: "70", y: "30", href: "/trails/willow-creek-loop" },
      { label: "Fishing pier", description: "Accessible pier. State license required for ages 16 and up.", x: "82", y: "48", href: "" },
      { label: "Overflow parking", description: "Used for events and weekend tournaments.", x: "88", y: "82", href: "" },
    ],
    downloadLabel: "Download the park map",
    downloadHref: "/maps/willow-creek-park.pdf",
    downloadMeta: "PDF, 1.2 MB",
  },
  render: ({ id, heading, headingLevel, intro, mapImageUrl, mapImageAlt, legendLabel, markers, downloadLabel, downloadHref, downloadMeta }) => {
    const H = headingLevel || "h2";
    const Sub = childHeading[headingLevel] || "h3";
    const baseId = id || "park-map-legend";
    const list = (markers ?? [])
      .filter((m) => m?.label)
      .slice(0, 12)
      .map((m, i) => ({ ...m, n: i + 1, px: pct(m.x), py: pct(m.y), anchor: `${baseId}-spot-${i + 1}` }));
    const placed = list.filter((m) => m.px !== null && m.py !== null);
    const hasHeader = Boolean(heading || intro);
    const hasMap = Boolean(mapImageUrl);
    return (
      <section aria-labelledby={heading ? `${baseId}-heading` : undefined} className="bg-neutral-50 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">
              {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>
          ) : null}

          {hasMap || list.length ? (
            <div className={`grid grid-cols-1 gap-8 lg:grid-cols-5 lg:gap-10 ${hasHeader ? "mt-10 sm:mt-12" : ""}`}>
              {hasMap ? (
                <figure className={list.length ? "lg:col-span-3" : "lg:col-span-5"}>
                  <div className="relative overflow-hidden rounded-2xl bg-neutral-200 shadow-sm ring-1 ring-neutral-950/10">
                    <img src={mapImageUrl} alt={mapImageAlt || "Park map"} className="block h-auto w-full" />
                    {placed.map((m) => (
                      <a
                        key={m.anchor}
                        href={m.href || `#${m.anchor}`}
                        aria-hidden="true"
                        tabIndex={-1}
                        title={m.label}
                        style={{ left: `${m.px}%`, top: `${m.py}%` }}
                        className="absolute grid size-7 -translate-x-1/2 -translate-y-1/2 place-items-center rounded-full bg-indigo-700 text-xs font-bold text-white shadow-md ring-2 ring-white transition tabular-nums hover:bg-indigo-900 motion-safe:hover:scale-110 sm:size-8 sm:text-sm"
                      >
                        {m.n}
                      </a>
                    ))}
                  </div>
                  {downloadLabel && downloadHref ? (
                    <figcaption className="mt-4">
                      <a
                        href={downloadHref}
                        download
                        className={`inline-flex min-h-11 items-center gap-2 rounded-lg bg-white px-4 py-2.5 text-sm font-semibold text-neutral-950 shadow-sm ring-1 ring-neutral-300 transition ring-inset hover:bg-neutral-50 ${focusRing}`}
                      >
                        <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="size-5 shrink-0 text-indigo-700">
                          <path d="M10.75 2.75a.75.75 0 0 0-1.5 0v8.614L6.295 8.235a.75.75 0 1 0-1.09 1.03l4.25 4.5a.75.75 0 0 0 1.09 0l4.25-4.5a.75.75 0 0 0-1.09-1.03l-2.955 3.129V2.75Z" />
                          <path d="M3.5 12.75a.75.75 0 0 0-1.5 0v2.5A2.75 2.75 0 0 0 4.75 18h10.5A2.75 2.75 0 0 0 18 15.25v-2.5a.75.75 0 0 0-1.5 0v2.5c0 .69-.56 1.25-1.25 1.25H4.75c-.69 0-1.25-.56-1.25-1.25v-2.5Z" />
                        </svg>
                        {downloadLabel}
                        {downloadMeta ? <span className="font-normal text-neutral-600">({downloadMeta})</span> : null}
                      </a>
                    </figcaption>
                  ) : null}
                </figure>
              ) : null}

              {list.length ? (
                <div className={hasMap ? "lg:col-span-2" : "lg:col-span-5"}>
                  {legendLabel ? (
                    <Sub id={`${baseId}-legend`} className="text-sm font-semibold tracking-wide text-neutral-700 uppercase">
                      {legendLabel}
                    </Sub>
                  ) : null}
                  <ol
                    role="list"
                    aria-labelledby={legendLabel ? `${baseId}-legend` : undefined}
                    aria-label={legendLabel ? undefined : "Map key"}
                    className={`divide-y divide-neutral-200 rounded-2xl bg-white ring-1 ring-neutral-950/5 ${legendLabel ? "mt-4" : ""}`}
                  >
                    {list.map((m) => (
                      <li key={m.anchor} id={m.anchor} className="flex scroll-mt-24 gap-3.5 px-4 py-3.5 first:rounded-t-2xl last:rounded-b-2xl target:bg-indigo-50 sm:px-5">
                        <span
                          aria-hidden="true"
                          className="mt-0.5 grid size-7 shrink-0 place-items-center rounded-full bg-indigo-700 text-xs font-bold text-white tabular-nums ring-2 ring-indigo-100"
                        >
                          {m.n}
                        </span>
                        <div className="min-w-0 flex-1">
                          <p className="text-sm leading-6 font-semibold text-neutral-950">
                            <span className="sr-only">{m.n}. </span>
                            {m.href ? (
                              <a href={m.href} className={`rounded text-indigo-700 underline decoration-indigo-300 underline-offset-4 hover:decoration-indigo-700 ${focusRing}`}>
                                {m.label}
                              </a>
                            ) : (
                              m.label
                            )}
                          </p>
                          {m.description ? <p className="mt-0.5 text-sm leading-6 text-pretty text-neutral-600">{m.description}</p> : null}
                        </div>
                      </li>
                    ))}
                  </ol>
                  {!hasMap && downloadLabel && downloadHref ? (
                    <a
                      href={downloadHref}
                      download
                      className={`mt-4 inline-flex min-h-11 items-center gap-2 rounded text-sm font-semibold text-indigo-700 underline decoration-indigo-300 underline-offset-4 hover:decoration-indigo-700 ${focusRing}`}
                    >
                      {downloadLabel}
                      {downloadMeta ? <span className="font-normal text-neutral-600">({downloadMeta})</span> : null}
                    </a>
                  ) : null}
                </div>
              ) : null}
            </div>
          ) : null}
        </div>
      </section>
    );
  },
};
```
