# Add the "Course Catalog" block to this P1 project

Add a Puck component from P1 Blocks (https://p1-blocks.prolificdigital.io/blocks/course-catalog) to this Pantheon Content Publisher (P1) Next.js project. Course listings with code, credits, terms offered and prerequisites, with each full description in an expandable panel.

## Steps

1. Create `components/puck/course-catalog-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 { courseCatalogBlock } from "./components/puck/course-catalog-block";`
3. Register it under `components` as `CourseCatalogBlock: courseCatalogBlock`.
4. Add `"CourseCatalogBlock"` 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/course-catalog-block.tsx`

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

/**
 * Course Catalog — a department's course listings with code, title, credits, terms offered
 * and prerequisites up front, and the full description tucked into a native <details>.
 * Register: `CourseCatalogBlock: courseCatalogBlock` in puck.config.tsx.
 */

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

type Course = {
  code: string;
  title: string;
  credits: string;
  terms: string;
  prerequisites: string;
  description: string;
  href: string;
};

export type CourseCatalogProps = {
  eyebrow: string;
  heading: string;
  headingLevel: Heading;
  intro: string;
  courses: Course[];
  footnote: string;
  catalogLabel: string;
  catalogHref: string;
};

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

const splitList = (value: string | undefined) =>
  (value || "")
    .split(/[,\n]/)
    .map((s) => s.trim())
    .filter(Boolean);

export const courseCatalogBlock: ComponentConfig<CourseCatalogProps> = {
  label: "Course Catalog",
  fields: {
    eyebrow: { type: "text", label: "Eyebrow", metadata: { help: "Small line above the heading, such as the department. 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" },
    courses: {
      type: "array",
      label: "Courses",
      min: 1,
      max: 40,
      getItemSummary: (item) => [item?.code, item?.title].filter(Boolean).join(" · ") || "Course",
      defaultItemProps: {
        code: "DEPT 100",
        title: "New course",
        credits: "3",
        terms: "Fall, Spring",
        prerequisites: "",
        description: "",
        href: "",
      },
      arrayFields: {
        code: { type: "text", label: "Course code", metadata: { help: "Subject and number, such as ENVS 210." } },
        title: { type: "text", label: "Title" },
        credits: { type: "text", label: "Credits", metadata: { help: "A number or range, such as 3 or 1–4." } },
        terms: { type: "text", label: "Terms offered", metadata: { help: "Separate with commas, such as Fall, Spring, Summer." } },
        prerequisites: { type: "text", label: "Prerequisites", metadata: { help: "Leave blank if there are none; the card will say so." } },
        description: { type: "textarea", label: "Description", metadata: { help: "Shown when a reader opens the course. Leave blank to hide the toggle." } },
        href: { type: "text", label: "Course page link", metadata: { help: "Optional link to the full catalog entry or section list." } },
      },
    },
    footnote: { type: "textarea", label: "Footnote", metadata: { help: "Small print under the list. Leave blank to hide it." } },
    catalogLabel: { type: "text", label: "Full catalog link text", metadata: { help: "Leave blank to hide it." } },
    catalogHref: { type: "text", label: "Full catalog link" },
  },
  defaultProps: {
    eyebrow: "Department of Environmental Science",
    heading: "Courses for 2026–27",
    headingLevel: "h2",
    intro: "Core and elective courses for the B.S. in Environmental Science. Open any course to read its full description; section times are posted in the class schedule each term.",
    courses: [
      {
        code: "ENVS 101",
        title: "Earth Systems and Society",
        credits: "4",
        terms: "Fall, Spring, Summer",
        prerequisites: "",
        description: "How the atmosphere, oceans, land and living things interact, and how people change those systems. Includes a weekly lab with two field trips to the Mill Creek watershed. Satisfies the general education natural science requirement.",
        href: "/catalog/envs-101",
      },
      {
        code: "ENVS 210",
        title: "Field Methods in Ecology",
        credits: "3",
        terms: "Fall",
        prerequisites: "ENVS 101 or BIOL 120",
        description: "Hands-on sampling design, species identification and data collection in forest, prairie and stream habitats. Saturday field sessions are required on four dates listed in the syllabus.",
        href: "/catalog/envs-210",
      },
      {
        code: "ENVS 245",
        title: "Introduction to GIS",
        credits: "3",
        terms: "Fall, Spring",
        prerequisites: "MATH 115 or placement",
        description: "Mapping and spatial analysis with open-source GIS tools. Students build a portfolio of three map projects using local land-use, flood-risk and transit data.",
        href: "/catalog/envs-245",
      },
      {
        code: "ENVS 330",
        title: "Water Resources and Policy",
        credits: "3",
        terms: "Spring",
        prerequisites: "ENVS 210 and junior standing",
        description: "Hydrology, water law and the politics of allocation, from municipal supply to agricultural rights. Includes a role-play negotiation over a regional reservoir.",
        href: "/catalog/envs-330",
      },
      {
        code: "ENVS 490",
        title: "Senior Capstone Research",
        credits: "1–4",
        terms: "Fall, Spring",
        prerequisites: "Senior standing and instructor permission",
        description: "An independent or small-team research project with a faculty mentor, ending in a public poster presentation at the spring Research Symposium. May be repeated once for credit.",
        href: "/catalog/envs-490",
      },
    ],
    footnote: "Terms offered are planned and may change with enrollment. Check the class schedule before registering.",
    catalogLabel: "Open the full academic catalog",
    catalogHref: "/catalog",
  },
  render: ({ eyebrow, heading, headingLevel, intro, courses, footnote, catalogLabel, catalogHref }) => {
    const H = headingLevel || "h2";
    const Sub = childHeading[headingLevel] || "h3";
    const list = (courses ?? []).filter((c) => c?.title || c?.code);
    const hasHeader = Boolean(eyebrow || heading || intro);

    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">
          {hasHeader ? (
            <div className="max-w-3xl">
              {eyebrow ? <p className="text-sm font-semibold tracking-wide text-indigo-700 uppercase">{eyebrow}</p> : null}
              {heading ? (
                <H className={`text-3xl font-semibold tracking-tight text-balance text-neutral-950 sm:text-4xl ${eyebrow ? "mt-3" : ""}`}>{heading}</H>
              ) : null}
              {intro ? <p className="mt-4 text-lg leading-8 text-pretty text-neutral-600">{intro}</p> : null}
            </div>
          ) : null}

          {list.length ? (
            <ul role="list" className={`divide-y divide-neutral-200 border-y border-neutral-200 ${hasHeader ? "mt-10 sm:mt-12" : ""}`}>
              {list.map((course, i) => {
                const terms = splitList(course.terms);
                return (
                  <li key={`${course.code}-${i}`} className="py-6 sm:py-7">
                    <article className="grid grid-cols-1 gap-4 sm:grid-cols-5 sm:gap-6">
                      <div className="flex items-center gap-3 sm:col-span-1 sm:flex-col sm:items-start sm:gap-2">
                        {course.code ? (
                          <p className="font-mono text-sm font-semibold tracking-tight text-indigo-700">{course.code}</p>
                        ) : null}
                        {course.credits ? (
                          <p className="text-sm text-neutral-600">
                            <span className="font-semibold text-neutral-900 tabular-nums">{course.credits}</span>{" "}
                            {course.credits.trim() === "1" ? "credit" : "credits"}
                          </p>
                        ) : null}
                      </div>
                      <div className="min-w-0 sm:col-span-4">
                        <Sub className="text-lg leading-7 font-semibold tracking-tight text-balance text-neutral-950 sm:text-xl">
                          {course.href ? (
                            <a
                              href={course.href}
                              className="rounded-sm underline decoration-neutral-300 underline-offset-4 transition hover:text-indigo-700 hover:decoration-indigo-400 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600"
                            >
                              {course.title || course.code}
                            </a>
                          ) : (
                            course.title || course.code
                          )}
                          {course.code && course.title ? <span className="sr-only"> ({course.code})</span> : null}
                        </Sub>

                        <dl className="mt-3 flex flex-col gap-2 text-sm leading-6 sm:flex-row sm:flex-wrap sm:items-center sm:gap-x-6">
                          {terms.length ? (
                            <div className="flex flex-wrap items-center gap-2">
                              <dt className="text-neutral-600">Offered</dt>
                              <dd className="flex flex-wrap gap-1.5">
                                {terms.map((t) => (
                                  <span key={t} className="rounded-md bg-neutral-100 px-2 py-0.5 text-xs font-medium text-neutral-800 ring-1 ring-neutral-200 ring-inset">
                                    {t}
                                  </span>
                                ))}
                              </dd>
                            </div>
                          ) : null}
                          <div className="flex flex-wrap items-baseline gap-x-2">
                            <dt className="text-neutral-600">Prerequisites</dt>
                            <dd className="font-medium text-neutral-900">{course.prerequisites || "None"}</dd>
                          </div>
                        </dl>

                        {course.description ? (
                          <details className="group mt-4">
                            <summary className="inline-flex min-h-11 cursor-pointer list-none items-center gap-1.5 rounded-md text-sm font-semibold text-indigo-700 hover:text-indigo-900 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600 [&::-webkit-details-marker]:hidden">
                              <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="size-5 transition group-open:rotate-90">
                                <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>
                              <span className="group-open:hidden">Course description</span>
                              <span className="hidden group-open:inline">Hide description</span>
                            </summary>
                            <p className="mt-2 max-w-2xl border-l-2 border-indigo-200 pl-4 text-base leading-7 text-pretty text-neutral-700">{course.description}</p>
                          </details>
                        ) : null}
                      </div>
                    </article>
                  </li>
                );
              })}
            </ul>
          ) : null}

          {footnote || catalogLabel ? (
            <div className="mt-8 flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between sm:gap-8">
              {footnote ? <p className="max-w-xl text-sm leading-6 text-pretty text-neutral-600">{footnote}</p> : <span />}
              {catalogLabel ? (
                <a
                  href={catalogHref || "#"}
                  className="group inline-flex min-h-11 shrink-0 items-center gap-2 self-start rounded-lg px-1 text-base font-semibold text-indigo-700 hover:text-indigo-900 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600 sm:self-auto"
                >
                  {catalogLabel}
                  <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="size-5 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>
              ) : null}
            </div>
          ) : null}
        </div>
      </section>
    );
  },
};
```
