# Add the "Field Conditions" block to this P1 project

Add a Puck component from P1 Blocks (https://p1-blocks.prolificdigital.io/blocks/field-conditions) to this Pantheon Content Publisher (P1) Next.js project. Today's status for fields, courts, trails, pools and rinks, with counts by status and a rain-out hotline.

## Steps

1. Create `components/puck/field-conditions-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 { fieldConditionsBlock } from "./components/puck/field-conditions-block";`
3. Register it under `components` as `FieldConditionsBlock: fieldConditionsBlock`.
4. Add `"FieldConditionsBlock"` 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/field-conditions-block.tsx`

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

// spec: status-colors

/**
 * Field Conditions — today's status for athletic fields, courts, trails, pools and rinks, with a
 * count by status, a rain-out hotline and an update-time promise. Status is icon plus word.
 * Register: `FieldConditionsBlock: fieldConditionsBlock` in puck.config.tsx.
 */

type Heading = "h1" | "h2" | "h3" | "h4";
type Status = "open" | "limited" | "wet" | "closed";
type Kind = "field" | "diamond" | "court" | "trail" | "pool" | "rink";

export type FieldConditionsProps = {
  heading: string;
  headingLevel: Heading;
  intro: string;
  lastUpdated: string;
  facilities: {
    name: string;
    kind: Kind;
    status: Status;
    note: string;
    updated: string;
  }[];
  hotlineLabel: string;
  hotlinePhone: string;
  hotlineNote: 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 statuses: Record<Status, { label: string; pill: string; tone: string; icon: string }> = {
  open: {
    label: "Open",
    pill: "bg-emerald-50 text-emerald-800 ring-emerald-600/25",
    tone: "text-emerald-700",
    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",
  },
  limited: {
    label: "Limited",
    pill: "bg-amber-50 text-amber-900 ring-amber-600/30",
    tone: "text-amber-700",
    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",
  },
  wet: {
    label: "Wet grounds",
    pill: "bg-amber-50 text-amber-900 ring-amber-600/30",
    tone: "text-amber-700",
    icon: "M10 2.5c-.3 0-.58.14-.76.38C7.6 5.07 4.75 9.06 4.75 12a5.25 5.25 0 0 0 10.5 0c0-2.94-2.85-6.93-4.49-9.12A.95.95 0 0 0 10 2.5Zm-2.25 9.75a.75.75 0 0 0-1.5 0A3.75 3.75 0 0 0 10 16a.75.75 0 0 0 0-1.5 2.25 2.25 0 0 1-2.25-2.25Z",
  },
  closed: {
    label: "Closed",
    pill: "bg-red-50 text-red-800 ring-red-600/25",
    tone: "text-red-700",
    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",
  },
};

const statusOrder: Status[] = ["open", "limited", "wet", "closed"];

const kinds: Record<Kind, { label: string; path: string }> = {
  field: { label: "Field", path: "M3 5h18v14H3V5Zm9 0v14m0-4.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM3 9h3v6H3m18-6h-3v6h3" },
  diamond: { label: "Ball diamond", path: "M12 4 20 12l-8 8-8-8 8-8Zm0 4.5L15.5 12 12 15.5 8.5 12 12 8.5Z" },
  court: { label: "Court", path: "M4 4h16v16H4V4Zm0 8h16M8 4v16m8-16v16" },
  trail: { label: "Trail", path: "M13 4.5a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3ZM9.5 21l2.5-7 3 3v4M7 12l2-5 4 1 2 4 3 1M12 14l-1.5-4.5" },
  pool: { label: "Pool", path: "M2 18c1.5 0 2.5-1 4-1s2.5 1 4 1 2.5-1 4-1 2.5 1 4 1 2.5-1 4-1M7 15V5a2 2 0 0 1 4 0m2 10V5a2 2 0 0 1 4 0M7 9h6m-6 3h6" },
  rink: { label: "Ice rink", path: "M4 16h13a3 3 0 0 0 3-3v-1h-6l-2-7H6v8l-2 3Zm-1 4h18M8 20v-4m8 4v-4" },
};

const kindOptions = (Object.keys(kinds) as Kind[]).map((value) => ({ label: kinds[value].label, value }));

export const fieldConditionsBlock: ComponentConfig<FieldConditionsProps> = {
  label: "Field Conditions",
  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: "Board last updated",
      metadata: { help: "Free text, like \"Updated Thursday, Oct 8 at 2:40 p.m.\" Change it every time you edit a status." },
    },
    facilities: {
      type: "array",
      label: "Facilities",
      min: 1,
      max: 40,
      getItemSummary: (item) => (item?.name ? `${statuses[item.status]?.label ?? "Open"} · ${item.name}` : "Facility"),
      defaultItemProps: { name: "New facility", kind: "field", status: "open", note: "", updated: "" },
      arrayFields: {
        name: { type: "text", label: "Name", metadata: { help: "Name it the way players and parents do, like \"Lakeside Fields 1–4\"." } },
        kind: { type: "select", label: "Type", options: kindOptions },
        status: {
          type: "select",
          label: "Status",
          options: [
            { label: "Open", value: "open" },
            { label: "Limited", value: "limited" },
            { label: "Wet grounds", value: "wet" },
            { label: "Closed", value: "closed" },
          ],
          metadata: { help: "Limited means some of it is usable. Wet grounds means no play until it dries. The counts at the top add these up." },
        },
        note: { type: "textarea", label: "Note", metadata: { help: "What's affected and when you'll check again. Leave blank when it's simply open." } },
        updated: { type: "text", label: "Updated", metadata: { help: "Like 2:15 p.m. Leave blank to rely on the board time." } },
      },
    },
    hotlineLabel: { type: "text", label: "Rain-out line label", metadata: { help: "Leave the label and phone blank to hide the box." } },
    hotlinePhone: { type: "text", label: "Rain-out line phone", metadata: { help: "Written the way people dial it, like 555-0142." } },
    hotlineNote: { type: "textarea", label: "Rain-out note", metadata: { help: "When you post updates and what happens to cancelled games." } },
    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: "Field and facility conditions",
    headingLevel: "h2",
    intro: "Check before you load the car. Coaches, this board is the official word for park district fields.",
    lastUpdated: "Updated Thursday, Oct 8 at 2:40 p.m.",
    facilities: [
      { name: "Lakeside Soccer Fields 1–4", kind: "field", status: "open", note: "", updated: "2:40 p.m." },
      { name: "Lakeside Soccer Fields 5–6", kind: "field", status: "wet", note: "Standing water near the north goals. We'll check again at 4:30 p.m.", updated: "2:40 p.m." },
      { name: "Miller Park Diamonds A–C", kind: "diamond", status: "limited", note: "Diamond B is closed for infield repair. A and C are open for games and practice.", updated: "1:15 p.m." },
      { name: "Oakmont Tennis & Pickleball Courts", kind: "court", status: "open", note: "", updated: "8:00 a.m." },
      { name: "Heron Marsh Loop", kind: "trail", status: "closed", note: "The boardwalk past the observation deck is flooded. The first 0.8 mi is open.", updated: "7:30 a.m." },
      { name: "Cedar Valley Aquatic Center", kind: "pool", status: "open", note: "Lap lanes only until 5 p.m. during swim team practice.", updated: "6:00 a.m." },
      { name: "Frostline Ice Arena", kind: "rink", status: "open", note: "", updated: "6:00 a.m." },
    ],
    hotlineLabel: "Rain-out line",
    hotlinePhone: "555-0142",
    hotlineNote: "On game days, conditions are updated by 3 p.m. for evening games and by 7 a.m. for weekend games. Your league contacts you about make-up dates.",
    alertsLabel: "Get rain-out alerts by text",
    alertsHref: "/alerts/fields",
  },
  render: ({ id, heading, headingLevel, intro, lastUpdated, facilities, hotlineLabel, hotlinePhone, hotlineNote, alertsLabel, alertsHref }) => {
    const H = headingLevel || "h2";
    const Sub = childHeading[headingLevel] || "h3";
    const baseId = id || "field-conditions";
    const list = (facilities ?? []).filter((f) => f?.name);
    const counts = statusOrder
      .map((s) => ({ status: s, count: list.filter((f) => (statuses[f.status] ? f.status : "open") === s).length }))
      .filter((c) => c.count > 0);
    const hasHotline = Boolean(hotlineLabel || hotlinePhone);
    const tel = (hotlinePhone || "").replace(/[^\d+]/g, "");

    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 grid max-w-7xl grid-cols-1 gap-10 lg:grid-cols-12 lg:gap-12">
          <div className="lg:col-span-4">
            <div className="lg:sticky lg:top-8">
              {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}

              {hasHotline ? (
                <div className={`rounded-2xl bg-neutral-950 p-6 text-white ${heading || intro ? "mt-8" : ""}`}>
                  <p className="flex items-center gap-2 text-sm font-semibold tracking-wide text-indigo-200 uppercase">
                    <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="size-4 shrink-0">
                      <path fillRule="evenodd" d="M2 3.5A1.5 1.5 0 0 1 3.5 2h1.148a1.5 1.5 0 0 1 1.465 1.175l.716 3.223a1.5 1.5 0 0 1-1.052 1.767l-.933.267c-.41.117-.643.555-.48.95a11.542 11.542 0 0 0 6.254 6.254c.395.163.833-.07.95-.48l.267-.933a1.5 1.5 0 0 1 1.767-1.052l3.223.716A1.5 1.5 0 0 1 18 15.352V16.5a1.5 1.5 0 0 1-1.5 1.5H15c-1.149 0-2.263-.15-3.326-.43A13.022 13.022 0 0 1 2.43 8.326 13.019 13.019 0 0 1 2 5V3.5Z" clipRule="evenodd" />
                    </svg>
                    {hotlineLabel || "Rain-out line"}
                  </p>
                  {hotlinePhone ? (
                    <a
                      href={tel ? `tel:${tel}` : undefined}
                      className="mt-2 inline-flex min-h-11 items-center rounded text-3xl font-semibold tracking-tight text-white tabular-nums underline decoration-white/30 underline-offset-6 hover:decoration-white focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-white"
                    >
                      {hotlinePhone}
                    </a>
                  ) : null}
                  {hotlineNote ? <p className="mt-3 text-sm leading-6 text-pretty text-neutral-300">{hotlineNote}</p> : null}
                </div>
              ) : null}

              {alertsLabel ? (
                <p className="mt-5">
                  <a
                    href={alertsHref || "#"}
                    className={`group inline-flex min-h-11 items-center gap-2 rounded text-base font-semibold text-indigo-700 hover:text-indigo-900 ${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}
                    <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>
          </div>

          {list.length ? (
            <div className="min-w-0 lg:col-span-8">
              <div className="flex flex-col gap-3 border-b border-neutral-200 pb-4 sm:flex-row sm:items-end sm:justify-between">
                <ul role="list" aria-label="Today at a glance" className="flex flex-wrap gap-x-5 gap-y-2">
                  {counts.map(({ status, count }) => (
                    <li key={status} className="flex items-center gap-1.5 text-sm text-neutral-700">
                      <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className={`size-4 shrink-0 ${statuses[status].tone}`}>
                        <path fillRule="evenodd" d={statuses[status].icon} clipRule="evenodd" />
                      </svg>
                      <span className="font-semibold text-neutral-950 tabular-nums">{count}</span>
                      {statuses[status].label.toLowerCase()}
                    </li>
                  ))}
                </ul>
                {lastUpdated ? <p className="text-sm text-neutral-600">{lastUpdated}</p> : null}
              </div>

              <ul role="list" className="divide-y divide-neutral-200">
                {list.map((f, i) => {
                  const s = statuses[f.status] ?? statuses.open;
                  const k = kinds[f.kind] ?? kinds.field;
                  return (
                    <li key={`${f.name}-${i}`} className="flex flex-col gap-3 py-5 sm:flex-row sm:items-start sm:justify-between sm:gap-8">
                      <div className="flex min-w-0 gap-4">
                        <span className="flex size-10 shrink-0 items-center justify-center rounded-lg bg-neutral-100 text-neutral-700">
                          <svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={1.6} strokeLinecap="round" strokeLinejoin="round" className="size-5">
                            <path d={k.path} />
                          </svg>
                        </span>
                        <div className="min-w-0">
                          <Sub className="text-base leading-6 font-semibold text-pretty text-neutral-950">{f.name}</Sub>
                          <p className="mt-0.5 text-sm text-neutral-600">
                            <span className="sr-only">Type: </span>
                            {k.label}
                            {f.updated ? (
                              <>
                                <span aria-hidden="true"> · </span>
                                <span className="sr-only">, </span>Updated {f.updated}
                              </>
                            ) : null}
                          </p>
                          {f.note ? <p className="mt-2 max-w-xl text-sm leading-6 text-pretty text-neutral-700">{f.note}</p> : null}
                        </div>
                      </div>
                      <p className={`ml-14 inline-flex shrink-0 items-center gap-1.5 self-start rounded-full px-3 py-1 text-sm font-semibold whitespace-nowrap ring-1 ring-inset sm:ml-0 ${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}
        </div>
      </section>
    );
  },
};
```
