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

Add a Puck component from P1 Blocks (https://p1-blocks.prolificdigital.io/blocks/provider-directory) to this Pantheon Content Publisher (P1) Next.js project. Providers grouped by specialty with jump links, credentials, clinic, languages and a new-patient badge.

## Steps

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

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

/**
 * Provider Directory — doctors, nurse practitioners and other providers grouped by specialty,
 * with jump links, photo or initials, credentials, clinic, languages, a new-patient badge
 * and a profile link.
 * Register: `ProviderDirectoryBlock: providerDirectoryBlock` in puck.config.tsx.
 */

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

type Provider = {
  name: string;
  credentials: string;
  specialty: string;
  clinic: string;
  languages: string;
  accepting: "yes" | "limited" | "no";
  photoUrl: string;
  photoAlt: string;
  profileHref: string;
};

export type ProviderDirectoryProps = {
  heading: string;
  headingLevel: Heading;
  intro: string;
  providers: Provider[];
  footnote: string;
};

const nextLevel = { h1: "h2", h2: "h3", h3: "h4", h4: "h5", h5: "h6", h6: "h6" } as const;
const focusRing = "focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600";
const slug = (s: string) => s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "") || "group";

const initialsOf = (name: string) => {
  const parts = name.replace(/^dr\.?\s+/i, "").split(/\s+/).filter(Boolean);
  const pick = parts.length > 1 ? [parts[0], parts[parts.length - 1]] : parts;
  return pick.map((p) => p[0]).join("").toUpperCase();
};

const accepting = {
  yes: { label: "Accepting new patients", icon: "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", cls: "bg-indigo-50 text-indigo-800 ring-indigo-600/20" },
  limited: { label: "Limited new patients", icon: "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", cls: "bg-neutral-100 text-neutral-800 ring-neutral-950/10" },
  no: { label: "Not accepting new patients", icon: "M4 10a.75.75 0 0 1 .75-.75h10.5a.75.75 0 0 1 0 1.5H4.75A.75.75 0 0 1 4 10Z", cls: "bg-white text-neutral-700 ring-neutral-950/15" },
};

