# Add the "Department Directory" block to this P1 project

Add a Puck component from P1 Blocks (https://p1-blocks.prolificdigital.io/blocks/department-directory) to this Pantheon Content Publisher (P1) Next.js project. Offices sorted A to Z and grouped by letter with a jump index, showing location, phone, email and hours.

## Steps

1. Create `components/puck/department-directory-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 { departmentDirectoryBlock } from "./components/puck/department-directory-block";`
3. Register it under `components` as `DepartmentDirectoryBlock: departmentDirectoryBlock`.
4. Add `"DepartmentDirectoryBlock"` 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/department-directory-block.tsx`

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

/**
 * Department Directory — offices and departments in A–Z order, grouped by letter with a
 * jump-to-letter index. Sorting, grouping and phone/email links are automatic.
 * Register: `DepartmentDirectoryBlock: departmentDirectoryBlock` in puck.config.tsx.
 */

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

type Department = {
  name: string;
  location: string;
  phone: string;
  email: string;
  hours: string;
  href: string;
};

export type DepartmentDirectoryProps = {
  heading: string;
  headingLevel: Heading;
  intro: string;
  departments: Department[];
};

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

const icons = {
  location:
    "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",
  phone:
    "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.745l-1.051.35a.5.5 0 0 0-.31.637 10.48 10.48 0 0 0 6.548 6.548.5.5 0 0 0 .637-.31l.35-1.05a1.5 1.5 0 0 1 1.745-1.021l2.31.513A1.5 1.5 0 0 1 18 15.352V16.5a1.5 1.5 0 0 1-1.5 1.5H15C7.82 18 2 12.18 2 5V3.5Z",
  email:
    "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-2H3ZM19 8.839l-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",
  hours:
    "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",
};

function Row({ icon, label, link, children }: { icon: string; label: string; link?: boolean; children: React.ReactNode }) {
  return (
    <div className={`flex items-start gap-3 ${link ? "" : "py-2.5"}`}>
      <dt className={`flex shrink-0 items-center ${link ? "min-h-11" : "h-6"}`}>
        <span className="sr-only">{label}</span>
        <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="size-5 text-neutral-500">
          <path fillRule="evenodd" d={icon} clipRule="evenodd" />
        </svg>
      </dt>
      <dd className="min-w-0 text-sm leading-6 text-pretty text-neutral-700">{children}</dd>
    </div>
  );
}

const contactLink =
  "inline-flex min-h-11 min-w-0 items-center rounded font-medium text-neutral-950 underline decoration-neutral-300 underline-offset-4 hover:decoration-indigo-600 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600";

export const departmentDirectoryBlock: ComponentConfig<DepartmentDirectoryProps> = {
  label: "Department Directory",
  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" },
    departments: {
      type: "array",
      label: "Departments",
      min: 1,
      max: 80,
      getItemSummary: (item) => item?.name || "Department",
      defaultItemProps: { name: "New office", location: "", phone: "", email: "", hours: "", href: "" },
      arrayFields: {
        name: { type: "text", label: "Name", metadata: { help: "The list sorts itself A to Z, so add offices in any order." } },
        location: { type: "text", label: "Building and room", metadata: { help: "Such as Founders Hall, Room 110. Leave blank to hide it." } },
        phone: { type: "text", label: "Phone", metadata: { help: "Shown as typed. The tap-to-call link is built from the digits." } },
        email: { type: "text", label: "Email" },
        hours: { type: "text", label: "Hours", metadata: { help: "Free text, such as Mon–Fri, 8 a.m.–4:30 p.m." } },
        href: { type: "text", label: "Web page", metadata: { help: "Links the office name to its page. Leave blank for no link." } },
      },
    },
  },
  defaultProps: {
    heading: "Offices and departments",
    headingLevel: "h2",
    intro: "Find the right office, where it is and how to reach it. Most offices are open weekdays during the fall and spring terms.",
    departments: [
      { name: "Registrar", location: "Founders Hall, Room 110", phone: "(555) 014-2310", email: "registrar@northfield.example.edu", hours: "Mon–Fri, 8 a.m.–4:30 p.m.", href: "/registrar" },
      { name: "Financial Aid and Scholarships", location: "Founders Hall, Room 140", phone: "(555) 014-2320", email: "finaid@northfield.example.edu", hours: "Mon–Fri, 8 a.m.–4:30 p.m.", href: "/financial-aid" },
      { name: "Admissions", location: "Welcome Center, first floor", phone: "(555) 014-2200", email: "admissions@northfield.example.edu", hours: "Mon–Fri, 8 a.m.–5 p.m.; Sat, 9 a.m.–noon", href: "/admissions" },
      { name: "Bursar and Student Accounts", location: "Founders Hall, Room 150", phone: "(555) 014-2330", email: "bursar@northfield.example.edu", hours: "Mon–Fri, 8 a.m.–4:30 p.m.", href: "/bursar" },
      { name: "Accessibility Resources", location: "Kessler Library, Room 204", phone: "(555) 014-2400", email: "access@northfield.example.edu", hours: "Mon–Fri, 8 a.m.–5 p.m.", href: "/accessibility" },
      { name: "Career Center", location: "Hollis Student Union, Room 220", phone: "(555) 014-2450", email: "careers@northfield.example.edu", hours: "Mon–Fri, 9 a.m.–5 p.m.", href: "/careers" },
      { name: "Counseling Services", location: "Ward Health Center, second floor", phone: "(555) 014-2500", email: "counseling@northfield.example.edu", hours: "Mon–Fri, 8 a.m.–5 p.m.; crisis line 24/7", href: "/counseling" },
      { name: "Campus Police", location: "Ash Street Building", phone: "(555) 014-2911", email: "police@northfield.example.edu", hours: "Open 24 hours", href: "/police" },
      { name: "Housing and Residence Life", location: "Maple Hall, lower level", phone: "(555) 014-2550", email: "housing@northfield.example.edu", hours: "Mon–Fri, 8 a.m.–5 p.m.", href: "/housing" },
      { name: "IT Help Desk", location: "Kessler Library, Room 101", phone: "(555) 014-2600", email: "help@northfield.example.edu", hours: "Mon–Fri, 7 a.m.–9 p.m.; Sat–Sun, noon–6 p.m.", href: "/it" },
      { name: "Dean of Students", location: "Hollis Student Union, Room 300", phone: "(555) 014-2650", email: "deanofstudents@northfield.example.edu", hours: "Mon–Fri, 8 a.m.–5 p.m.", href: "/dean-of-students" },
      { name: "International Student Services", location: "Hollis Student Union, Room 240", phone: "(555) 014-2700", email: "international@northfield.example.edu", hours: "Mon–Fri, 9 a.m.–4 p.m.", href: "/international" },
    ],
  },
  render: ({ id, heading, headingLevel, intro, departments }) => {
    const H = headingLevel || "h2";
    const Letter = childHeading[headingLevel] || "h3";
    const Name = grandchildHeading[headingLevel] || "h4";
    const uid = `p1-dept-dir-${id}`;

    const sorted = (departments ?? [])
      .filter((d) => d?.name?.trim())
      .slice()
      .sort((a, b) => a.name.trim().localeCompare(b.name.trim(), undefined, { sensitivity: "base", numeric: true }));

    const groups: { letter: string; key: string; items: Department[] }[] = [];
    for (const dept of sorted) {
      const first = dept.name.trim().charAt(0).toLocaleUpperCase();
      const letter = /\p{L}/u.test(first) ? first : "#";
      const last = groups[groups.length - 1];
      if (last && last.letter === letter) last.items.push(dept);
      else groups.push({ letter, key: letter === "#" ? "num" : String(groups.length), items: [dept] });
    }

    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-7xl">
          {heading || intro ? (
            <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>
          ) : null}

          {groups.length > 1 ? (
            <nav aria-label="Jump to letter" className={heading || intro ? "mt-10" : undefined}>
              <ul role="list" className="flex flex-wrap gap-1.5">
                {groups.map((g) => (
                  <li key={g.key}>
                    <a
                      href={`#${uid}-${g.key}`}
                      className="grid size-11 place-items-center rounded-lg bg-neutral-100 text-base font-semibold text-neutral-800 transition hover:bg-indigo-50 hover:text-indigo-700 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={`divide-y divide-neutral-200 border-t border-neutral-200 ${heading || intro || groups.length > 1 ? "mt-10 sm:mt-12" : ""}`}>
              {groups.map((g) => (
                <section key={g.key} aria-labelledby={`${uid}-${g.key}`} className="grid gap-4 py-8 sm:py-10 lg:grid-cols-12 lg:gap-8">
                  <div className="lg:col-span-2">
                    <Letter id={`${uid}-${g.key}`} className="scroll-mt-24 text-4xl font-semibold tracking-tight text-indigo-700 lg:sticky lg:top-24 lg:text-5xl">
                      {g.letter}
                    </Letter>
                  </div>
                  <ul role="list" className="grid gap-x-8 gap-y-8 md:grid-cols-2 lg:col-span-10">
                    {g.items.map((dept, i) => {
                      const tel = (dept.phone || "").replace(/[^\d+]/g, "");
                      const email = (dept.email || "").trim();
                      return (
                        <li key={`${dept.name}-${i}`} className="min-w-0">
                          <Name className="text-lg leading-7 font-semibold text-neutral-950">
                            {dept.href ? (
                              <a
                                href={dept.href}
                                className="group inline-flex min-h-11 items-center gap-1.5 rounded hover:text-indigo-700 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600"
                              >
                                {dept.name}
                                <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="size-4 shrink-0 text-neutral-400 transition group-hover:translate-x-0.5 group-hover:text-indigo-600">
                                  <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>
                            ) : (
                              dept.name
                            )}
                          </Name>
                          {dept.location || tel || email || dept.hours ? (
                            <dl className="mt-1">
                              {dept.location ? (
                                <Row icon={icons.location} label="Location">
                                  {dept.location}
                                </Row>
                              ) : null}
                              {tel ? (
                                <Row icon={icons.phone} label="Phone" link>
                                  <a href={`tel:${tel}`} className={`${contactLink} tabular-nums`}>
                                    {dept.phone}
                                  </a>
                                </Row>
                              ) : null}
                              {email ? (
                                <Row icon={icons.email} label="Email" link>
                                  <a href={`mailto:${email}`} className={`${contactLink} break-all`}>
                                    {email}
                                  </a>
                                </Row>
                              ) : null}
                              {dept.hours ? (
                                <Row icon={icons.hours} label="Hours">
                                  {dept.hours}
                                </Row>
                              ) : null}
                            </dl>
                          ) : null}
                        </li>
                      );
                    })}
                  </ul>
                </section>
              ))}
            </div>
          ) : null}
        </div>
      </section>
    );
  },
};
```
