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

Add a Puck component from P1 Blocks (https://p1-blocks.prolificdigital.io/blocks/staff-directory) to this Pantheon Content Publisher (P1) Next.js project. Staff grouped by department and sorted by last name, with roles, email and tap-to-call extensions, plus department jump links.

## Steps

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

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

/**
 * Staff Directory — school or district staff grouped by department, sorted A–Z by last
 * name, with role, email and a tap-to-call phone extension, plus department jump links.
 * Register: `StaffDirectoryBlock: staffDirectoryBlock` in puck.config.tsx.
 */

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

type Department = { name: string; staff: string };

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

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

const icons = {
  mail: "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-2H3Zm16 4.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",
  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.756l-.97.33a.75.75 0 0 0-.41 1.03 11.5 11.5 0 0 0 5.663 5.663.75.75 0 0 0 1.03-.41l.33-.97a1.5 1.5 0 0 1 1.756-1.02l2.31.513A1.5 1.5 0 0 1 18 15.352V16.5a1.5 1.5 0 0 1-1.5 1.5H15c-7.18 0-13-5.82-13-13V3.5Z",
};

function Icon({ d, className }: { d: string; className: string }) {
  return (
    <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className={className}>
      <path fillRule="evenodd" d={d} clipRule="evenodd" />
    </svg>
  );
}

const lastName = (name: string) => {
  const parts = name.replace(/,.*$/, "").trim().split(/\s+/);
  return (parts[parts.length - 1] || "").toLowerCase();
};

function parseStaff(raw: string) {
  return (raw || "")
    .split("\n")
    .map((line) => line.trim())
    .filter(Boolean)
    .map((line) => {
      const [name = "", role = "", email = "", ext = ""] = line.split("|").map((p) => p.trim());
      return { name, role, email, ext: ext.replace(/^ext\.?\s*/i, "") };
    })
    .filter((p) => p.name)
    .sort((a, b) => lastName(a.name).localeCompare(lastName(b.name)) || a.name.localeCompare(b.name));
}

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

export const staffDirectoryBlock: ComponentConfig<StaffDirectoryProps> = {
  label: "Staff 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", metadata: { help: "Leave blank to hide it." } },
    mainPhone: {
      type: "text",
      label: "Main phone number",
      metadata: { help: "Extensions dial through this number. Leave blank to show extensions as plain text." },
    },
    departments: {
      type: "array",
      label: "Departments",
      min: 1,
      max: 20,
      getItemSummary: (item) => item?.name || "Department",
      defaultItemProps: { name: "New department", staff: "" },
      arrayFields: {
        name: { type: "text", label: "Department" },
        staff: {
          type: "textarea",
          label: "Staff",
          metadata: {
            help: "One person per line: name | role | email | extension. Example: Ana Ruiz | Counselor | aruiz@school.org | 2104. Lines are sorted by last name for you.",
          },
        },
      },
    },
    note: { type: "textarea", label: "Footnote", metadata: { help: "Leave blank to hide it." } },
  },
  defaultProps: {
    heading: "Staff directory",
    headingLevel: "h2",
    intro: "Riverbend High School staff, sorted by last name. Teachers usually answer email within one school day.",
    mainPhone: "555-0130",
    departments: [
      {
        name: "Administration",
        staff:
          "Angela Torres | Principal | atorres@riverbendusd.example.org | 1001\nKevin Marsh | Assistant Principal, grades 9–10 | kmarsh@riverbendusd.example.org | 1002\nDenise Carter | Assistant Principal, grades 11–12 | dcarter@riverbendusd.example.org | 1003\nLuis Ortega | Office Manager | lortega@riverbendusd.example.org | 1000\nJanelle Brooks | Attendance Clerk | jbrooks@riverbendusd.example.org | 1010",
      },
      {
        name: "Counseling",
        staff:
          "Samantha Lee | Counselor, last names A–G | slee@riverbendusd.example.org | 2101\nOmar Haddad | Counselor, last names H–O | ohaddad@riverbendusd.example.org | 2102\nRachel Kim | Counselor, last names P–Z | rkim@riverbendusd.example.org | 2103\nBen Foster | College and Career Advisor | bfoster@riverbendusd.example.org | 2110",
      },
      {
        name: "Special education",
        staff:
          "Teresa Vaughn | Special Education Coordinator | tvaughn@riverbendusd.example.org | 2201\nMichael Duarte | Resource Teacher | mduarte@riverbendusd.example.org | 2202\nHannah Price | School Psychologist | hprice@riverbendusd.example.org | 2203",
      },
      {
        name: "Health and wellness",
        staff:
          "Carla Jimenez | School Nurse | cjimenez@riverbendusd.example.org | 2301\nDavid Arnott | Social Worker | darnott@riverbendusd.example.org | 2302",
      },
    ],
    note: "Need someone not listed here? Call the main office and we'll connect you.",
  },
  render: ({ id, heading, headingLevel, intro, mainPhone, departments, note }) => {
    const H = headingLevel || "h2";
    const Sub = lower[H] || "h3";
    const uid = id || "staff-directory";
    const base = (mainPhone || "").replace(/[^\d+]/g, "");
    const groups = (departments ?? [])
      .filter((d) => d?.name)
      .map((d, i) => ({ name: d.name, anchor: `${uid}-${slug(d.name)}-${i}`, people: parseStaff(d.staff) }))
      .filter((g) => g.people.length);

    return (
      <section aria-labelledby={heading ? `${uid}-heading` : undefined} 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">
          {heading || intro ? (
            <div className="max-w-2xl">
              {heading ? (
                <H id={`${uid}-heading`} 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}
              {mainPhone ? (
                <p className="mt-4 text-sm text-neutral-700">
                  Main office:{" "}
                  <a href={`tel:${base}`} className="inline-flex min-h-11 items-center rounded-md font-semibold text-indigo-700 tabular-nums hover:text-indigo-900 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-700">
                    {mainPhone}
                  </a>
                </p>
              ) : null}
            </div>
          ) : null}

          {groups.length > 1 ? (
            <nav aria-label="Jump to a department" className={`border-y border-neutral-200 py-3 ${heading || intro ? "mt-8" : ""}`}>
              <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 px-4 text-sm font-semibold text-neutral-800 ring-1 ring-neutral-300 transition ring-inset hover:bg-neutral-50 hover:ring-neutral-400 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-700"
                    >
                      {g.name}
                      <span className="text-xs font-medium text-neutral-500 tabular-nums">
                        {g.people.length}
                        <span className="sr-only"> {g.people.length === 1 ? "person" : "people"}</span>
                      </span>
                    </a>
                  </li>
                ))}
              </ul>
            </nav>
          ) : null}

          {groups.map((g, gi) => (
            <div key={g.anchor} id={g.anchor} className={`scroll-mt-8 ${gi === 0 ? "mt-10" : "mt-14"}`}>
              <Sub className="border-b-2 border-neutral-950 pb-2 text-xl font-semibold tracking-tight text-neutral-950">{g.name}</Sub>
              <ul role="list" className="divide-y divide-neutral-200">
                {g.people.map((p, i) => (
                  <li key={`${p.name}-${i}`} className="grid grid-cols-1 gap-x-6 gap-y-1 py-4 sm:grid-cols-12 sm:items-center">
                    <div className="min-w-0 sm:col-span-5">
                      <p className="text-base font-semibold text-neutral-950">{p.name}</p>
                      {p.role ? <p className="text-sm leading-6 text-pretty text-neutral-600">{p.role}</p> : null}
                    </div>
                    <div className="flex min-w-0 flex-wrap items-center gap-x-6 sm:col-span-7 sm:justify-end">
                      {p.email ? (
                        <a
                          href={`mailto:${p.email}`}
                          className="inline-flex min-h-11 min-w-0 items-center gap-2 rounded-md text-sm font-medium break-all text-indigo-700 hover:text-indigo-900 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-700"
                        >
                          <Icon d={icons.mail} className="size-4 shrink-0" />
                          {p.email}
                        </a>
                      ) : null}
                      {p.ext ? (
                        base ? (
                          <a
                            href={`tel:${base},${p.ext.replace(/\D/g, "")}`}
                            className="inline-flex min-h-11 shrink-0 items-center gap-2 rounded-md text-sm font-medium text-neutral-800 tabular-nums hover:text-indigo-700 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-700"
                          >
                            <Icon d={icons.phone} className="size-4 shrink-0 text-neutral-400" />
                            ext. {p.ext}
                            <span className="sr-only">, call {p.name}</span>
                          </a>
                        ) : (
                          <p className="inline-flex shrink-0 items-center gap-2 text-sm text-neutral-800 tabular-nums">
                            <Icon d={icons.phone} className="size-4 shrink-0 text-neutral-400" />
                            ext. {p.ext}
                          </p>
                        )
                      ) : null}
                    </div>
                  </li>
                ))}
              </ul>
            </div>
          ))}

          {note ? <p className="mt-10 text-sm leading-6 text-pretty text-neutral-600">{note}</p> : null}
        </div>
      </section>
    );
  },
};
```
