# Add the "Campus Buildings" block to this P1 project

Add a Puck component from P1 Blocks (https://p1-blocks.prolificdigital.io/blocks/campus-buildings) to this Pantheon Content Publisher (P1) Next.js project. An A–Z building directory with codes, departments housed, accessibility features and map links.

## Steps

1. Create `components/puck/campus-buildings-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 { campusBuildingsBlock } from "./components/puck/campus-buildings-block";`
3. Register it under `components` as `CampusBuildingsBlock: campusBuildingsBlock`.
4. Add `"CampusBuildingsBlock"` 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/campus-buildings-block.tsx`

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

/**
 * Campus Buildings — an A–Z building directory with building codes, departments housed,
 * accessibility features and a map link. Sorted alphabetically, with letter jump links.
 * Register: `CampusBuildingsBlock: campusBuildingsBlock` in puck.config.tsx.
 */

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

type Building = {
  name: string;
  code: string;
  departments: string;
  accessibility: string;
  mapHref: string;
};

export type CampusBuildingsProps = {
  heading: string;
  headingLevel: Heading;
  intro: string;
  buildings: Building[];
  mapLabel: string;
  mapHref: string;
  footnote: string;
};

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

const sortKey = (name: string) => name.replace(/^the\s+/i, "").trim();

export const campusBuildingsBlock: ComponentConfig<CampusBuildingsProps> = {
  label: "Campus Buildings",
  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" },
    buildings: {
      type: "array",
      label: "Buildings",
      min: 1,
      max: 80,
      getItemSummary: (item) => [item?.code, item?.name].filter(Boolean).join(" · ") || "Building",
      defaultItemProps: { name: "New Hall", code: "NEW", departments: "", accessibility: "Step-free entrance", mapHref: "/map" },
      arrayFields: {
        name: { type: "text", label: "Building name", metadata: { help: "The list sorts itself alphabetically, ignoring a leading The." } },
        code: { type: "text", label: "Building code", metadata: { help: "The short code on class schedules, such as HOL. Leave blank to hide it." } },
        departments: { type: "textarea", label: "Departments and offices", metadata: { help: "Separate with commas or new lines." } },
        accessibility: { type: "textarea", label: "Accessibility features", metadata: { help: "One per line, such as Step-free entrance on the east side." } },
        mapHref: { type: "text", label: "Map link", metadata: { help: "A link to this building on your campus map. Leave blank to hide it." } },
      },
    },
    mapLabel: { type: "text", label: "Campus map link text", metadata: { help: "Leave blank to hide it." } },
    mapHref: { type: "text", label: "Campus map link" },
    footnote: { type: "textarea", label: "Footnote", metadata: { help: "Small print under the directory, such as who to contact about access barriers. Leave blank to hide it." } },
  },
  defaultProps: {
    heading: "Building directory",
    headingLevel: "h2",
    intro: "Find a building by name or by the code on your class schedule. Every entry lists its accessible entrance; report a broken door opener or elevator to Facilities any time.",
    buildings: [
      {
        name: "Hollis Arena",
        code: "HOL",
        departments: "Athletics, Kinesiology, Commencement and Events",
        accessibility: "Step-free entrance at Gate B\nAccessible seating on the floor and upper concourse\nAssistive listening devices at Guest Services",
        mapHref: "/map?building=HOL",
      },
      {
        name: "Ashford Hall",
        code: "ASH",
        departments: "English, History, Philosophy, Writing Center",
        accessibility: "Step-free entrance on the north side\nElevator to all four floors\nAll-gender accessible restrooms on floors 1 and 3",
        mapHref: "/map?building=ASH",
      },
      {
        name: "Carver Science Center",
        code: "CSC",
        departments: "Biology, Chemistry, Environmental Science, Great Rivers Water Institute",
        accessibility: "Automatic doors at the main entrance\nTwo elevators\nAdjustable-height lab benches in rooms 120 and 214",
        mapHref: "/map?building=CSC",
      },
      {
        name: "Mendez Student Union",
        code: "MSU",
        departments: "Dining, Student Involvement, Campus Food Pantry, Bookstore",
        accessibility: "Step-free entrances on all sides\nElevator and ramps between levels\nSensory-friendly quiet room on level 2",
        mapHref: "/map?building=MSU",
      },
      {
        name: "Bellamy Library",
        code: "BEL",
        departments: "University Libraries, Tutoring Center, Digital Scholarship Lab",
        accessibility: "Automatic doors at the main entrance\nElevator to all floors\nAssistive technology room 104 with screen readers and magnifiers",
        mapHref: "/map?building=BEL",
      },
      {
        name: "Whitfield Engineering Building",
        code: "WEB",
        departments: "Civil Engineering, Computer Science, Electrical and Computer Engineering",
        accessibility: "Step-free entrance from Lot C\nElevator to all floors",
        mapHref: "/map?building=WEB",
      },
    ],
    mapLabel: "Open the interactive campus map",
    mapHref: "/map",
    footnote: "Something not working? Report access barriers to Facilities at access@northfield.example.edu or (555) 555-0117.",
  },
  render: ({ id, heading, headingLevel, intro, buildings, mapLabel, mapHref, footnote }) => {
    const H = headingLevel || "h2";
    const Sub = childHeading[headingLevel] || "h3";
    const base = id || "buildings";
    const sorted = (buildings ?? [])
      .filter((b) => b?.name)
      .slice()
      .sort((a, b) => sortKey(a.name).localeCompare(sortKey(b.name), "en", { sensitivity: "base" }));

    const groups: { letter: string; items: Building[] }[] = [];
    for (const b of sorted) {
      const first = sortKey(b.name).charAt(0).toUpperCase();
      const letter = /[A-Z]/.test(first) ? first : "#";
      const last = groups[groups.length - 1];
      if (last && last.letter === letter) last.items.push(b);
      else groups.push({ letter, items: [b] });
    }
    const anchor = (letter: string) => `${base}-${letter === "#" ? "num" : letter}`;
    const hasHeader = Boolean(heading || intro || mapLabel);

    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-6xl">
          {hasHeader ? (
            <div className="flex flex-col gap-6 lg:flex-row lg:items-end lg:justify-between lg:gap-16">
              <div className="max-w-2xl">
                {heading ? <H 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>
              {mapLabel ? (
                <a
                  href={mapHref || "#"}
                  className="inline-flex min-h-11 shrink-0 items-center justify-center gap-2 self-start rounded-lg bg-white px-5 py-3 text-base font-semibold text-neutral-950 ring-1 ring-neutral-300 transition ring-inset hover:bg-neutral-50 hover:ring-indigo-400 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600 lg:self-auto"
                >
                  <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="size-5 text-indigo-600">
                    <path fillRule="evenodd" d="M8.157 2.176a1.5 1.5 0 0 0-1.147 0l-4.084 1.69A1.5 1.5 0 0 0 2 5.25v10.877a1.5 1.5 0 0 0 2.074 1.386l3.51-1.452 4.26 1.762a1.5 1.5 0 0 0 1.146 0l4.083-1.69A1.5 1.5 0 0 0 18 14.75V3.872a1.5 1.5 0 0 0-2.073-1.386l-3.51 1.452-4.26-1.762ZM7.58 5a.75.75 0 0 1 .75.75v6.5a.75.75 0 0 1-1.5 0v-6.5A.75.75 0 0 1 7.58 5Zm5.59 2.75a.75.75 0 0 0-1.5 0v6.5a.75.75 0 0 0 1.5 0v-6.5Z" clipRule="evenodd" />
                  </svg>
                  {mapLabel}
                </a>
              ) : null}
            </div>
          ) : null}

          {groups.length > 1 ? (
            <nav aria-label="Jump to letter" className={hasHeader ? "mt-10" : ""}>
              <ul role="list" className="flex flex-wrap gap-1.5">
                {groups.map((g) => (
                  <li key={g.letter}>
                    <a
                      href={`#${anchor(g.letter)}`}
                      className="grid size-11 place-items-center rounded-lg bg-neutral-100 text-base font-semibold text-neutral-900 transition hover:bg-indigo-600 hover:text-white focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600"
                    >
                      {g.letter}
                    </a>
                  </li>
                ))}
              </ul>
            </nav>
          ) : null}

          {groups.length ? (
            <div className={`space-y-12 ${hasHeader || groups.length > 1 ? "mt-10 sm:mt-12" : ""}`}>
              {groups.map((g) => (
                <div key={g.letter} id={anchor(g.letter)} className="grid scroll-mt-8 grid-cols-1 gap-4 border-t border-neutral-950 pt-6 md:grid-cols-12 md:gap-8">
                  <p aria-hidden="true" className="text-4xl leading-none font-semibold tracking-tight text-indigo-600 md:col-span-1 md:text-5xl">
                    {g.letter}
                  </p>
                  <ul role="list" className="grid grid-cols-1 gap-x-8 gap-y-8 md:col-span-11 lg:grid-cols-2">
                    {g.items.map((b, i) => {
                      const depts = (b.departments || "")
                        .split(/[,\n]/)
                        .map((d) => d.trim())
                        .filter(Boolean);
                      const features = (b.accessibility || "")
                        .split("\n")
                        .map((f) => f.trim())
                        .filter(Boolean);
                      return (
                        <li key={`${b.name}-${i}`}>
                          <article className="min-w-0">
                            <div className="flex flex-wrap items-baseline gap-x-3 gap-y-1">
                              <Sub className="text-xl leading-7 font-semibold tracking-tight text-neutral-950">{b.name}</Sub>
                              {b.code ? (
                                <p className="rounded-md bg-neutral-950 px-2 py-0.5 font-mono text-xs font-semibold tracking-widest text-white">
                                  <span className="sr-only">Building code </span>
                                  {b.code}
                                </p>
                              ) : null}
                            </div>
                            {depts.length ? <p className="mt-2 text-sm leading-6 text-pretty text-neutral-600">{depts.join(" · ")}</p> : null}
                            {features.length ? (
                              <div className="mt-4">
                                <p className="text-xs font-semibold tracking-wide text-neutral-700 uppercase">Accessibility</p>
                                <ul role="list" className="mt-2 space-y-1.5">
                                  {features.map((f, j) => (
                                    <li key={j} className="flex gap-2 text-sm leading-6 text-neutral-800">
                                      <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="mt-0.5 size-4 shrink-0 text-indigo-600">
                                        <path fillRule="evenodd" d="M16.704 4.153a.75.75 0 0 1 .143 1.052l-8 10.5a.75.75 0 0 1-1.127.075l-4.5-4.5a.75.75 0 0 1 1.06-1.06l3.894 3.893 7.48-9.817a.75.75 0 0 1 1.05-.143Z" clipRule="evenodd" />
                                      </svg>
                                      <span className="min-w-0">{f}</span>
                                    </li>
                                  ))}
                                </ul>
                              </div>
                            ) : null}
                            {b.mapHref ? (
                              <a
                                href={b.mapHref}
                                className="mt-3 inline-flex min-h-11 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"
                              >
                                <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="size-4">
                                  <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>
                                View on map
                                <span className="sr-only">: {b.name}</span>
                              </a>
                            ) : null}
                          </article>
                        </li>
                      );
                    })}
                  </ul>
                </div>
              ))}
            </div>
          ) : null}

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