# Add the "Elected Officials" block to this P1 project

Add a Puck component from P1 Blocks (https://p1-blocks.prolificdigital.io/blocks/elected-officials) to this Pantheon Content Publisher (P1) Next.js project. Mayor and council with office, term end, direct email and phone, and a find-your-ward link.

## Steps

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

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

/**
 * Elected Officials — mayor and council with office, term, and direct email and phone.
 * Optionally features the first person (usually the mayor) in a wide card; shows initials
 * when a photo is missing. Register: `ElectedOfficialsBlock: electedOfficialsBlock` in puck.config.tsx.
 */

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

type Official = {
  name: string;
  office: string;
  termEnds: string;
  photoUrl: string;
  photoAlt: string;
  email: string;
  phone: string;
  bioHref: string;
};

export type ElectedOfficialsProps = {
  heading: string;
  headingLevel: Heading;
  intro: string;
  officials: Official[];
  featureFirst: "yes" | "no";
  wardLabel: string;
  wardHref: string;
};

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

function initials(name?: string) {
  return (name || "")
    .trim()
    .split(/\s+/)
    .filter(Boolean)
    .map((part) => part[0])
    .slice(0, 2)
    .join("")
    .toUpperCase();
}

function telHref(phone: string) {
  return `tel:${phone.replace(/[^\d+]/g, "")}`;
}

const contactClass =
  "inline-flex min-h-11 items-center gap-2 rounded-lg text-sm font-semibold text-indigo-700 underline decoration-indigo-300 underline-offset-4 hover:text-indigo-900 hover:decoration-indigo-700 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-700";

const mailIcon = (
  <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="size-4 shrink-0">
    <path d="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-2H3Z" />
    <path d="m19 8.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" />
  </svg>
);

const phoneIcon = (
  <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="size-4 shrink-0">
    <path
      fillRule="evenodd"
      d="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.322a11.04 11.04 0 0 0 6.302 6.302l.322-.97a1.5 1.5 0 0 1 1.756-1.02l2.31.513A1.5 1.5 0 0 1 18 12.352V13.5a1.5 1.5 0 0 1-1.5 1.5h-1A13.5 13.5 0 0 1 2 4.5v-1Z"
      clipRule="evenodd"
    />
  </svg>
);

export const electedOfficialsBlock: ComponentConfig<ElectedOfficialsProps> = {
  label: "Elected Officials",
  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." } },
    officials: {
      type: "array",
      label: "Officials",
      min: 1,
      max: 30,
      getItemSummary: (item) => (item?.name ? `${item.name}${item.office ? ` · ${item.office}` : ""}` : "Official"),
      defaultItemProps: { name: "New official", office: "Council Member", termEnds: "", photoUrl: "", photoAlt: "", email: "", phone: "", bioHref: "" },
      arrayFields: {
        name: { type: "text", label: "Name" },
        office: { type: "text", label: "Office", metadata: { help: "Like \"Council Member, Ward 3\" or \"Mayor\"." } },
        termEnds: { type: "text", label: "Term ends", metadata: { help: "Like \"December 2028\". Leave blank to hide it." } },
        photoUrl: { type: "text", label: "Photo URL", metadata: { help: "An official portrait. Leave blank to show initials instead." } },
        photoAlt: { type: "text", label: "Photo alt text", metadata: { help: "Usually blank, since the name is printed beside the photo." } },
        email: { type: "text", label: "Email", metadata: { help: "Leave blank to hide it." } },
        phone: { type: "text", label: "Phone", metadata: { help: "Written as you'd like it shown, like (555) 010-2410." } },
        bioHref: { type: "text", label: "Bio page link", metadata: { help: "Optional. Links the name to a full bio page." } },
      },
    },
    featureFirst: {
      type: "radio",
      label: "Feature the first person",
      options: [
        { label: "Yes", value: "yes" },
        { label: "No", value: "no" },
      ],
      metadata: { help: "Shows the first person in the list, usually the mayor, in a wide card above the others." },
    },
    wardLabel: { type: "text", label: "Find-your-ward link text", metadata: { help: "Leave blank to hide the link." } },
    wardHref: { type: "text", label: "Find-your-ward link", metadata: { help: "Your ward map or address lookup page." } },
  },
  defaultProps: {
    heading: "Your mayor and city council",
    headingLevel: "h2",
    intro: "Millbrook is governed by a mayor elected citywide and six council members, each elected by one ward. Reach out about any city issue; you'll hear back within two business days.",
    officials: [
      {
        name: "Dana Whitaker",
        office: "Mayor",
        termEnds: "December 2028",
        photoUrl: "https://picsum.photos/seed/millbrookmayor/800/800",
        photoAlt: "",
        email: "mayor@millbrook.gov",
        phone: "(555) 010-2400",
        bioHref: "/government/mayor",
      },
      {
        name: "Luis Ortega",
        office: "Council Member, Ward 1",
        termEnds: "December 2026",
        photoUrl: "https://picsum.photos/seed/ortegaward1/600/600",
        photoAlt: "",
        email: "lortega@millbrook.gov",
        phone: "(555) 010-2411",
        bioHref: "/government/council/ward-1",
      },
      {
        name: "Grace Kim",
        office: "Council Member, Ward 2",
        termEnds: "December 2028",
        photoUrl: "https://picsum.photos/seed/kimward2/600/600",
        photoAlt: "",
        email: "gkim@millbrook.gov",
        phone: "(555) 010-2412",
        bioHref: "/government/council/ward-2",
      },
      {
        name: "Robert Haines",
        office: "Council Member, Ward 3",
        termEnds: "December 2026",
        photoUrl: "",
        photoAlt: "",
        email: "rhaines@millbrook.gov",
        phone: "(555) 010-2413",
        bioHref: "/government/council/ward-3",
      },
      {
        name: "Aisha Bello",
        office: "Council Member, Ward 4",
        termEnds: "December 2028",
        photoUrl: "https://picsum.photos/seed/belloward4/600/600",
        photoAlt: "",
        email: "abello@millbrook.gov",
        phone: "(555) 010-2414",
        bioHref: "/government/council/ward-4",
      },
    ],
    featureFirst: "yes",
    wardLabel: "Find your ward",
    wardHref: "/government/wards",
  },
  render: ({ heading, headingLevel, intro, officials, featureFirst, wardLabel, wardHref }) => {
    const H = headingLevel || "h2";
    const Sub = childHeading[headingLevel] || "h3";
    const list = (officials ?? []).filter((o) => o?.name);
    const featured = featureFirst !== "no" && list.length > 0 ? list[0] : null;
    const rest = featured ? list.slice(1) : list;

    const contact = (o: Official) =>
      o.email || o.phone ? (
        <ul role="list" className="flex flex-col items-start gap-x-6 sm:flex-row sm:flex-wrap">
          {o.email ? (
            <li>
              <a href={`mailto:${o.email}`} className={contactClass}>
                {mailIcon}
                Email<span className="sr-only"> {o.name}</span>
              </a>
            </li>
          ) : null}
          {o.phone ? (
            <li>
              <a href={telHref(o.phone)} className={`${contactClass} tabular-nums`}>
                {phoneIcon}
                <span className="sr-only">Call {o.name} at </span>
                {o.phone}
              </a>
            </li>
          ) : null}
        </ul>
      ) : null;

    const name = (o: Official) =>
      o.bioHref ? (
        <a
          href={o.bioHref}
          className="rounded-sm underline-offset-4 hover:text-indigo-800 hover:underline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-700"
        >
          {o.name}
        </a>
      ) : (
        o.name
      );

    const portrait = (o: Official, size: string, text: string) =>
      o.photoUrl ? (
        <img src={o.photoUrl} alt={o.photoAlt || ""} className={`${size} bg-neutral-100 object-cover ring-1 ring-neutral-900/5`} />
      ) : (
        <div aria-hidden="true" className={`${size} grid place-items-center bg-indigo-50 font-semibold tracking-tight text-indigo-700 ring-1 ring-indigo-100 ${text}`}>
          {initials(o.name)}
        </div>
      );

    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 || wardLabel ? (
            <div className="flex flex-col gap-6 md:flex-row md:items-end md:justify-between">
              {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}
              {wardLabel ? (
                <a
                  href={wardHref || "#"}
                  className="inline-flex min-h-11 shrink-0 items-center gap-2 self-start rounded-lg px-4 text-base font-semibold text-neutral-900 ring-1 ring-neutral-300 ring-inset transition hover:bg-neutral-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-700 md:self-auto"
                >
                  <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="size-5 shrink-0 text-indigo-700">
                    <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>
                  {wardLabel}
                </a>
              ) : null}
            </div>
          ) : null}

          {featured ? (
            <article className={`flex flex-col gap-6 rounded-3xl bg-neutral-50 p-5 ring-1 ring-neutral-200 sm:flex-row sm:items-center sm:gap-10 sm:p-8 ${heading || intro || wardLabel ? "mt-10 sm:mt-12" : ""}`}>
              {portrait(featured, "aspect-square w-full max-w-60 shrink-0 rounded-2xl sm:w-48 lg:w-60", "text-6xl")}
              <div className="min-w-0">
                {featured.office ? <p className="text-sm leading-6 font-semibold tracking-wide text-indigo-700 uppercase">{featured.office}</p> : null}
                <Sub className="mt-1 text-2xl font-semibold tracking-tight text-balance text-neutral-950 sm:text-3xl">{name(featured)}</Sub>
                {featured.termEnds ? <p className="mt-2 text-sm leading-6 text-neutral-600">Term ends {featured.termEnds}</p> : null}
                {featured.email || featured.phone ? <div className="mt-4">{contact(featured)}</div> : null}
              </div>
            </article>
          ) : null}

          {rest.length ? (
            <ul
              role="list"
              className={`grid grid-cols-1 gap-x-8 gap-y-10 sm:grid-cols-2 lg:grid-cols-4 ${featured ? "mt-12 border-t border-neutral-200 pt-12" : heading || intro || wardLabel ? "mt-10 sm:mt-12" : ""}`}
            >
              {rest.map((o, i) => (
                <li key={`${o.name}-${i}`} className="flex gap-4 sm:flex-col sm:gap-0">
                  {portrait(o, "size-20 shrink-0 rounded-2xl sm:aspect-square sm:size-auto sm:w-full", "text-2xl sm:text-5xl")}
                  <div className="min-w-0 sm:mt-5">
                    <Sub className="text-lg leading-7 font-semibold tracking-tight text-neutral-950">{name(o)}</Sub>
                    {o.office ? <p className="text-sm leading-6 font-medium text-indigo-700">{o.office}</p> : null}
                    {o.termEnds ? <p className="text-sm leading-6 text-neutral-600">Term ends {o.termEnds}</p> : null}
                    {o.email || o.phone ? <div className="mt-2">{contact(o)}</div> : null}
                  </div>
                </li>
              ))}
            </ul>
          ) : null}
        </div>
      </section>
    );
  },
};
```
