# Add the "Road Closures" block to this P1 project

Add a Puck component from P1 Blocks (https://p1-blocks.prolificdigital.io/blocks/road-closures) to this Pantheon Content Publisher (P1) Next.js project. Current road closures and detours with cross streets, dates, reason and a labeled severity.

## Steps

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

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

// spec: status-colors

/**
 * Road Closures — current closures and detours: street, the cross streets it's closed between,
 * dates, reason and the detour to take. Severity always shows an icon and a word, never color alone.
 * Register: `RoadClosuresBlock: roadClosuresBlock` in puck.config.tsx.
 */

type Heading = "h1" | "h2" | "h3" | "h4";
type Severity = "closed" | "lanes" | "delays" | "reopened";

export type RoadClosuresProps = {
  heading: string;
  headingLevel: Heading;
  intro: string;
  lastUpdated: string;
  closures: {
    street: string;
    between: string;
    dates: string;
    reason: string;
    detour: string;
    severity: Severity;
  }[];
  mapLabel: string;
  mapHref: string;
  alertsLabel: string;
  alertsHref: 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";

const severities: Record<Severity, { label: string; plural: string; pill: string; rail: string; icon: string }> = {
  closed: {
    label: "Road closed",
    plural: "closed",
    pill: "bg-red-50 text-red-800 ring-red-600/25",
    rail: "border-red-600",
    icon: "M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16ZM6.75 9.25a.75.75 0 0 0 0 1.5h6.5a.75.75 0 0 0 0-1.5h-6.5Z",
  },
  lanes: {
    label: "Lanes closed",
    plural: "with lane closures",
    pill: "bg-amber-50 text-amber-900 ring-amber-600/30",
    rail: "border-amber-500",
    icon: "M8.485 2.495c.673-1.167 2.357-1.167 3.03 0l6.28 10.875c.673 1.167-.17 2.625-1.516 2.625H3.72c-1.347 0-2.189-1.458-1.515-2.625L8.485 2.495ZM10 5a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 10 5Zm0 9a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z",
  },
  delays: {
    label: "Expect delays",
    plural: "with delays",
    pill: "bg-neutral-100 text-neutral-800 ring-neutral-500/25",
    rail: "border-neutral-400",
    icon: "M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16Zm.75-13a.75.75 0 0 0-1.5 0v5c0 .414.336.75.75.75h4a.75.75 0 0 0 0-1.5h-3.25V5Z",
  },
  reopened: {
    label: "Reopened",
    plural: "reopened",
    pill: "bg-emerald-50 text-emerald-800 ring-emerald-600/25",
    rail: "border-emerald-600",
    icon: "M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16Zm3.857-9.809a.75.75 0 0 0-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 1 0-1.06 1.061l2.5 2.5a.75.75 0 0 0 1.137-.089l4-5.5Z",
  },
};

const order: Severity[] = ["closed", "lanes", "delays", "reopened"];

export const roadClosuresBlock: ComponentConfig<RoadClosuresProps> = {
  label: "Road Closures",
  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." } },
    lastUpdated: { type: "text", label: "Last updated", metadata: { help: "Free text, like \"Updated Oct 8, 2026 at 6:30 a.m.\" Change it every time you edit a closure." } },
    closures: {
      type: "array",
      label: "Closures",
      min: 1,
      max: 30,
      getItemSummary: (item) => (item?.street ? `${severities[item.severity]?.label ?? "Road closed"} · ${item.street}` : "Closure"),
      defaultItemProps: { street: "New closure", between: "", dates: "", reason: "", detour: "", severity: "closed" },
      arrayFields: {
        street: { type: "text", label: "Street", metadata: { help: "Like Elm Street." } },
        between: { type: "text", label: "Between", metadata: { help: "The cross streets, like 3rd Avenue and 5th Avenue." } },
        dates: { type: "text", label: "Dates", metadata: { help: "Like Oct 6 to Nov 20, 2026, or Nightly 8 p.m. to 5 a.m. through Oct 30." } },
        reason: { type: "text", label: "Reason", metadata: { help: "Like Water main replacement." } },
        detour: { type: "textarea", label: "Detour", metadata: { help: "The route to take instead, in plain directions. Leave blank to hide it." } },
        severity: {
          type: "select",
          label: "Severity",
          options: [
            { label: "Road closed", value: "closed" },
            { label: "Lanes closed", value: "lanes" },
            { label: "Expect delays", value: "delays" },
            { label: "Reopened", value: "reopened" },
          ],
          metadata: { help: "The summary at the top counts closures by severity. Remove Reopened items after a few days." },
        },
      },
    },
    mapLabel: { type: "text", label: "Map link text", metadata: { help: "Leave blank to hide the link." } },
    mapHref: { type: "text", label: "Map link" },
    alertsLabel: { type: "text", label: "Alerts link text", metadata: { help: "Leave blank to hide the link." } },
    alertsHref: { type: "text", label: "Alerts link" },
  },
  defaultProps: {
    heading: "Road closures and detours",
    headingLevel: "h2",
    intro: "Planned work on Millbrook streets this month. Emergency closures are added as soon as crews are on site.",
    lastUpdated: "Updated Oct 8, 2026 at 6:30 a.m.",
    closures: [
      {
        street: "Elm Street bridge",
        between: "2nd Avenue and 4th Avenue",
        dates: "Oct 6 to Nov 20, 2026",
        reason: "Bridge deck repair",
        detour: "Use Oak Street to cross the river. Trucks over 10 tons follow the signed route on River Road.",
        severity: "closed",
      },
      {
        street: "Hillcrest Avenue",
        between: "Fairview Drive and Summit Lane",
        dates: "Weekdays 9 a.m. to 3 p.m., through Oct 24",
        reason: "Water main replacement",
        detour: "One lane open in each direction. Flaggers on site; allow 10 extra minutes.",
        severity: "lanes",
      },
      {
        street: "Market Square loop",
        between: "Main Street and Church Street",
        dates: "Saturday, Oct 17, 6 a.m. to 6 p.m.",
        reason: "Harvest Festival",
        detour: "Follow signs to Main Street. Festival parking is in the Center Street garage.",
        severity: "closed",
      },
      {
        street: "Cedar Run Drive",
        between: "Westgate Road and the Sports Complex",
        dates: "Oct 12 to Oct 16",
        reason: "Repaving",
        detour: "",
        severity: "delays",
      },
      {
        street: "Canal Street",
        between: "Mill Road and Water Street",
        dates: "Reopened Oct 5",
        reason: "Sewer repair complete",
        detour: "",
        severity: "reopened",
      },
    ],
    mapLabel: "View the closures map",
    mapHref: "/streets/closures-map",
    alertsLabel: "Get closure alerts by text",
    alertsHref: "/alerts",
  },
  render: ({ id, heading, headingLevel, intro, lastUpdated, closures, mapLabel, mapHref, alertsLabel, alertsHref }) => {
    const H = headingLevel || "h2";
    const Sub = childHeading[headingLevel] || "h3";
    const baseId = id || "road-closures";
    const list = (closures ?? []).filter((c) => c?.street);
    const counts = order
      .map((key) => ({ key, n: list.filter((c) => (c.severity || "closed") === key).length }))
      .filter((c) => c.n > 0);
    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-5xl">
          {heading || intro ? (
            <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}

          {counts.length || lastUpdated ? (
            <div className={`flex flex-col gap-3 border-y border-neutral-200 py-4 sm:flex-row sm:items-center sm:justify-between ${heading || intro ? "mt-10" : ""}`}>
              {counts.length ? (
                <ul role="list" aria-label="Summary" className="flex flex-wrap gap-x-5 gap-y-2 text-sm">
                  {counts.map(({ key, n }) => (
                    <li key={key} className="inline-flex items-center gap-2 text-neutral-700">
                      <span className={`grid size-6 place-items-center rounded-full text-xs font-bold tabular-nums ring-1 ring-inset ${severities[key].pill}`}>{n}</span>
                      {n === 1 ? "street" : "streets"} {severities[key].plural}
                    </li>
                  ))}
                </ul>
              ) : null}
              {lastUpdated ? <p className="text-sm text-neutral-600">{lastUpdated}</p> : null}
            </div>
          ) : null}

          {list.length ? (
            <ul role="list" className="mt-6 space-y-4">
              {list.map((c, i) => {
                const s = severities[c.severity] ?? severities.closed;
                const done = c.severity === "reopened";
                return (
                  <li key={`${c.street}-${i}`} className={`rounded-r-2xl border-l-4 bg-neutral-50 ring-1 ring-neutral-200 ${s.rail}`}>
                    <div className="grid grid-cols-1 gap-5 p-5 sm:p-6 md:grid-cols-5 md:gap-8">
                      <div className="min-w-0 md:col-span-3">
                        <p className={`inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-xs font-semibold ring-1 ring-inset ${s.pill}`}>
                          <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="size-3.5 shrink-0">
                            <path fillRule="evenodd" d={s.icon} clipRule="evenodd" />
                          </svg>
                          <span className="sr-only">Status: </span>
                          {s.label}
                        </p>
                        <Sub className={`mt-3 text-xl font-semibold tracking-tight ${done ? "text-neutral-700" : "text-neutral-950"}`}>{c.street}</Sub>
                        {c.between ? (
                          <p className="mt-1 text-sm leading-6 text-neutral-700">
                            <span className="font-medium text-neutral-600">Between </span>
                            {c.between}
                          </p>
                        ) : null}
                        {c.dates || c.reason ? (
                          <dl className="mt-4 grid grid-cols-1 gap-x-6 gap-y-2 text-sm leading-6 sm:grid-cols-2">
                            {c.dates ? (
                              <div>
                                <dt className="font-semibold text-neutral-950">When</dt>
                                <dd className="text-neutral-700">{c.dates}</dd>
                              </div>
                            ) : null}
                            {c.reason ? (
                              <div>
                                <dt className="font-semibold text-neutral-950">Why</dt>
                                <dd className="text-neutral-700">{c.reason}</dd>
                              </div>
                            ) : null}
                          </dl>
                        ) : null}
                      </div>
                      {c.detour ? (
                        <div className="rounded-xl bg-white p-4 ring-1 ring-neutral-200 md:col-span-2">
                          <p className="flex items-center gap-2 text-sm font-semibold text-indigo-800">
                            <svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={1.75} strokeLinecap="round" strokeLinejoin="round" className="size-5 shrink-0">
                              <path d="M6 21V9a4 4 0 0 1 4-4h9m0 0-3.5-3.5M19 5l-3.5 3.5" />
                            </svg>
                            Detour
                          </p>
                          <p className="mt-2 text-sm leading-6 text-pretty text-neutral-700">{c.detour}</p>
                        </div>
                      ) : null}
                    </div>
                  </li>
                );
              })}
            </ul>
          ) : null}

          {mapLabel || alertsLabel ? (
            <div className="mt-8 flex flex-col gap-2 sm:flex-row sm:flex-wrap sm:gap-x-8">
              {mapLabel ? (
                <a href={mapHref || "#"} className={`inline-flex min-h-11 items-center gap-2 rounded text-base font-semibold text-indigo-700 underline decoration-indigo-300 underline-offset-4 hover:decoration-indigo-700 ${focusRing}`}>
                  <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="size-5 shrink-0">
                    <path fillRule="evenodd" d="M8.157 2.176a1.5 1.5 0 0 0-1.147 0l-4.084 1.69A1.5 1.5 0 0 0 2 5.25v10.877a1.5 1.5 0 0 0 2.074 1.386l3.51-1.452 4.26 1.762a1.5 1.5 0 0 0 1.146 0l4.083-1.69A1.5 1.5 0 0 0 18 14.75V3.872a1.5 1.5 0 0 0-2.073-1.386l-3.51 1.452-4.26-1.762ZM7.58 5a.75.75 0 0 1 .75.75v6.5a.75.75 0 0 1-1.5 0v-6.5A.75.75 0 0 1 7.58 5Zm5.59 2.75a.75.75 0 0 0-1.5 0v6.5a.75.75 0 0 0 1.5 0v-6.5Z" clipRule="evenodd" />
                  </svg>
                  {mapLabel}
                </a>
              ) : null}
              {alertsLabel ? (
                <a href={alertsHref || "#"} className={`inline-flex min-h-11 items-center gap-2 rounded text-base font-semibold text-indigo-700 underline decoration-indigo-300 underline-offset-4 hover:decoration-indigo-700 ${focusRing}`}>
                  <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="size-5 shrink-0">
                    <path fillRule="evenodd" d="M10 2a6 6 0 0 0-6 6c0 1.887-.454 3.665-1.257 5.234a.75.75 0 0 0 .515 1.076 32.91 32.91 0 0 0 3.256.508 3.5 3.5 0 0 0 6.972 0 32.903 32.903 0 0 0 3.256-.508.75.75 0 0 0 .515-1.076A11.448 11.448 0 0 1 16 8a6 6 0 0 0-6-6ZM8.05 14.943a33.54 33.54 0 0 0 3.9 0 2 2 0 0 1-3.9 0Z" clipRule="evenodd" />
                  </svg>
                  {alertsLabel}
                </a>
              ) : null}
            </div>
          ) : null}
        </div>
      </section>
    );
  },
};
```
