# Add the "School Finder" block to this P1 project

Add a Puck component from P1 Blocks (https://p1-blocks.prolificdigital.io/blocks/school-finder) to this Pantheon Content Publisher (P1) Next.js project. Schools grouped by level with grades, principal, address, phone and website, plus level jump links and an address lookup.

## Steps

1. Create `components/puck/school-finder-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 { schoolFinderBlock } from "./components/puck/school-finder-block";`
3. Register it under `components` as `SchoolFinderBlock: schoolFinderBlock`.
4. Add `"SchoolFinderBlock"` 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/school-finder-block.tsx`

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

/**
 * School Finder — every school in the district grouped by level (elementary, middle, high,
 * alternative), with grades, principal, address, phone and website, plus level jump links.
 * Register: `SchoolFinderBlock: schoolFinderBlock` in puck.config.tsx.
 */

type Heading = "h1" | "h2" | "h3" | "h4";
type Level = "elementary" | "middle" | "high" | "alternative";

type School = {
  name: string;
  level: Level;
  grades: string;
  principal: string;
  address: string;
  phone: string;
  websiteHref: string;
};

export type SchoolFinderProps = {
  heading: string;
  headingLevel: Heading;
  intro: string;
  finderLabel: string;
  finderHref: string;
  finderNote: string;
  schools: School[];
};

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

const levels: { value: Level; label: string; short: string }[] = [
  { value: "elementary", label: "Elementary schools", short: "Elementary" },
  { value: "middle", label: "Middle schools", short: "Middle" },
  { value: "high", label: "High schools", short: "High" },
  { value: "alternative", label: "Alternative programs", short: "Alternative" },
];

const icons = {
  pin: "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.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",
  user: "M10 8a3 3 0 1 0 0-6 3 3 0 0 0 0 6ZM3.465 14.493a1.23 1.23 0 0 0 .41 1.412A9.957 9.957 0 0 0 10 18c2.31 0 4.438-.784 6.131-2.1.43-.333.604-.903.408-1.41a7.002 7.002 0 0 0-13.074.003Z",
  search: "M9 3.5a5.5 5.5 0 1 0 0 11 5.5 5.5 0 0 0 0-11ZM2 9a7 7 0 1 1 12.452 4.391l3.328 3.329a.75.75 0 1 1-1.06 1.06l-3.329-3.328A7 7 0 0 1 2 9Z",
  arrow: "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",
};

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 telHref = (phone: string) => `tel:${phone.replace(/[^\d+]/g, "")}`;

export const schoolFinderBlock: ComponentConfig<SchoolFinderProps> = {
  label: "School Finder",
  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." } },
    finderLabel: { type: "text", label: "Address lookup link text", metadata: { help: "Leave blank to hide the lookup card." } },
    finderHref: { type: "text", label: "Address lookup link", metadata: { help: "Your attendance-boundary or school-locator tool." } },
    finderNote: { type: "textarea", label: "Address lookup note", metadata: { help: "One or two sentences shown beside the link. Leave blank to hide it." } },
    schools: {
      type: "array",
      label: "Schools",
      min: 1,
      max: 60,
      getItemSummary: (item) => (item?.name ? `${levels.find((l) => l.value === item.level)?.short ?? "School"} · ${item.name}` : "School"),
      defaultItemProps: { name: "New school", level: "elementary", grades: "K–5", principal: "", address: "", phone: "", websiteHref: "" },
      arrayFields: {
        name: { type: "text", label: "School name" },
        level: {
          type: "select",
          label: "Level",
          options: [
            { label: "Elementary", value: "elementary" },
            { label: "Middle", value: "middle" },
            { label: "High", value: "high" },
            { label: "Alternative", value: "alternative" },
          ],
          metadata: { help: "Schools are grouped by level. Empty levels are hidden." },
        },
        grades: { type: "text", label: "Grades served", metadata: { help: "Like \"K–5\" or \"9–12\"." } },
        principal: { type: "text", label: "Principal", metadata: { help: "Full name. Leave blank to hide it." } },
        address: { type: "textarea", label: "Address" },
        phone: { type: "text", label: "Main office phone" },
        websiteHref: { type: "text", label: "School website link", metadata: { help: "Leave blank to hide the link." } },
      },
    },
  },
  defaultProps: {
    heading: "Find a school",
    headingLevel: "h2",
    intro: "Riverbend Unified has 10 schools and programs serving families from preschool through grade 12.",
    finderLabel: "Find your school by address",
    finderHref: "/schools/boundary-lookup",
    finderNote: "Your home address decides which neighborhood school your child attends. Type it in and we'll show your elementary, middle and high school.",
    schools: [
      { name: "Alder Creek Elementary", level: "elementary", grades: "PreK–5", principal: "Monica Reyes", address: "1420 Alder Creek Road, Riverbend", phone: "555-0110", websiteHref: "/schools/alder-creek" },
      { name: "Bridgeview Elementary", level: "elementary", grades: "K–5", principal: "Daniel Okafor", address: "88 Bridge Street, Riverbend", phone: "555-0111", websiteHref: "/schools/bridgeview" },
      { name: "Hawthorne Elementary", level: "elementary", grades: "K–5", principal: "Lisa Nguyen", address: "305 Hawthorne Avenue, Riverbend", phone: "555-0112", websiteHref: "/schools/hawthorne" },
      { name: "Millpond Elementary", level: "elementary", grades: "K–5", principal: "Grace Whitfield", address: "2 Millpond Lane, Riverbend", phone: "555-0113", websiteHref: "/schools/millpond" },
      { name: "Riverbend Middle School", level: "middle", grades: "6–8", principal: "Marcus Bell", address: "900 Center Street, Riverbend", phone: "555-0120", websiteHref: "/schools/riverbend-middle" },
      { name: "Westfield Middle School", level: "middle", grades: "6–8", principal: "Priya Raman", address: "4100 Westfield Parkway, Riverbend", phone: "555-0121", websiteHref: "/schools/westfield-middle" },
      { name: "Riverbend High School", level: "high", grades: "9–12", principal: "Angela Torres", address: "1 Ranger Way, Riverbend", phone: "555-0130", websiteHref: "/schools/riverbend-high" },
      { name: "Northgate High School", level: "high", grades: "9–12", principal: "James Whitaker", address: "7700 Northgate Boulevard, Riverbend", phone: "555-0131", websiteHref: "/schools/northgate-high" },
      { name: "Harbor Academy", level: "alternative", grades: "9–12", principal: "Rosa Delgado", address: "215 Harbor Street, Riverbend", phone: "555-0140", websiteHref: "/schools/harbor-academy" },
      { name: "Riverbend Online Learning", level: "alternative", grades: "K–12", principal: "Tom Eckert", address: "District Office, 500 Main Street, Riverbend", phone: "555-0141", websiteHref: "/schools/online" },
    ],
  },
  render: ({ id, heading, headingLevel, intro, finderLabel, finderHref, finderNote, schools }) => {
    const H = headingLevel || "h2";
    const Group = lower[H] || "h3";
    const Name = lower[Group] || "h4";
    const uid = id || "school-finder";
    const list = (schools ?? []).filter((s) => s?.name);
    const groups = levels
      .map((l) => ({ ...l, schools: list.filter((s) => (s.level || "elementary") === l.value) }))
      .filter((g) => g.schools.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-7xl">
          <div className="grid grid-cols-1 gap-8 lg:grid-cols-5 lg:items-end lg:gap-12">
            {heading || intro ? (
              <div className="lg:col-span-3">
                {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 max-w-2xl text-lg leading-8 text-pretty text-neutral-600">{intro}</p> : null}
              </div>
            ) : null}
            {finderLabel ? (
              <div className="rounded-2xl bg-indigo-50 p-5 ring-1 ring-indigo-100 sm:p-6 lg:col-span-2">
                {finderNote ? <p className="text-sm leading-6 text-pretty text-indigo-950">{finderNote}</p> : null}
                <a
                  href={finderHref || "#"}
                  className={`group inline-flex min-h-11 items-center gap-2 rounded-lg bg-indigo-700 px-4 py-2.5 text-sm font-semibold text-white shadow-sm transition hover:bg-indigo-800 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-700 ${finderNote ? "mt-4" : ""}`}
                >
                  <Icon d={icons.search} className="size-5 shrink-0" />
                  {finderLabel}
                  <Icon d={icons.arrow} className="size-4 shrink-0 transition motion-safe:group-hover:translate-x-0.5" />
                </a>
              </div>
            ) : null}
          </div>

          {groups.length > 1 ? (
            <nav aria-label="Jump to a school level" className="mt-10 border-y border-neutral-200 py-3 sm:mt-12">
              <ul role="list" className="flex flex-wrap gap-2">
                {groups.map((g) => (
                  <li key={g.value}>
                    <a
                      href={`#${uid}-${g.value}`}
                      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.short}
                      <span className="rounded-full bg-neutral-100 px-2 py-0.5 text-xs font-medium text-neutral-700 tabular-nums">
                        {g.schools.length}
                        <span className="sr-only"> {g.schools.length === 1 ? "school" : "schools"}</span>
                      </span>
                    </a>
                  </li>
                ))}
              </ul>
            </nav>
          ) : null}

          {groups.map((g, gi) => (
            <div key={g.value} id={`${uid}-${g.value}`} className={`scroll-mt-8 ${gi === 0 ? "mt-10 sm:mt-12" : "mt-14 sm:mt-16"}`}>
              <Group className="flex items-baseline gap-3 text-xl font-semibold tracking-tight text-neutral-950 sm:text-2xl">
                {g.label}
                <span className="text-sm font-medium text-neutral-500 tabular-nums">{g.schools.length}</span>
              </Group>
              <ul role="list" className="mt-6 grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3">
                {g.schools.map((s, i) => (
                  <li key={`${s.name}-${i}`} className="flex min-w-0 flex-col rounded-2xl bg-white p-5 ring-1 ring-neutral-200 transition hover:ring-neutral-300 sm:p-6">
                    <div className="flex items-start justify-between gap-4">
                      <Name className="min-w-0 text-lg leading-7 font-semibold text-balance text-neutral-950">{s.name}</Name>
                      {s.grades ? (
                        <p className="shrink-0 rounded-md bg-indigo-50 px-2 py-1 text-xs font-semibold text-indigo-800 ring-1 ring-indigo-200 ring-inset">
                          <span className="sr-only">Grades </span>
                          {s.grades}
                        </p>
                      ) : null}
                    </div>
                    <dl className="mt-4 space-y-2 text-sm leading-6 text-neutral-700">
                      {s.principal ? (
                        <div className="flex gap-2.5">
                          <dt className="shrink-0">
                            <span className="sr-only">Principal</span>
                            <Icon d={icons.user} className="mt-0.5 size-5 text-neutral-400" />
                          </dt>
                          <dd className="min-w-0">
                            {s.principal}
                            <span className="text-neutral-500">, Principal</span>
                          </dd>
                        </div>
                      ) : null}
                      {s.address ? (
                        <div className="flex gap-2.5">
                          <dt className="shrink-0">
                            <span className="sr-only">Address</span>
                            <Icon d={icons.pin} className="mt-0.5 size-5 text-neutral-400" />
                          </dt>
                          <dd className="min-w-0 text-pretty">{s.address}</dd>
                        </div>
                      ) : null}
                    </dl>
                    {s.phone || s.websiteHref ? (
                      <div className="mt-auto flex flex-wrap gap-x-5 gap-y-1 pt-4">
                        {s.phone ? (
                          <a
                            href={telHref(s.phone)}
                            className="inline-flex min-h-11 items-center gap-2 rounded-md text-sm font-semibold text-neutral-900 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-indigo-700" />
                            {s.phone}
                            <span className="sr-only">, call {s.name}</span>
                          </a>
                        ) : null}
                        {s.websiteHref ? (
                          <a
                            href={s.websiteHref}
                            className="group 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-700"
                          >
                            School website
                            <span className="sr-only">: {s.name}</span>
                            <Icon d={icons.arrow} className="size-4 shrink-0 transition motion-safe:group-hover:translate-x-0.5" />
                          </a>
                        ) : null}
                      </div>
                    ) : null}
                  </li>
                ))}
              </ul>
            </div>
          ))}
        </div>
      </section>
    );
  },
};
```