export const providerDirectoryBlock: ComponentConfig<ProviderDirectoryProps> = {
  label: "Provider 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. Specialties use the next level down, and provider names the level after that." },
    },
    intro: { type: "textarea", label: "Intro" },
    providers: {
      type: "array",
      label: "Providers",
      min: 1,
      max: 60,
      getItemSummary: (item) => (item?.name ? `${item.name}${item.specialty ? ` · ${item.specialty}` : ""}` : "Provider"),
      defaultItemProps: { name: "New provider", credentials: "", specialty: "Primary care", clinic: "", languages: "", accepting: "yes", photoUrl: "", photoAlt: "", profileHref: "" },
      arrayFields: {
        name: { type: "text", label: "Name" },
        credentials: { type: "text", label: "Credentials", metadata: { help: "Like MD, DO, NP, PA-C or DDS." } },
        specialty: { type: "text", label: "Specialty", metadata: { help: "Providers with the same specialty are grouped together, in the order the specialty first appears." } },
        clinic: { type: "text", label: "Clinic" },
        languages: { type: "text", label: "Languages", metadata: { help: "Separate with commas." } },
        accepting: {
          type: "radio",
          label: "New patients",
          options: [
            { label: "Accepting", value: "yes" },
            { label: "Limited", value: "limited" },
            { label: "Not accepting", value: "no" },
          ],
        },
        photoUrl: { type: "text", label: "Photo URL", metadata: { help: "Use a real, approved photo of this provider. Leave blank to show initials." } },
        photoAlt: { type: "text", label: "Photo alt text", metadata: { help: "Leave blank if the photo only shows the person named next to it." } },
        profileHref: { type: "text", label: "Profile link", metadata: { help: "Leave blank to hide the link." } },
      },
    },
    footnote: { type: "textarea", label: "Footnote", metadata: { help: "Optional, like how to request a provider. Leave blank to hide." } },
  },
  defaultProps: {
    heading: "Our providers",
    headingLevel: "h2",
    intro: "Choose a provider who fits you. Every provider works with a care team of nurses, medical assistants and community health workers.",
    providers: [
      { name: "Dr. Maya Okafor", credentials: "MD", specialty: "Family medicine", clinic: "Harbor Street Health Center", languages: "English, Igbo", accepting: "yes", photoUrl: "", photoAlt: "", profileHref: "/providers/maya-okafor" },
      { name: "Luis Herrera", credentials: "NP", specialty: "Family medicine", clinic: "Northside Family Clinic", languages: "English, Spanish", accepting: "yes", photoUrl: "", photoAlt: "", profileHref: "/providers/luis-herrera" },
      { name: "Dr. Grace Lindqvist", credentials: "DO", specialty: "Family medicine", clinic: "Dunes Road Community Clinic", languages: "English", accepting: "limited", photoUrl: "", photoAlt: "", profileHref: "/providers/grace-lindqvist" },
      { name: "Dr. Samir Haddad", credentials: "MD", specialty: "Pediatrics", clinic: "Harbor Street Health Center", languages: "English, Arabic", accepting: "yes", photoUrl: "", photoAlt: "", profileHref: "/providers/samir-haddad" },
      { name: "Tou Vang", credentials: "PA-C", specialty: "Pediatrics", clinic: "Northside Family Clinic", languages: "English, Hmong", accepting: "no", photoUrl: "", photoAlt: "", profileHref: "/providers/tou-vang" },
      { name: "Dr. Renee Whitfield", credentials: "DDS", specialty: "Dental", clinic: "Harbor Street Health Center", languages: "English", accepting: "yes", photoUrl: "", photoAlt: "", profileHref: "/providers/renee-whitfield" },
    ],
    footnote: "Want a provider who speaks your language or shares your background? Call (555) 010-2000 and we'll help you find a match.",
  },
  render: ({ id, heading, headingLevel, intro, providers, footnote }) => {
    const H = headingLevel || "h2";
    const GroupH = nextLevel[H] ?? "h3";
    const NameH = nextLevel[GroupH] ?? "h4";
    const base = `pd-${id || "block"}`;
    const list = (providers ?? []).filter((p) => p?.name);

    const groups: { name: string; anchor: string; items: Provider[] }[] = [];
    for (const p of list) {
      const name = (p.specialty || "").trim() || "Other providers";
      let g = groups.find((x) => x.name === name);
      if (!g) {
        g = { name, anchor: `${base}-${slug(name)}-${groups.length}`, items: [] };
        groups.push(g);
      }
      g.items.push(p);
    }

    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">
          <div className="grid grid-cols-1 gap-10 lg:grid-cols-12 lg:gap-12">
            <div className="lg:col-span-4">
              <div className="lg:sticky lg:top-8">
                {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-base leading-7 text-pretty text-neutral-600">{intro}</p> : null}
                {groups.length > 1 ? (
                  <nav aria-label={`${heading || "Providers"}: jump to a specialty`} className="mt-8">
                    <p className="text-xs font-semibold tracking-wider text-neutral-600 uppercase">Jump to</p>
                    <ul role="list" className="mt-3 flex flex-wrap gap-2 lg:flex-col lg:gap-1">
                      {groups.map((g) => (
                        <li key={g.anchor}>
                          <a
                            href={`#${g.anchor}`}
                            className={`inline-flex min-h-11 items-center justify-between gap-3 rounded-lg bg-neutral-50 px-3.5 py-2 text-sm font-semibold text-neutral-900 ring-1 ring-neutral-950/5 ring-inset transition hover:bg-indigo-50 hover:text-indigo-800 lg:flex lg:bg-transparent lg:ring-0 ${focusRing}`}
                          >
                            {g.name}
                            <span className="rounded-full bg-white px-2 py-0.5 text-xs font-medium text-neutral-600 tabular-nums ring-1 ring-neutral-950/10">
                              {g.items.length}
                              <span className="sr-only"> {g.items.length === 1 ? "provider" : "providers"}</span>
                            </span>
                          </a>
                        </li>
                      ))}
                    </ul>
                  </nav>
                ) : null}
              </div>
            </div>

            <div className="space-y-14 lg:col-span-8">
              {groups.map((g) => (
                <section key={g.anchor} aria-labelledby={g.anchor} className="scroll-mt-8">
                  <GroupH id={g.anchor} className="scroll-mt-8 border-b border-neutral-200 pb-3 text-xl font-semibold tracking-tight text-neutral-950">
                    {g.name}
                  </GroupH>
                  <ul role="list" className="mt-2 divide-y divide-neutral-200">
                    {g.items.map((p, i) => {
                      const a = accepting[p.accepting] ?? accepting.yes;
                      const fullName = p.credentials ? `${p.name}, ${p.credentials}` : p.name;
                      return (
                        <li key={`${p.name}-${i}`} className="flex flex-col gap-4 py-6 sm:flex-row sm:items-start sm:gap-6">
                          {p.photoUrl ? (
                            <img src={p.photoUrl} alt={p.photoAlt || ""} className="size-16 shrink-0 rounded-full bg-neutral-100 object-cover ring-1 ring-neutral-950/5" />
                          ) : (
                            <span aria-hidden="true" className="grid size-16 shrink-0 place-items-center rounded-full bg-indigo-50 text-lg font-semibold tracking-wide text-indigo-800 ring-1 ring-indigo-600/15">
                              {initialsOf(p.name)}
                            </span>
                          )}
                          <div className="min-w-0 flex-1">
                            <NameH className="text-lg font-semibold tracking-tight text-neutral-950">{fullName}</NameH>
                            <dl className="mt-1 space-y-0.5 text-sm leading-6 text-neutral-600">
                              {p.clinic ? (
                                <div>
                                  <dt className="sr-only">Clinic</dt>
                                  <dd>{p.clinic}</dd>
                                </div>
                              ) : null}
                              {p.languages ? (
                                <div className="flex gap-1">
                                  <dt className="font-medium text-neutral-800">Speaks</dt>
                                  <dd>{p.languages}</dd>
                                </div>
                              ) : null}
                            </dl>
                            <p className={`mt-3 inline-flex items-center gap-1.5 rounded-md px-2 py-1 text-xs font-semibold ring-1 ring-inset ${a.cls}`}>
                              <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="size-4 shrink-0">
                                <path fillRule="evenodd" d={a.icon} clipRule="evenodd" />
                              </svg>
                              {a.label}
                            </p>
                          </div>
                          {p.profileHref ? (
                            <a
                              href={p.profileHref}
                              className={`group inline-flex min-h-11 shrink-0 items-center gap-1.5 self-start rounded-lg text-sm font-semibold text-indigo-700 hover:text-indigo-900 ${focusRing}`}
                            >
                              View profile
                              <span className="sr-only">: {p.name}</span>
                              <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="size-4 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}
                        </li>
                      );
                    })}
                  </ul>
                </section>
              ))}
              {footnote ? <p className="rounded-xl bg-neutral-50 p-5 text-sm leading-6 text-pretty text-neutral-700 ring-1 ring-neutral-950/5 ring-inset">{footnote}</p> : null}
            </div>
          </div>
        </div>
      </section>
    );
  },
};
```
