# Add the "Bell Schedule" block to this P1 project

Add a Puck component from P1 Blocks (https://p1-blocks.prolificdigital.io/blocks/bell-schedule) to this Pantheon Content Publisher (P1) Next.js project. Period start and end times with a CSS-only switch between regular, early release and late start days, lunches highlighted.

## Steps

1. Create `components/puck/bell-schedule-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 { bellScheduleBlock } from "./components/puck/bell-schedule-block";`
3. Register it under `components` as `BellScheduleBlock: bellScheduleBlock`.
4. Add `"BellScheduleBlock"` 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/bell-schedule-block.tsx`

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

/**
 * Bell Schedule — period start and end times for up to four schedule types (regular, early
 * release, late start…) behind a CSS-only radio switch, with lunch periods called out.
 * Register: `BellScheduleBlock: bellScheduleBlock` in puck.config.tsx.
 */

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

type Schedule = { name: string; days: string; periods: string };

export type BellScheduleProps = {
  heading: string;
  headingLevel: Heading;
  intro: string;
  schedules: Schedule[];
  lunchNote: string;
  note: string;
};

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

// Static class strings so Tailwind can see them; one per possible schedule.
const keys = ["a", "b", "c", "d"] as const;
const panelShow = {
  a: "hidden group-has-[[data-bell=a]:checked]/bell:block",
  b: "hidden group-has-[[data-bell=b]:checked]/bell:block",
  c: "hidden group-has-[[data-bell=c]:checked]/bell:block",
  d: "hidden group-has-[[data-bell=d]:checked]/bell:block",
} as const;

function parsePeriods(raw: string) {
  return (raw || "")
    .split("\n")
    .map((line) => line.trim())
    .filter(Boolean)
    .map((line) => {
      const [name = "", start = "", end = ""] = line.split("|").map((p) => p.trim());
      return { name, start, end, lunch: /lunch/i.test(name) };
    })
    .filter((p) => p.name || p.start);
}

const clock =
  "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";

export const bellScheduleBlock: ComponentConfig<BellScheduleProps> = {
  label: "Bell Schedule",
  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." } },
    schedules: {
      type: "array",
      label: "Schedules",
      min: 1,
      max: 4,
      getItemSummary: (item) => item?.name || "Schedule",
      defaultItemProps: { name: "New schedule", days: "", periods: "Period 1 | 8:00 a.m. | 8:50 a.m." },
      arrayFields: {
        name: { type: "text", label: "Schedule name", metadata: { help: "Like \"Regular day\" or \"Early release\". The first schedule shows first." } },
        days: { type: "text", label: "When it applies", metadata: { help: "Like \"Most Wednesdays\" or \"Two-hour delay days\". Leave blank to hide it." } },
        periods: {
          type: "textarea",
          label: "Periods",
          metadata: {
            help: "One period per line: name | start | end. Example: Period 1 | 7:45 a.m. | 8:40 a.m. Any line with \"lunch\" in its name is highlighted.",
          },
        },
      },
    },
    lunchNote: { type: "textarea", label: "Lunch note", metadata: { help: "Which grades eat when. Leave blank to hide it." } },
    note: { type: "textarea", label: "Footnote", metadata: { help: "Small print under the schedule. Leave blank to hide it." } },
  },
  defaultProps: {
    heading: "Riverbend High School bell schedule",
    headingLevel: "h2",
    intro: "Doors open at 7:15 a.m. and the first bell rings at 7:40. Pick a schedule to see that day's times.",
    schedules: [
      {
        name: "Regular day",
        days: "Monday, Tuesday, Thursday, Friday",
        periods:
          "Period 1 | 7:45 a.m. | 8:40 a.m.\nPeriod 2 | 8:46 a.m. | 9:41 a.m.\nAdvisory | 9:47 a.m. | 10:17 a.m.\nPeriod 3 | 10:23 a.m. | 11:18 a.m.\nLunch A (grades 9–10) | 11:18 a.m. | 11:48 a.m.\nPeriod 4 | 11:54 a.m. | 12:49 p.m.\nLunch B (grades 11–12) | 12:49 p.m. | 1:19 p.m.\nPeriod 5 | 1:25 p.m. | 2:20 p.m.\nPeriod 6 | 2:26 p.m. | 3:05 p.m.",
      },
      {
        name: "Early release",
        days: "Most Wednesdays",
        periods:
          "Period 1 | 7:45 a.m. | 8:25 a.m.\nPeriod 2 | 8:31 a.m. | 9:11 a.m.\nPeriod 3 | 9:17 a.m. | 9:57 a.m.\nPeriod 4 | 10:03 a.m. | 10:43 a.m.\nPeriod 5 | 10:49 a.m. | 11:29 a.m.\nPeriod 6 | 11:35 a.m. | 12:15 p.m.\nGrab-and-go lunch | 12:15 p.m. | 12:35 p.m.",
      },
      {
        name: "Late start",
        days: "Two-hour delay days",
        periods:
          "Period 1 | 9:45 a.m. | 10:22 a.m.\nPeriod 2 | 10:28 a.m. | 11:05 a.m.\nLunch A (grades 9–10) | 11:05 a.m. | 11:35 a.m.\nPeriod 3 | 11:41 a.m. | 12:18 p.m.\nLunch B (grades 11–12) | 12:18 p.m. | 12:48 p.m.\nPeriod 4 | 12:54 p.m. | 1:31 p.m.\nPeriod 5 | 1:37 p.m. | 2:14 p.m.\nPeriod 6 | 2:20 p.m. | 3:05 p.m.",
      },
    ],
    lunchNote: "Grades 9 and 10 eat during Lunch A, grades 11 and 12 during Lunch B. Breakfast is free for every student from 7:15 to 7:40 a.m. in the cafeteria.",
    note: "Buses leave 10 minutes after the last bell. On early release days, after-school programs start at 12:30 p.m.",
  },
  render: ({ id, heading, headingLevel, intro, schedules, lunchNote, note }) => {
    const H = headingLevel || "h2";
    const Sub = lower[H] || "h3";
    const uid = id || "bell-schedule";
    const list = (schedules ?? []).filter((s) => s?.name || s?.periods).slice(0, 4);
    const switchable = list.length > 1;

    return (
      <section aria-labelledby={heading ? `${uid}-heading` : undefined} className="group/bell 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={`${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>
          ) : null}

          {switchable ? (
            <fieldset className={heading || intro ? "mt-10" : ""}>
              <legend className="sr-only">Choose a schedule</legend>
              <div className="flex flex-wrap gap-1 rounded-xl bg-neutral-100 p-1 sm:inline-flex">
                {list.map((s, i) => (
                  <label
                    key={`${s.name}-${i}`}
                    className="relative flex min-h-11 flex-1 cursor-pointer items-center justify-center rounded-lg px-4 text-sm font-semibold text-neutral-700 transition select-none hover:text-neutral-950 has-checked:bg-white has-checked:text-neutral-950 has-checked:shadow-sm has-checked:ring-1 has-checked:ring-neutral-950/5 has-focus-visible:outline-2 has-focus-visible:outline-offset-2 has-focus-visible:outline-indigo-700 sm:flex-none"
                  >
                    <input type="radio" name={`${uid}-schedule`} value={keys[i]} data-bell={keys[i]} defaultChecked={i === 0} className="sr-only" />
                    {s.name || `Schedule ${i + 1}`}
                  </label>
                ))}
              </div>
            </fieldset>
          ) : null}

          {list.map((s, i) => {
            const rows = parsePeriods(s.periods);
            return (
              <div
                key={`${s.name}-${i}`}
                className={`${switchable ? panelShow[keys[i]] : ""} ${switchable ? "mt-6" : heading || intro ? "mt-10" : ""}`}
              >
                <div className="flex flex-col gap-1 sm:flex-row sm:items-baseline sm:justify-between sm:gap-6">
                  <Sub className="text-xl font-semibold tracking-tight text-neutral-950">{s.name || `Schedule ${i + 1}`}</Sub>
                  {s.days ? (
                    <p className="flex items-center gap-1.5 text-sm leading-6 text-neutral-600">
                      <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="size-4 shrink-0 text-neutral-400">
                        <path fillRule="evenodd" d={clock} clipRule="evenodd" />
                      </svg>
                      {s.days}
                    </p>
                  ) : null}
                </div>
                {rows.length ? (
                  <div className="relative mt-4 overflow-x-auto rounded-2xl ring-1 ring-neutral-200">
                    <table className="w-full min-w-72 text-left text-sm">
                      <caption className="sr-only">
                        {s.name || `Schedule ${i + 1}`}
                        {s.days ? `, ${s.days}` : ""}: start and end time for each period
                      </caption>
                      <thead className="bg-neutral-50 text-neutral-700">
                        <tr>
                          <th scope="col" className="px-4 py-3 font-semibold sm:px-6">Period</th>
                          <th scope="col" className="px-4 py-3 font-semibold sm:px-6">Starts</th>
                          <th scope="col" className="px-4 py-3 font-semibold sm:px-6">Ends</th>
                        </tr>
                      </thead>
                      <tbody className="divide-y divide-neutral-200">
                        {rows.map((r, j) => (
                          <tr key={j} className={r.lunch ? "bg-indigo-50/60" : undefined}>
                            <th scope="row" className="px-4 py-3 font-medium text-neutral-950 sm:px-6">
                              <span className="flex flex-wrap items-center gap-2">
                                {r.name}
                                {r.lunch ? (
                                  <span className="rounded-md bg-indigo-100 px-1.5 py-0.5 text-xs font-semibold text-indigo-800">Lunch</span>
                                ) : null}
                              </span>
                            </th>
                            <td className="px-4 py-3 whitespace-nowrap text-neutral-700 tabular-nums sm:px-6">{r.start || "—"}</td>
                            <td className="px-4 py-3 whitespace-nowrap text-neutral-700 tabular-nums sm:px-6">{r.end || "—"}</td>
                          </tr>
                        ))}
                      </tbody>
                    </table>
                  </div>
                ) : null}
              </div>
            );
          })}

          {lunchNote ? (
            <div className="mt-8 flex gap-3 rounded-2xl bg-indigo-50 p-5 ring-1 ring-indigo-100 sm:p-6">
              <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="mt-0.5 size-5 shrink-0 text-indigo-700">
                <path fillRule="evenodd" d={clock} clipRule="evenodd" />
              </svg>
              <div className="min-w-0">
                <p className="text-sm leading-6 font-semibold text-indigo-950">Lunch times</p>
                <p className="mt-1 text-sm leading-6 text-pretty text-indigo-950">{lunchNote}</p>
              </div>
            </div>
          ) : null}
          {note ? <p className="mt-6 text-sm leading-6 text-pretty text-neutral-600">{note}</p> : null}
        </div>
      </section>
    );
  },
};
```
