# Add the "District Calendar" block to this P1 project

Add a Puck component from P1 Blocks (https://p1-blocks.prolificdigital.io/blocks/district-calendar) to this Pantheon Content Publisher (P1) Next.js project. Key school-year dates by month with text type badges for breaks and early release, plus iCal subscribe and PDF links.

## Steps

1. Create `components/puck/district-calendar-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 { districtCalendarBlock } from "./components/puck/district-calendar-block";`
3. Register it under `components` as `DistrictCalendarBlock: districtCalendarBlock`.
4. Add `"DistrictCalendarBlock"` 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/district-calendar-block.tsx`

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

/**
 * District Calendar — the school year's key dates by month (first day, breaks, no-school
 * days, early release, conferences) with text type badges, plus iCal and PDF links.
 * Register: `DistrictCalendarBlock: districtCalendarBlock` in puck.config.tsx.
 */

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

type Month = { month: string; dates: string };

export type DistrictCalendarProps = {
  heading: string;
  headingLevel: Heading;
  intro: string;
  months: Month[];
  subscribeLabel: string;
  subscribeHref: string;
  pdfLabel: string;
  pdfHref: string;
  pdfMeta: string;
  note: string;
};

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

// Badge look by keyword; the badge always shows its own words, so color is never the only cue.
function badgeClass(type: string) {
  const t = type.toLowerCase();
  if (/no school|closed|holiday|break|recess/.test(t)) return "bg-neutral-900 text-white ring-neutral-900";
  if (/first|last|graduation/.test(t)) return "bg-indigo-700 text-white ring-indigo-700";
  if (/early|late|half/.test(t)) return "bg-white text-indigo-800 ring-indigo-300";
  if (/conference|meeting|open house/.test(t)) return "bg-indigo-50 text-indigo-900 ring-indigo-200";
  return "bg-neutral-100 text-neutral-800 ring-neutral-200";
}

function parseDates(raw: string) {
  return (raw || "")
    .split("\n")
    .map((line) => line.trim())
    .filter(Boolean)
    .map((line) => {
      const parts = line.split("|").map((p) => p.trim());
      if (parts.length === 1) return { date: "", event: parts[0], type: "" };
      return { date: parts[0] || "", event: parts[1] || "", type: parts[2] || "" };
    })
    .filter((r) => r.date || r.event);
}

const linkBase =
  "group inline-flex min-h-11 items-center gap-2 rounded-lg px-4 py-2.5 text-sm font-semibold shadow-sm transition focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-700";

export const districtCalendarBlock: ComponentConfig<DistrictCalendarProps> = {
  label: "District Calendar",
  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." } },
    months: {
      type: "array",
      label: "Months",
      min: 1,
      max: 14,
      getItemSummary: (item) => item?.month || "Month",
      defaultItemProps: { month: "New month", dates: "1 | What happens | No school" },
      arrayFields: {
        month: { type: "text", label: "Month", metadata: { help: "Like \"August 2026\"." } },
        dates: {
          type: "textarea",
          label: "Dates",
          metadata: {
            help: "One per line: date | what happens | type. Example: Nov 25–27 | Thanksgiving break | No school. Types with \"no school\", \"break\", \"first\", \"last\", \"early\" or \"conference\" get their own badge style.",
          },
        },
      },
    },
    subscribeLabel: { type: "text", label: "Subscribe link text", metadata: { help: "Leave blank to hide it." } },
    subscribeHref: { type: "text", label: "Subscribe link", metadata: { help: "Your calendar feed. A webcal:// or .ics link opens most calendar apps." } },
    pdfLabel: { type: "text", label: "PDF link text", metadata: { help: "Leave blank to hide it." } },
    pdfHref: { type: "text", label: "PDF link" },
    pdfMeta: { type: "text", label: "PDF details", metadata: { help: "Like \"PDF, 180 KB\". Leave blank to hide it." } },
    note: { type: "textarea", label: "Footnote", metadata: { help: "Leave blank to hide it." } },
  },
  defaultProps: {
    heading: "2026–27 school year calendar",
    headingLevel: "h2",
    intro: "The dates every Riverbend family needs: the first day, breaks, days off and early release. Add them to your phone so you never miss one.",
    months: [
      { month: "August 2026", dates: "Aug 17–18 | Teacher work days | No school\nAug 19 | First day for grades 1–12 | First day\nAug 24 | First day for kindergarten | First day" },
      { month: "September 2026", dates: "Sep 7 | Labor Day | No school\nSep 23 | Early release, all schools | Early release" },
      { month: "October 2026", dates: "Oct 15–16 | Parent-teacher conferences | Conferences\nOct 16 | No school for students | No school\nOct 28 | Early release, all schools | Early release" },
      { month: "November 2026", dates: "Nov 11 | Veterans Day | No school\nNov 25–27 | Thanksgiving break | Break" },
      { month: "December 2026", dates: "Dec 18 | Early release, last day before break | Early release\nDec 21–Jan 1 | Winter break | Break" },
      { month: "January 2027", dates: "Jan 4 | School resumes | Event\nJan 18 | Martin Luther King Jr. Day | No school\nJan 22 | End of first semester | Event" },
      { month: "March 2027", dates: "Mar 11–12 | Parent-teacher conferences | Conferences\nMar 22–26 | Spring break | Break" },
      { month: "May–June 2027", dates: "May 31 | Memorial Day | No school\nJun 4 | Riverbend and Northgate graduations | Graduation\nJun 9 | Last day of school, early release | Last day" },
    ],
    subscribeLabel: "Subscribe (iCal)",
    subscribeHref: "webcal://riverbendusd.example.org/calendar/district.ics",
    pdfLabel: "Download PDF",
    pdfHref: "/calendar/riverbend-2026-27.pdf",
    pdfMeta: "PDF, 180 KB",
    note: "Approved by the Board of Education on March 10, 2026. If we lose days to snow, make-up days come off the end of the year first.",
  },
  render: ({ id, heading, headingLevel, intro, months, subscribeLabel, subscribeHref, pdfLabel, pdfHref, pdfMeta, note }) => {
    const H = headingLevel || "h2";
    const Sub = lower[H] || "h3";
    const uid = id || "district-calendar";
    const list = (months ?? []).filter((m) => m?.month || m?.dates);
    const hasLinks = Boolean(subscribeLabel || pdfLabel);

    return (
      <section aria-labelledby={heading ? `${uid}-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-7xl">
          {heading || intro || hasLinks ? (
            <div className="flex flex-col gap-6 border-b border-neutral-200 pb-10 lg:flex-row lg:items-end lg:justify-between lg:gap-12">
              <div className="max-w-2xl">
                {heading ? (
                  <H id={`${uid}-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>
              {hasLinks ? (
                <div className="flex shrink-0 flex-wrap gap-3">
                  {subscribeLabel ? (
                    <a href={subscribeHref || "#"} className={`${linkBase} bg-indigo-700 text-white hover:bg-indigo-800`}>
                      <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="size-5 shrink-0">
                        <path
                          fillRule="evenodd"
                          d="M5.75 2a.75.75 0 0 1 .75.75V4h7V2.75a.75.75 0 0 1 1.5 0V4h.25A2.75 2.75 0 0 1 18 6.75v8.5A2.75 2.75 0 0 1 15.25 18H4.75A2.75 2.75 0 0 1 2 15.25v-8.5A2.75 2.75 0 0 1 4.75 4H5V2.75A.75.75 0 0 1 5.75 2Zm-1 5.5c-.69 0-1.25.56-1.25 1.25v6.5c0 .69.56 1.25 1.25 1.25h10.5c.69 0 1.25-.56 1.25-1.25v-6.5c0-.69-.56-1.25-1.25-1.25H4.75Z"
                          clipRule="evenodd"
                        />
                      </svg>
                      {subscribeLabel}
                    </a>
                  ) : null}
                  {pdfLabel ? (
                    <a href={pdfHref || "#"} className={`${linkBase} bg-white text-neutral-950 ring-1 ring-neutral-300 ring-inset hover:bg-neutral-50 hover:ring-neutral-400`}>
                      <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="size-5 shrink-0 text-indigo-700 transition motion-safe:group-hover:translate-y-0.5">
                        <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>
                      <span>
                        {pdfLabel}
                        {pdfMeta ? <span className="ml-1.5 font-normal text-neutral-600">({pdfMeta})</span> : null}
                      </span>
                    </a>
                  ) : null}
                </div>
              ) : null}
            </div>
          ) : null}

          {list.length ? (
            <div className={`grid grid-cols-1 gap-x-10 gap-y-10 md:grid-cols-2 lg:grid-cols-3 ${heading || intro || hasLinks ? "mt-10 sm:mt-12" : ""}`}>
              {list.map((m, i) => {
                const rows = parseDates(m.dates);
                return (
                  <article key={`${m.month}-${i}`} className="min-w-0">
                    {m.month ? (
                      <Sub className="text-sm font-semibold tracking-wide text-indigo-700 uppercase">{m.month}</Sub>
                    ) : null}
                    {rows.length ? (
                      <ul role="list" className="mt-3 divide-y divide-neutral-200 border-t border-neutral-900">
                        {rows.map((r, j) => (
                          <li key={j} className="flex gap-4 py-3.5">
                            <p className="w-24 shrink-0 text-sm leading-6 font-semibold text-neutral-950 tabular-nums">{r.date || "TBA"}</p>
                            <div className="flex min-w-0 flex-1 flex-col items-start gap-1.5">
                              <p className="text-sm leading-6 text-pretty text-neutral-700">{r.event}</p>
                              {r.type ? (
                                <p className={`rounded-md px-2 py-0.5 text-xs font-semibold ring-1 ring-inset ${badgeClass(r.type)}`}>
                                  <span className="sr-only">Type: </span>
                                  {r.type}
                                </p>
                              ) : null}
                            </div>
                          </li>
                        ))}
                      </ul>
                    ) : null}
                  </article>
                );
              })}
            </div>
          ) : null}

          {note ? <p className="mt-10 max-w-3xl text-sm leading-6 text-pretty text-neutral-600 sm:mt-12">{note}</p> : null}
        </div>
      </section>
    );
  },
};
```
