# Add the "Service Status" block to this P1 project

Add a Puck component from P1 Blocks (https://p1-blocks.prolificdigital.io/blocks/service-status) to this Pantheon Content Publisher (P1) Next.js project. City services status board with last-updated time, affected count, and status as icon plus text.

## Steps

1. Create `components/puck/service-status-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 { serviceStatusBlock } from "./components/puck/service-status-block";`
3. Register it under `components` as `ServiceStatusBlock: serviceStatusBlock`.
4. Add `"ServiceStatusBlock"` 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/service-status-block.tsx`

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

// spec: status-colors

/**
 * Service Status — a city services board (trash, water, transit, facilities) with a summary
 * line counted from the rows. Every status shows an icon and a word, never color alone.
 * Register: `ServiceStatusBlock: serviceStatusBlock` in puck.config.tsx.
 */

type Heading = "h1" | "h2" | "h3" | "h4";
type Status = "normal" | "delayed" | "disrupted" | "closed";

export type ServiceStatusProps = {
  heading: string;
  headingLevel: Heading;
  intro: string;
  lastUpdated: string;
  services: {
    name: string;
    status: Status;
    note: string;
  }[];
  alertsLabel: string;
  alertsHref: string;
};

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

const statuses: Record<Status, { label: string; pill: string; icon: string; rank: number }> = {
  normal: {
    label: "Normal",
    pill: "bg-emerald-50 text-emerald-800 ring-emerald-600/25",
    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",
    rank: 0,
  },
  delayed: {
    label: "Delayed",
    pill: "bg-amber-50 text-amber-900 ring-amber-600/30",
    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",
    rank: 1,
  },
  disrupted: {
    label: "Disrupted",
    pill: "bg-red-50 text-red-800 ring-red-600/25",
    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",
    rank: 2,
  },
  closed: {
    label: "Closed",
    pill: "bg-neutral-900 text-white ring-neutral-900",
    icon: "M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16ZM8.28 7.22a.75.75 0 0 0-1.06 1.06L8.94 10l-1.72 1.72a.75.75 0 1 0 1.06 1.06L10 11.06l1.72 1.72a.75.75 0 1 0 1.06-1.06L11.06 10l1.72-1.72a.75.75 0 0 0-1.06-1.06L10 8.94 8.28 7.22Z",
    rank: 3,
  },
};

const summaryTone = {
  ok: "border-emerald-200 bg-emerald-50 text-emerald-950",
  minor: "border-amber-200 bg-amber-50 text-amber-950",
  major: "border-red-200 bg-red-50 text-red-950",
} as const;

export const serviceStatusBlock: ComponentConfig<ServiceStatusProps> = {
  label: "Service Status",
  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 7, 2026 at 7:15 a.m.\" Change it every time you edit a status." },
    },
    services: {
      type: "array",
      label: "Services",
      min: 1,
      max: 20,
      getItemSummary: (item) => (item?.name ? `${statuses[item.status]?.label ?? "Normal"} · ${item.name}` : "Service"),
      defaultItemProps: { name: "New service", status: "normal", note: "" },
      arrayFields: {
        name: { type: "text", label: "Service", metadata: { help: "Like \"Trash & recycling\" or \"Westside Pool\"." } },
        status: {
          type: "select",
          label: "Status",
          options: [
            { label: "Normal", value: "normal" },
            { label: "Delayed", value: "delayed" },
            { label: "Disrupted", value: "disrupted" },
            { label: "Closed", value: "closed" },
          ],
          metadata: { help: "The summary at the top counts every service that isn't Normal." },
        },
        note: {
          type: "textarea",
          label: "Details",
          metadata: { help: "What's happening and what people should do. Leave blank when service is normal." },
        },
      },
    },
    alertsLabel: { type: "text", label: "Alerts link text", metadata: { help: "Leave blank to hide the link." } },
    alertsHref: { type: "text", label: "Alerts link", metadata: { help: "Your text or email alert sign-up page." } },
  },
  defaultProps: {
    heading: "City services today",
    headingLevel: "h2",
    intro: "Check here before you head out. We update this board as soon as a service changes.",
    lastUpdated: "Updated Oct 7, 2026 at 7:15 a.m.",
    services: [
      { name: "Trash & recycling", status: "delayed", note: "Routes are running about one day behind after Monday's storm. Leave carts at the curb until they're emptied." },
      { name: "Water & sewer", status: "normal", note: "" },
      { name: "Millbrook Transit buses", status: "disrupted", note: "Route 4 is detoured around the Elm Street bridge repair. Use the temporary stop at Elm and 3rd." },
      { name: "City Hall & permit counter", status: "normal", note: "" },
      { name: "Riverside Pool", status: "closed", note: "Closed for the season. Indoor swim moves to the Northside Recreation Center." },
      { name: "Parks & trails", status: "normal", note: "" },
    ],
    alertsLabel: "Get service alerts by text or email",
    alertsHref: "/alerts",
  },
  render: ({ id, heading, headingLevel, intro, lastUpdated, services, alertsLabel, alertsHref }) => {
    const H = headingLevel || "h2";
    const Sub = childHeading[headingLevel] || "h3";
    const list = (services ?? []).filter((s) => s?.name);
    const affected = list.filter((s) => (s.status || "normal") !== "normal");
    const worst = Math.max(0, ...list.map((s) => statuses[s.status]?.rank ?? 0));
    const tone = worst === 0 ? summaryTone.ok : worst === 1 ? summaryTone.minor : summaryTone.major;
    const summary =
      affected.length === 0
        ? "All services are running normally."
        : `${affected.length} of ${list.length} ${list.length === 1 ? "service is" : "services are"} affected.`;
    const summaryIcon = worst === 0 ? statuses.normal.icon : worst === 1 ? statuses.delayed.icon : statuses.disrupted.icon;
    const headingId = `${id || "service-status"}-heading`;
    return (
      <section aria-labelledby={heading ? headingId : 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-4xl">
          {heading || intro ? (
            <div className="max-w-2xl">
              {heading ? (
                <H id={headingId} 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}
          {list.length ? (
            <div className={`overflow-hidden rounded-2xl ring-1 ring-neutral-200 ${heading || intro ? "mt-10" : ""}`}>
              <div className={`flex flex-col gap-1 border-b px-5 py-4 sm:flex-row sm:items-center sm:justify-between sm:gap-6 sm:px-6 ${tone}`}>
                <p className="flex items-center gap-2.5 text-base leading-6 font-semibold">
                  <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="size-5 shrink-0">
                    <path fillRule="evenodd" d={summaryIcon} clipRule="evenodd" />
                  </svg>
                  {summary}
                </p>
                {lastUpdated ? <p className="pl-7.5 text-sm leading-6 opacity-90 sm:pl-0">{lastUpdated}</p> : null}
              </div>
              <ul role="list" className="divide-y divide-neutral-200 bg-white">
                {list.map((service, i) => {
                  const s = statuses[service.status] ?? statuses.normal;
                  return (
                    <li key={`${service.name}-${i}`} className="flex flex-col gap-3 px-5 py-5 sm:flex-row sm:items-start sm:justify-between sm:gap-8 sm:px-6">
                      <div className="min-w-0">
                        <Sub className="text-base leading-7 font-semibold text-neutral-950">{service.name}</Sub>
                        {service.note ? <p className="mt-1 max-w-xl text-sm leading-6 text-pretty text-neutral-600">{service.note}</p> : null}
                      </div>
                      <p className={`inline-flex shrink-0 items-center gap-1.5 self-start rounded-full px-3 py-1 text-sm font-semibold ring-1 ring-inset ${s.pill}`}>
                        <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="size-4 shrink-0">
                          <path fillRule="evenodd" d={s.icon} clipRule="evenodd" />
                        </svg>
                        <span className="sr-only">Status: </span>
                        {s.label}
                      </p>
                    </li>
                  );
                })}
              </ul>
            </div>
          ) : null}
          {alertsLabel ? (
            <p className="mt-6">
              <a
                href={alertsHref || "#"}
                className="group inline-flex min-h-11 items-center gap-2 rounded-lg text-base font-semibold text-indigo-700 hover:text-indigo-900 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-700"
              >
                <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}
                <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="size-5 shrink-0 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>
            </p>
          ) : null}
        </div>
      </section>
    );
  },
};
```
