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

Add a Puck component from P1 Blocks (https://p1-blocks.prolificdigital.io/blocks/storytime-schedule) to this Pantheon Content Publisher (P1) Next.js project. Weekly kids' storytimes grouped by age with jump links, day, time, branch and a plain-text registration note.

## Steps

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

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

/**
 * Storytime Schedule — weekly children's programs grouped by age, with jump links to each
 * age group, day/time, branch and a plain-text registration note on every program.
 * Register: `StorytimeScheduleBlock: storytimeScheduleBlock` in puck.config.tsx.
 */

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

type Program = {
  group: string;
  name: string;
  ages: string;
  day: string;
  time: string;
  branch: string;
  registration: "required" | "dropin";
  description: string;
  href: string;
};

export type StorytimeScheduleProps = {
  eyebrow: string;
  heading: string;
  headingLevel: Heading;
  intro: string;
  jumpLabel: string;
  programs: Program[];
  note: string;
  calendarLabel: string;
  calendarHref: string;
};

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

const slug = (s: string) => s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "") || "group";

export const storytimeScheduleBlock: ComponentConfig<StorytimeScheduleProps> = {
  label: "Storytime Schedule",
  fields: {
    eyebrow: { type: "text", label: "Eyebrow", metadata: { help: "Small line above the heading, such as Fall 2026 season. Leave blank to hide it." } },
    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" },
    jumpLabel: { type: "text", label: "Jump links label", metadata: { help: "Shown before the age group links. Leave blank to use Jump to an age." } },
    programs: {
      type: "array",
      label: "Programs",
      min: 1,
      max: 20,
      getItemSummary: (item) => [item?.name, item?.day].filter(Boolean).join(" · ") || "Program",
      defaultItemProps: { group: "Preschool", name: "New program", ages: "Ages 3–5", day: "Wednesday", time: "10:30–11 a.m.", branch: "Main Library", registration: "dropin", description: "", href: "" },
      arrayFields: {
        group: { type: "text", label: "Age group", metadata: { help: "Programs with the same age group are listed together, in the order the group first appears. Each group gets a jump link." } },
        name: { type: "text", label: "Program name" },
        ages: { type: "text", label: "Age range", metadata: { help: "Such as Birth–18 months or Ages 3–5." } },
        day: { type: "text", label: "Day", metadata: { help: "Such as Tuesdays." } },
        time: { type: "text", label: "Time" },
        branch: { type: "text", label: "Branch and room" },
        registration: {
          type: "radio",
          label: "Registration",
          options: [
            { label: "Required", value: "required" },
            { label: "Drop in", value: "dropin" },
          ],
        },
        description: { type: "textarea", label: "Description", metadata: { help: "One or two sentences. Leave blank to hide it." } },
        href: { type: "text", label: "Details or registration link", metadata: { help: "Leave blank for no link." } },
      },
    },
    note: { type: "textarea", label: "Note", metadata: { help: "Small print, such as cancellations or caregiver rules. Leave blank to hide it." } },
    calendarLabel: { type: "text", label: "Calendar link text", metadata: { help: "Leave blank to hide it." } },
    calendarHref: { type: "text", label: "Calendar link" },
  },
  defaultProps: {
    eyebrow: "Fall 2026 · September 8 – December 12",
    heading: "Storytimes for little readers",
    headingLevel: "h2",
    intro: "Songs, rhymes, stories and play that build early literacy skills, led by Cedar Valley children's librarians. Free, every week, no library card needed.",
    jumpLabel: "Jump to an age",
    programs: [
      { group: "Babies", name: "Baby Rhyme Time", ages: "Birth–18 months with a caregiver", day: "Tuesdays", time: "10–10:30 a.m.", branch: "Main Library, Children's Room", registration: "dropin", description: "Bounces, lap songs and board books, followed by 15 minutes of play and a chance to meet other families.", href: "/kids/baby-rhyme-time" },
      { group: "Babies", name: "Baby Rhyme Time", ages: "Birth–18 months with a caregiver", day: "Thursdays", time: "10–10:30 a.m.", branch: "Hillcrest Branch, Story Room", registration: "required", description: "Same program, smaller room: register to save one of 15 spots.", href: "/kids/baby-rhyme-time-hillcrest" },
      { group: "Toddlers", name: "Toddler Stories", ages: "18 months–3 years", day: "Wednesdays", time: "10–10:30 a.m.", branch: "Riverside Branch, Community Room", registration: "dropin", description: "Short picture books, movement songs and shakers for wiggly listeners.", href: "/kids/toddler-stories" },
      { group: "Preschool", name: "Preschool Storytime", ages: "Ages 3–5", day: "Wednesdays", time: "11–11:45 a.m.", branch: "Main Library, Children's Room", registration: "dropin", description: "Longer stories, a simple craft and early literacy activities that get kids ready for kindergarten.", href: "/kids/preschool-storytime" },
      { group: "All ages", name: "Bilingual Storytime · Cuentos bilingües", ages: "Ages 0–6 and families", day: "Saturdays", time: "10:30–11:15 a.m.", branch: "North Fork Branch", registration: "required", description: "Stories and songs in English and Spanish. Cuentos y canciones en inglés y español.", href: "/kids/bilingual-storytime" },
    ],
    note: "Storytimes are canceled when Cedar Valley schools close for weather. Children under 8 need a caregiver in the room. Groups of six or more, please call ahead at (555) 555-0119.",
    calendarLabel: "See all kids' events",
    calendarHref: "/events?audience=kids",
  },
  render: ({ id, eyebrow, heading, headingLevel, intro, jumpLabel, programs, note, calendarLabel, calendarHref }) => {
    const H = headingLevel || "h2";
    const GroupH = down[H] ?? "h3";
    const ProgramH = down[GroupH] ?? "h4";
    const uid = `p1-storytime-${id || "block"}`;
    const list = (programs ?? []).filter((p) => p?.name);
    const groups: { label: string; anchor: string; items: Program[] }[] = [];
    for (const p of list) {
      const label = (p.group || "").trim() || "Programs";
      let g = groups.find((x) => x.label === label);
      if (!g) {
        g = { label, anchor: `${uid}-${slug(label)}-${groups.length}`, items: [] };
        groups.push(g);
      }
      g.items.push(p);
    }
    const focusRing = "focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600";

    return (
      <section 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-5xl">
          <div className="max-w-2xl">
            {eyebrow ? <p className="text-sm font-semibold tracking-wide text-indigo-700 uppercase">{eyebrow}</p> : null}
            {heading ? (
              <H className={`${eyebrow ? "mt-3" : ""} font-serif 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>

          {groups.length > 1 ? (
            <nav aria-label={jumpLabel || "Jump to an age"} className="mt-8 flex flex-col gap-3 sm:flex-row sm:items-center">
              <p className="text-sm font-semibold text-neutral-700">{jumpLabel || "Jump to an age"}</p>
              <ul role="list" className="flex flex-wrap gap-2">
                {groups.map((g) => (
                  <li key={g.anchor}>
                    <a
                      href={`#${g.anchor}`}
                      className={`inline-flex min-h-11 items-center gap-2 rounded-full bg-white px-4 py-2 text-sm font-medium text-neutral-800 ring-1 ring-neutral-300 transition hover:bg-indigo-50 hover:text-indigo-800 hover:ring-indigo-300 ${focusRing}`}
                    >
                      {g.label}
                      <span className="rounded-full bg-neutral-100 px-1.5 text-xs text-neutral-700 tabular-nums">
                        {g.items.length}
                        <span className="sr-only"> {g.items.length === 1 ? "program" : "programs"}</span>
                      </span>
                    </a>
                  </li>
                ))}
              </ul>
            </nav>
          ) : null}

          <div className="mt-12 space-y-14">
            {groups.map((g) => (
              <div key={g.anchor} id={g.anchor} className="scroll-mt-24">
                <div className="flex items-center gap-4">
                  <GroupH className="font-serif text-2xl font-semibold tracking-tight text-neutral-950">{g.label}</GroupH>
                  <span aria-hidden="true" className="h-px flex-1 bg-neutral-200" />
                </div>
                <ul role="list" className="mt-6 grid grid-cols-1 gap-4 md:grid-cols-2">
                  {g.items.map((p, i) => {
                    const required = p.registration === "required";
                    return (
                      <li key={`${p.name}-${i}`} className="flex flex-col rounded-2xl bg-neutral-50 p-5 ring-1 ring-neutral-200 sm:p-6">
                        <div className="flex flex-wrap items-start justify-between gap-x-4 gap-y-2">
                          <ProgramH className="text-lg font-semibold tracking-tight text-pretty text-neutral-950">{p.name}</ProgramH>
                          <p
                            className={`inline-flex shrink-0 items-center gap-1.5 rounded-full px-2.5 py-1 text-xs font-semibold ${required ? "bg-indigo-600 text-white" : "bg-white text-neutral-800 ring-1 ring-neutral-300"}`}
                          >
                            <svg aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" className="size-3.5">
                              {required ? (
                                <path fillRule="evenodd" d="M4 1.75a.75.75 0 0 1 1.5 0V3h5V1.75a.75.75 0 0 1 1.5 0V3a2 2 0 0 1 2 2v7a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2V1.75ZM4.5 6a1 1 0 0 0-1 1v4.5a1 1 0 0 0 1 1h7a1 1 0 0 0 1-1V7a1 1 0 0 0-1-1h-7Z" clipRule="evenodd" />
                              ) : (
                                <path fillRule="evenodd" d="M8 15A7 7 0 1 0 8 1a7 7 0 0 0 0 14Zm3.844-8.791a.75.75 0 0 0-1.188-.918l-3.7 4.79-1.649-1.833a.75.75 0 1 0-1.114 1.004l2.25 2.5a.75.75 0 0 0 1.15-.043l4.25-5.5Z" clipRule="evenodd" />
                              )}
                            </svg>
                            {required ? "Registration required" : "Drop in, no registration"}
                          </p>
                        </div>
                        {p.ages ? <p className="mt-1 text-sm font-medium text-indigo-700">{p.ages}</p> : null}
                        {p.description ? <p className="mt-3 text-sm leading-6 text-pretty text-neutral-700">{p.description}</p> : null}
                        {p.day || p.time || p.branch ? (
                          <dl className="mt-4 space-y-1.5 text-sm leading-6 text-neutral-700">
                            {p.day || p.time ? (
                              <div className="flex items-start gap-2">
                                <dt>
                                  <span className="sr-only">When</span>
                                  <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="mt-0.5 size-5 text-neutral-500">
                                    <path fillRule="evenodd" d="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" clipRule="evenodd" />
                                  </svg>
                                </dt>
                                <dd className="font-semibold text-neutral-950">{[p.day, p.time].filter(Boolean).join(", ")}</dd>
                              </div>
                            ) : null}
                            {p.branch ? (
                              <div className="flex items-start gap-2">
                                <dt>
                                  <span className="sr-only">Where</span>
                                  <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="mt-0.5 size-5 text-neutral-500">
                                    <path fillRule="evenodd" d="m9.69 18.933.003.001C9.89 19.02 10 19 10 19s.11.02.308-.066l.002-.001.006-.003.018-.008a5.741 5.741 0 0 0 .281-.14c.186-.096.446-.24.757-.433.62-.384 1.445-.966 2.274-1.765C15.302 14.988 17 12.493 17 9A7 7 0 1 0 3 9c0 3.492 1.698 5.988 3.355 7.584a13.731 13.731 0 0 0 2.273 1.765 11.842 11.842 0 0 0 .976.544l.062.029.018.008.006.003ZM10 11.25a2.25 2.25 0 1 0 0-4.5 2.25 2.25 0 0 0 0 4.5Z" clipRule="evenodd" />
                                  </svg>
                                </dt>
                                <dd className="min-w-0">{p.branch}</dd>
                              </div>
                            ) : null}
                          </dl>
                        ) : null}
                        {p.href ? (
                          <a
                            href={p.href}
                            className={`mt-auto inline-flex min-h-11 items-center gap-1.5 self-start rounded pt-3 text-sm font-semibold text-indigo-700 underline decoration-indigo-300 underline-offset-4 hover:decoration-indigo-700 ${focusRing}`}
                          >
                            {required ? "Register" : "Details"}
                            <span className="sr-only">: {p.name}{p.day ? `, ${p.day}` : ""}</span>
                            <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="size-4">
                              <path fillRule="evenodd" d="M8.22 5.22a.75.75 0 0 1 1.06 0l4.25 4.25a.75.75 0 0 1 0 1.06l-4.25 4.25a.75.75 0 0 1-1.06-1.06L11.94 10 8.22 6.28a.75.75 0 0 1 0-1.06Z" clipRule="evenodd" />
                            </svg>
                          </a>
                        ) : null}
                      </li>
                    );
                  })}
                </ul>
              </div>
            ))}
          </div>

          {note || calendarLabel ? (
            <div className="mt-12 flex flex-col gap-4 border-t border-neutral-200 pt-6 sm:flex-row sm:items-start sm:justify-between sm:gap-10">
              {note ? <p className="max-w-2xl text-sm leading-6 text-pretty text-neutral-600">{note}</p> : null}
              {calendarLabel ? (
                <a
                  href={calendarHref || "#"}
                  className={`inline-flex min-h-11 shrink-0 items-center justify-center rounded-xl bg-indigo-600 px-5 py-2.5 text-sm font-semibold text-white shadow-sm transition hover:bg-indigo-500 ${focusRing}`}
                >
                  {calendarLabel}
                </a>
              ) : null}
            </div>
          ) : null}
        </div>
      </section>
    );
  },
};
```
