# Add the "Closings Alert" block to this P1 project

Add a Puck component from P1 Blocks (https://p1-blocks.prolificdigital.io/blocks/closings-alert) to this Pantheon Content Publisher (P1) Next.js project. Today's open, delayed, closed or remote status with icon and words, a message, update time and notes for buses and programs.

## Steps

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

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

// spec: status-colors

/**
 * Closings Alert — today's weather or emergency status for the district (open, delayed,
 * closed, remote learning) with icon + words, a message, and notes for buses and programs.
 * Register: `ClosingsAlertBlock: closingsAlertBlock` in puck.config.tsx.
 */

type Heading = "h1" | "h2" | "h3" | "h4";
type Status = "open" | "delayed" | "closed" | "remote";

type Program = { program: string; detail: string };

export type ClosingsAlertProps = {
  heading: string;
  headingLevel: Heading;
  status: Status;
  statusLabel: string;
  dateLabel: string;
  message: string;
  updated: string;
  programs: Program[];
  alertsLabel: string;
  alertsHref: string;
  contactNote: string;
};

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

const statuses: Record<Status, { label: string; panel: string; badge: string; icon: string }> = {
  open: {
    label: "Open",
    panel: "bg-emerald-50 ring-emerald-600/20",
    badge: "bg-emerald-700 text-white",
    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",
  },
  delayed: {
    label: "Delayed 2 hours",
    panel: "bg-amber-50 ring-amber-600/25",
    badge: "bg-amber-400 text-amber-950",
    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",
  },
  closed: {
    label: "Closed",
    panel: "bg-red-50 ring-red-600/20",
    badge: "bg-red-700 text-white",
    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",
  },
  remote: {
    label: "Remote learning",
    panel: "bg-indigo-50 ring-indigo-600/20",
    badge: "bg-indigo-700 text-white",
    icon: "M2 4.25A2.25 2.25 0 0 1 4.25 2h11.5A2.25 2.25 0 0 1 18 4.25v8.5A2.25 2.25 0 0 1 15.75 15h-3.105a3.501 3.501 0 0 0 1.1 1.677A.75.75 0 0 1 13.26 18H6.74a.75.75 0 0 1-.484-1.323A3.501 3.501 0 0 0 7.355 15H4.25A2.25 2.25 0 0 1 2 12.75v-8.5Zm1.5 0a.75.75 0 0 1 .75-.75h11.5a.75.75 0 0 1 .75.75v7.5a.75.75 0 0 1-.75.75H4.25a.75.75 0 0 1-.75-.75v-7.5Z",
  },
};

export const closingsAlertBlock: ComponentConfig<ClosingsAlertProps> = {
  label: "Closings Alert",
  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." },
    },
    status: {
      type: "radio",
      label: "Today's status",
      options: [
        { label: "Open", value: "open" },
        { label: "Delayed", value: "delayed" },
        { label: "Closed", value: "closed" },
        { label: "Remote learning", value: "remote" },
      ],
      metadata: { help: "Sets the color, icon and default wording. Change it first, then update the message and time." },
    },
    statusLabel: {
      type: "text",
      label: "Status wording",
      metadata: { help: "Overrides the default words, like \"Delayed 90 minutes\". Leave blank to use the default for the status." },
    },
    dateLabel: { type: "text", label: "Date", metadata: { help: "Like \"Thursday, January 14\". Leave blank to hide it." } },
    message: { type: "textarea", label: "Message", metadata: { help: "What families need to do, in a sentence or two." } },
    updated: { type: "text", label: "Last updated", metadata: { help: "Like \"Updated 5:40 a.m.\" Change it every time you edit this block." } },
    programs: {
      type: "array",
      label: "Program notes",
      min: 0,
      max: 10,
      getItemSummary: (item) => item?.program || "Program",
      defaultItemProps: { program: "New program", detail: "" },
      arrayFields: {
        program: { type: "text", label: "Program", metadata: { help: "Like \"Buses\" or \"After-school care\"." } },
        detail: { type: "textarea", label: "What's happening" },
      },
    },
    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, email or app alert sign-up page." } },
    contactNote: { type: "textarea", label: "Contact note", metadata: { help: "Small print, like where else closings are announced. Leave blank to hide it." } },
  },
  defaultProps: {
    heading: "School status today",
    headingLevel: "h2",
    status: "delayed",
    statusLabel: "",
    dateLabel: "Thursday, January 14, 2027",
    message: "Icy roads this morning. All Riverbend schools open two hours late. Doors open at 9:15 a.m. and classes start at 9:45 a.m. Morning preschool is canceled.",
    updated: "Updated 5:40 a.m.",
    programs: [
      { program: "Buses", detail: "Running two hours later than usual. Some routes may skip hilly stops; drivers will pick up at the nearest main road." },
      { program: "Breakfast", detail: "Grab-and-go breakfast in every school lobby when doors open." },
      { program: "Before-school care", detail: "Opens at 9:00 a.m., two hours later than usual." },
      { program: "After-school care and activities", detail: "Running on normal schedules, including practices and rehearsals." },
    ],
    alertsLabel: "Get closing alerts by text or email",
    alertsHref: "/alerts",
    contactNote: "We decide by 5:30 a.m. and share it here first, then by text, email, the Riverbend Schools app, and local TV and radio.",
  },
  render: ({ id, heading, headingLevel, status, statusLabel, dateLabel, message, updated, programs, alertsLabel, alertsHref, contactNote }) => {
    const H = headingLevel || "h2";
    const Sub = lower[H] || "h3";
    const uid = id || "closings-alert";
    const s = statuses[status] ?? statuses.open;
    const label = statusLabel || s.label;
    const list = (programs ?? []).filter((p) => p?.program || p?.detail);

    return (
      <section aria-labelledby={heading ? `${uid}-heading` : `${uid}-status`} 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 ? (
            <H id={`${uid}-heading`} className="text-3xl font-semibold tracking-tight text-balance text-neutral-950 sm:text-4xl">
              {heading}
            </H>
          ) : null}

          <div className={`overflow-hidden rounded-3xl ring-1 ${s.panel} ${heading ? "mt-8" : ""}`}>
            <div className="p-6 sm:p-8">
              <div className="flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between">
                <div className="min-w-0">
                  {dateLabel ? <p className="text-sm font-medium text-neutral-700">{dateLabel}</p> : null}
                  <p id={`${uid}-status`} className="mt-2 flex flex-wrap items-center gap-3">
                    <span className={`inline-flex items-center gap-2 rounded-full py-1.5 pr-4 pl-2.5 text-xl font-semibold tracking-tight sm:text-2xl ${s.badge}`}>
                      <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="size-6 shrink-0 sm:size-7">
                        <path fillRule="evenodd" d={s.icon} clipRule="evenodd" />
                      </svg>
                      <span className="sr-only">Status: </span>
                      {label}
                    </span>
                  </p>
                </div>
                {updated ? <p className="shrink-0 text-sm font-medium text-neutral-700 tabular-nums">{updated}</p> : null}
              </div>
              {message ? <p className="mt-5 max-w-2xl text-lg leading-8 text-pretty text-neutral-950">{message}</p> : null}
            </div>

            {list.length ? (
              <div className="border-t border-neutral-950/10 bg-white/70 px-6 py-6 sm:px-8">
                <Sub className="text-sm font-semibold tracking-wide text-neutral-700 uppercase">Programs and services</Sub>
                <dl className="mt-4 grid grid-cols-1 gap-x-8 gap-y-5 sm:grid-cols-2">
                  {list.map((p, i) => (
                    <div key={`${p.program}-${i}`} className="min-w-0">
                      <dt className="text-base font-semibold text-neutral-950">{p.program}</dt>
                      {p.detail ? <dd className="mt-1 text-sm leading-6 text-pretty text-neutral-700">{p.detail}</dd> : null}
                    </div>
                  ))}
                </dl>
              </div>
            ) : null}
          </div>

          {alertsLabel || contactNote ? (
            <div className="mt-6 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between sm:gap-8">
              {alertsLabel ? (
                <a
                  href={alertsHref || "#"}
                  className="group inline-flex min-h-11 shrink-0 items-center gap-2 self-start rounded-lg bg-neutral-950 px-4 py-2.5 text-sm font-semibold text-white shadow-sm transition hover:bg-neutral-800 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}
                </a>
              ) : null}
              {contactNote ? <p className="text-sm leading-6 text-pretty text-neutral-600 sm:text-right">{contactNote}</p> : null}
            </div>
          ) : null}
        </div>
      </section>
    );
  },
};
```
