# Add the "Library Hours" block to this P1 project

Add a Puck component from P1 Blocks (https://p1-blocks.prolificdigital.io/blocks/library-hours) to this Pantheon Content Publisher (P1) Next.js project. Opening hours for several library locations in one table, with a today note, holiday changes and contact links.

## Steps

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

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

/**
 * Library Hours — opening hours for several library locations in one table (locations by
 * day groups), with a today note, upcoming holiday changes and contact links.
 * Register: `LibraryHoursBlock: libraryHoursBlock` in puck.config.tsx.
 */

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

type Location = {
  name: string;
  detail: string;
  hours1: string;
  hours2: string;
  hours3: string;
  hours4: string;
  href: string;
};

type Exception = { date: string; dateIso: string; note: string };

export type LibraryHoursProps = {
  heading: string;
  headingLevel: Heading;
  intro: string;
  period: string;
  todayNote: string;
  caption: string;
  day1: string;
  day2: string;
  day3: string;
  day4: string;
  locations: Location[];
  exceptionsHeading: string;
  exceptions: Exception[];
  phone: string;
  email: string;
  askLabel: string;
  askHref: string;
};

const childHeading = { h1: "h2", h2: "h3", h3: "h4", h4: "h5" } as const;
const isoPattern = /^\d{4}-\d{2}-\d{2}/;

const hoursHelp = { help: "Such as 7:30 a.m.–midnight, 24 hours or Closed." };

export const libraryHoursBlock: ComponentConfig<LibraryHoursProps> = {
  label: "Library Hours",
  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" },
    period: { type: "text", label: "Period", metadata: { help: "Which dates these hours cover, such as Fall semester 2026. Leave blank to hide it." } },
    todayNote: { type: "text", label: "Today note", metadata: { help: "A one-line notice, such as Today: regular hours, or Main Library closes at 6 p.m. tonight. Leave blank to hide it." } },
    caption: { type: "text", label: "Table caption", metadata: { help: "Names the table for screen reader users and sits above it." } },
    day1: { type: "text", label: "Column 1 days", metadata: { help: "Days the first hours column covers, such as Mon–Thu." } },
    day2: { type: "text", label: "Column 2 days", metadata: { help: "Such as Friday." } },
    day3: { type: "text", label: "Column 3 days", metadata: { help: "Such as Saturday." } },
    day4: { type: "text", label: "Column 4 days", metadata: { help: "Such as Sunday. Leave blank to drop this column." } },
    locations: {
      type: "array",
      label: "Locations",
      min: 1,
      max: 10,
      getItemSummary: (item) => item?.name || "Location",
      defaultItemProps: { name: "New library", detail: "", hours1: "8 a.m.–10 p.m.", hours2: "8 a.m.–6 p.m.", hours3: "10 a.m.–6 p.m.", hours4: "Closed", href: "" },
      arrayFields: {
        name: { type: "text", label: "Location name" },
        detail: { type: "text", label: "Detail", metadata: { help: "Building or a short note, such as 2nd floor, Carver Science Center. Leave blank to hide it." } },
        hours1: { type: "text", label: "Column 1 hours", metadata: hoursHelp },
        hours2: { type: "text", label: "Column 2 hours", metadata: hoursHelp },
        hours3: { type: "text", label: "Column 3 hours", metadata: hoursHelp },
        hours4: { type: "text", label: "Column 4 hours", metadata: hoursHelp },
        href: { type: "text", label: "Location page link", metadata: { help: "Leave blank for no link." } },
      },
    },
    exceptionsHeading: { type: "text", label: "Holiday changes heading", metadata: { help: "Leave blank to use Holiday and break hours." } },
    exceptions: {
      type: "array",
      label: "Holiday and break changes",
      min: 0,
      max: 10,
      getItemSummary: (item) => item?.date || "Date",
      defaultItemProps: { date: "Monday, January 18", dateIso: "2027-01-18", note: "All locations closed" },
      arrayFields: {
        date: { type: "text", label: "Date or range", metadata: { help: "As it should appear, such as Nov 25–29." } },
        dateIso: { type: "text", label: "Start date (YYYY-MM-DD)", metadata: { help: "For calendars and screen readers. Optional." } },
        note: { type: "text", label: "What changes" },
      },
    },
    phone: { type: "text", label: "Phone", metadata: { help: "Leave blank to hide it." } },
    email: { type: "text", label: "Email", metadata: { help: "Leave blank to hide it." } },
    askLabel: { type: "text", label: "Chat link text", metadata: { help: "Such as Ask a librarian. Leave blank to hide it." } },
    askHref: { type: "text", label: "Chat link" },
  },
  defaultProps: {
    heading: "Library hours",
    headingLevel: "h2",
    intro: "Hours for every Northfield library location. The Bellamy Library learning commons stays open around the clock during finals; your Northfield ID gets you in after 10 p.m.",
    period: "Fall semester 2026 · August 24 – December 18",
    todayNote: "Today, all locations are on regular hours.",
    caption: "Library hours by location, fall semester 2026",
    day1: "Mon–Thu",
    day2: "Friday",
    day3: "Saturday",
    day4: "Sunday",
    locations: [
      { name: "Bellamy Library", detail: "Main library and learning commons", hours1: "7:30 a.m.–2 a.m.", hours2: "7:30 a.m.–8 p.m.", hours3: "10 a.m.–8 p.m.", hours4: "Noon–2 a.m.", href: "/libraries/bellamy" },
      { name: "Carver Science Library", detail: "2nd floor, Carver Science Center", hours1: "8 a.m.–11 p.m.", hours2: "8 a.m.–6 p.m.", hours3: "Noon–6 p.m.", hours4: "Noon–11 p.m.", href: "/libraries/science" },
      { name: "Music and Media Library", detail: "Lower level, Ashford Hall", hours1: "9 a.m.–9 p.m.", hours2: "9 a.m.–5 p.m.", hours3: "Closed", hours4: "1 p.m.–9 p.m.", href: "/libraries/music-media" },
      { name: "Special Collections and Archives", detail: "By appointment after 4 p.m.", hours1: "9 a.m.–4 p.m.", hours2: "9 a.m.–4 p.m.", hours3: "Closed", hours4: "Closed", href: "/libraries/special-collections" },
    ],
    exceptionsHeading: "Holiday and break hours",
    exceptions: [
      { date: "Wednesday, November 25", dateIso: "2026-11-25", note: "All locations close at 5 p.m." },
      { date: "November 26–29", dateIso: "2026-11-26", note: "Thanksgiving break: all locations closed" },
      { date: "December 7–17", dateIso: "2026-12-07", note: "Finals: Bellamy Library learning commons open 24 hours" },
    ],
    phone: "(555) 555-0168",
    email: "library@northfield.example.edu",
    askLabel: "Chat with a librarian",
    askHref: "/libraries/ask",
  },
  render: ({
    id,
    heading,
    headingLevel,
    intro,
    period,
    todayNote,
    caption,
    day1,
    day2,
    day3,
    day4,
    locations,
    exceptionsHeading,
    exceptions,
    phone,
    email,
    askLabel,
    askHref,
  }) => {
    const H = headingLevel || "h2";
    const Sub = childHeading[headingLevel] || "h3";
    const list = (locations ?? []).filter((l) => l?.name);
    const changes = (exceptions ?? []).filter((e) => e?.date || e?.note);
    const captionId = `${id || "library-hours"}-caption`;
    const columns = [
      { label: day1 || "Mon–Thu", key: "hours1" as const },
      { label: day2 || "Friday", key: "hours2" as const },
      { label: day3 || "Saturday", key: "hours3" as const },
      ...(day4 ? [{ label: day4, key: "hours4" as const }] : []),
    ];
    const hasContact = Boolean(phone || email || askLabel);
    const contactLink =
      "inline-flex min-h-11 items-center gap-2 rounded-md text-sm font-semibold text-neutral-900 hover:text-indigo-700 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600";

    return (
      <section className="bg-neutral-50 px-4 py-16 sm:px-6 sm:py-20 lg:px-8 lg:py-24">
        <div className="mx-auto max-w-7xl">
          <div className="flex flex-col gap-6 lg:flex-row lg:items-end lg:justify-between lg:gap-16">
            <div className="max-w-2xl">
              {period ? <p className="text-sm font-semibold tracking-wide text-indigo-700 uppercase">{period}</p> : null}
              {heading ? (
                <H className={`text-3xl font-semibold tracking-tight text-balance text-neutral-950 sm:text-4xl ${period ? "mt-3" : ""}`}>{heading}</H>
              ) : null}
              {intro ? <p className="mt-4 text-lg leading-8 text-pretty text-neutral-600">{intro}</p> : null}
            </div>
            {todayNote ? (
              <p className="flex items-start gap-3 self-start rounded-xl bg-white px-4 py-3 text-sm leading-6 font-medium text-neutral-900 shadow-sm ring-1 ring-neutral-200 lg:max-w-sm lg:self-auto">
                <span aria-hidden="true" className="relative mt-1.5 flex size-2.5 shrink-0">
                  <span className="absolute inline-flex size-full rounded-full bg-indigo-400 opacity-75 motion-safe:animate-ping" />
                  <span className="relative inline-flex size-2.5 rounded-full bg-indigo-600" />
                </span>
                {todayNote}
              </p>
            ) : null}
          </div>

          {list.length ? (
            <div
              role="region"
              aria-labelledby={captionId}
              tabIndex={0}
              className="mt-10 relative overflow-x-auto rounded-2xl bg-white shadow-sm ring-1 ring-neutral-200 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600 sm:mt-12"
            >
              <table className="w-full min-w-2xl border-collapse text-left">
                <caption id={captionId} className="sr-only">
                  {caption || "Library hours by location"}
                </caption>
                <thead className="bg-neutral-950 text-white">
                  <tr>
                    <th scope="col" className="px-5 py-3.5 text-sm font-semibold">
                      Location
                    </th>
                    {columns.map((c) => (
                      <th key={c.key} scope="col" className="px-5 py-3.5 text-sm font-semibold whitespace-nowrap">
                        {c.label}
                      </th>
                    ))}
                  </tr>
                </thead>
                <tbody className="divide-y divide-neutral-200">
                  {list.map((loc, i) => (
                    <tr key={`${loc.name}-${i}`} className="align-top even:bg-neutral-50/70">
                      <th scope="row" className="px-5 py-4 text-left font-normal">
                        {loc.href ? (
                          <a
                            href={loc.href}
                            className="rounded-sm text-base font-semibold text-neutral-950 underline decoration-neutral-300 underline-offset-4 hover:text-indigo-700 hover:decoration-indigo-400 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600"
                          >
                            {loc.name}
                          </a>
                        ) : (
                          <span className="text-base font-semibold text-neutral-950">{loc.name}</span>
                        )}
                        {loc.detail ? <span className="mt-0.5 block text-sm leading-6 text-neutral-600">{loc.detail}</span> : null}
                      </th>
                      {columns.map((c) => {
                        const value = (loc[c.key] || "").trim();
                        const closed = /^closed$/i.test(value);
                        return (
                          <td
                            key={c.key}
                            className={`px-5 py-4 text-sm whitespace-nowrap tabular-nums ${closed ? "text-neutral-600 italic" : "text-neutral-900"}`}
                          >
                            {value || "—"}
                          </td>
                        );
                      })}
                    </tr>
                  ))}
                </tbody>
              </table>
            </div>
          ) : null}

          {changes.length || hasContact ? (
            <div className="mt-10 grid grid-cols-1 gap-8 lg:grid-cols-12 lg:gap-12">
              {changes.length ? (
                <div className={hasContact ? "lg:col-span-8" : "lg:col-span-12"}>
                  <Sub className="text-lg font-semibold text-neutral-950">{exceptionsHeading || "Holiday and break hours"}</Sub>
                  <ul role="list" className="mt-4 divide-y divide-neutral-200 border-y border-neutral-200">
                    {changes.map((c, i) => {
                      const iso = isoPattern.test(c.dateIso || "") ? c.dateIso.slice(0, 10) : "";
                      return (
                        <li key={`${c.date}-${i}`} className="flex flex-col gap-1 py-3 sm:flex-row sm:gap-6">
                          <p className="text-sm font-semibold text-neutral-950 sm:w-56 sm:shrink-0">
                            {iso ? <time dateTime={iso}>{c.date || iso}</time> : c.date}
                          </p>
                          {c.note ? <p className="text-sm leading-6 text-pretty text-neutral-700">{c.note}</p> : null}
                        </li>
                      );
                    })}
                  </ul>
                </div>
              ) : null}
              {hasContact ? (
                <div className={`rounded-2xl bg-white p-6 ring-1 ring-neutral-200 ${changes.length ? "lg:col-span-4" : "lg:col-span-12"}`}>
                  <p className="text-sm font-semibold text-neutral-950">Questions?</p>
                  <ul role="list" className="mt-2">
                    {phone ? (
                      <li>
                        <a href={`tel:${phone.replace(/[^0-9+]/g, "")}`} className={contactLink}>
                          <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="size-4 text-indigo-600">
                            <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.513 2.31a1.5 1.5 0 0 1-1.02 1.756l-.97.33a11.04 11.04 0 0 0 6.783 6.783l.33-.97a1.5 1.5 0 0 1 1.756-1.02l2.31.513A1.5 1.5 0 0 1 18 14.352V15.5a1.5 1.5 0 0 1-1.5 1.5H15c-7.18 0-13-5.82-13-13V3.5Z" clipRule="evenodd" />
                          </svg>
                          {phone}
                        </a>
                      </li>
                    ) : null}
                    {email ? (
                      <li>
                        <a href={`mailto:${email}`} className={`${contactLink} max-w-full break-all`}>
                          <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="size-4 shrink-0 text-indigo-600">
                            <path d="M3 4a2 2 0 0 0-2 2v1.161l8.441 4.221a1.25 1.25 0 0 0 1.118 0L19 7.162V6a2 2 0 0 0-2-2H3Z" />
                            <path d="m19 8.839-7.77 3.885a2.75 2.75 0 0 1-2.46 0L1 8.839V14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V8.839Z" />
                          </svg>
                          {email}
                        </a>
                      </li>
                    ) : null}
                  </ul>
                  {askLabel ? (
                    <a
                      href={askHref || "#"}
                      className="mt-4 inline-flex min-h-11 w-full items-center justify-center gap-2 rounded-lg bg-indigo-600 px-5 py-2.5 text-sm font-semibold text-white shadow-sm transition hover:bg-indigo-500 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600"
                    >
                      <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="size-4">
                        <path fillRule="evenodd" d="M10 2c-2.236 0-4.43.18-6.57.524C1.993 2.755 1 4.014 1 5.426v5.148c0 1.413.993 2.67 2.43 2.902 1.168.188 2.352.327 3.55.414.28.02.521.18.642.413l1.713 3.293a.75.75 0 0 0 1.33 0l1.713-3.293a.783.783 0 0 1 .642-.413 41.102 41.102 0 0 0 3.55-.414c1.437-.231 2.43-1.49 2.43-2.902V5.426c0-1.413-.993-2.67-2.43-2.902A41.289 41.289 0 0 0 10 2Z" clipRule="evenodd" />
                      </svg>
                      {askLabel}
                    </a>
                  ) : null}
                </div>
              ) : null}
            </div>
          ) : null}
        </div>
      </section>
    );
  },
};
```
