# Add the "Bus Routes" block to this P1 project

Add a Puck component from P1 Blocks (https://p1-blocks.prolificdigital.io/blocks/bus-routes) to this Pantheon Content Publisher (P1) Next.js project. School bus routes with schools served, first pickup and expandable stop lists, plus a stop finder and transportation contact.

## Steps

1. Create `components/puck/bus-routes-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 { busRoutesBlock } from "./components/puck/bus-routes-block";`
3. Register it under `components` as `BusRoutesBlock: busRoutesBlock`.
4. Add `"BusRoutesBlock"` 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/bus-routes-block.tsx`

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

/**
 * Bus Routes — school bus routes with schools served, first pickup time and every stop in an
 * expandable list, plus a find-my-stop link, transportation contact and bad-weather note.
 * Register: `BusRoutesBlock: busRoutesBlock` in puck.config.tsx.
 */

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

type Route = { number: string; schools: string; firstPickup: string; stops: string };

export type BusRoutesProps = {
  heading: string;
  headingLevel: Heading;
  intro: string;
  findLabel: string;
  findHref: string;
  routes: Route[];
  weatherNote: string;
  officeName: string;
  officeHours: string;
  officePhone: string;
  officeEmail: string;
};

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

const icons = {
  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",
  clock: "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",
  chevron: "M5.22 8.22a.75.75 0 0 1 1.06 0L10 11.94l3.72-3.72a.75.75 0 1 1 1.06 1.06l-4.25 4.25a.75.75 0 0 1-1.06 0L5.22 9.28a.75.75 0 0 1 0-1.06Z",
  cloud: "M1 12.5A4.5 4.5 0 0 0 5.5 17H15a4 4 0 0 0 1.866-7.539 3.504 3.504 0 0 0-4.504-4.272A4.5 4.5 0 0 0 4.06 8.235 4.502 4.502 0 0 0 1 12.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",
  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",
};

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>
  );
}

function parseStops(raw: string) {
  return (raw || "")
    .split("\n")
    .map((line) => line.trim())
    .filter(Boolean)
    .map((line) => {
      const cut = line.indexOf("|");
      return cut === -1 ? { time: "", place: line } : { time: line.slice(0, cut).trim(), place: line.slice(cut + 1).trim() };
    });
}

const contactLink =
  "inline-flex min-h-11 items-center gap-2.5 rounded-md text-sm font-semibold text-neutral-900 hover:text-indigo-700 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-700";

export const busRoutesBlock: ComponentConfig<BusRoutesProps> = {
  label: "Bus Routes",
  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." } },
    findLabel: { type: "text", label: "Stop lookup link text", metadata: { help: "Leave blank to hide the link." } },
    findHref: { type: "text", label: "Stop lookup link", metadata: { help: "Your address-based bus stop finder." } },
    routes: {
      type: "array",
      label: "Routes",
      min: 1,
      max: 60,
      getItemSummary: (item) => (item?.number ? `Route ${item.number}${item.schools ? ` · ${item.schools}` : ""}` : "Route"),
      defaultItemProps: { number: "", schools: "", firstPickup: "", stops: "" },
      arrayFields: {
        number: { type: "text", label: "Route number", metadata: { help: "Just the number or code, like 12 or 7A." } },
        schools: { type: "text", label: "Schools served", metadata: { help: "Separate with commas." } },
        firstPickup: { type: "text", label: "First pickup", metadata: { help: "Like 6:52 a.m." } },
        stops: {
          type: "textarea",
          label: "Stops",
          metadata: { help: "One stop per line, in order: time | place. Example: 6:52 a.m. | Maple Street and 3rd Avenue" },
        },
      },
    },
    weatherNote: { type: "textarea", label: "Bad weather note", metadata: { help: "What happens to buses on delay or snow days. Leave blank to hide it." } },
    officeName: { type: "text", label: "Office name", metadata: { help: "Leave blank to hide the contact card." } },
    officeHours: { type: "text", label: "Office hours" },
    officePhone: { type: "text", label: "Office phone" },
    officeEmail: { type: "text", label: "Office email" },
  },
  defaultProps: {
    heading: "Bus routes",
    headingLevel: "h2",
    intro: "Times are when the bus arrives. Please have your child at the stop 5 minutes early, and the driver won't wait longer than a minute.",
    findLabel: "Find my bus stop",
    findHref: "/transportation/find-my-stop",
    routes: [
      {
        number: "4",
        schools: "Alder Creek Elementary, Riverbend Middle",
        firstPickup: "6:58 a.m.",
        stops: "6:58 a.m. | Alder Creek Road and Fox Hollow Lane\n7:04 a.m. | Pinecrest Apartments, front entrance\n7:11 a.m. | Willow Street and 9th Avenue\n7:18 a.m. | Riverbend Middle School\n7:32 a.m. | Alder Creek Elementary",
      },
      {
        number: "7A",
        schools: "Riverbend High",
        firstPickup: "6:41 a.m.",
        stops: "6:41 a.m. | Northgate Park and Ride\n6:49 a.m. | Lakeview Drive and Cedar Court\n6:56 a.m. | Main Street and 14th Avenue\n7:08 a.m. | Riverbend High School, east loop",
      },
      {
        number: "12",
        schools: "Bridgeview Elementary, Westfield Middle",
        firstPickup: "7:02 a.m.",
        stops: "7:02 a.m. | Westfield Parkway and Orchard Road\n7:09 a.m. | Sunset Mobile Home Park\n7:15 a.m. | Bridge Street and River Road\n7:24 a.m. | Westfield Middle School\n7:40 a.m. | Bridgeview Elementary",
      },
      {
        number: "15",
        schools: "Northgate High, Harbor Academy",
        firstPickup: "6:45 a.m.",
        stops: "6:45 a.m. | Harbor Street and 2nd Avenue\n6:53 a.m. | Riverbend Library\n7:01 a.m. | Harbor Academy\n7:14 a.m. | Northgate High School",
      },
    ],
    weatherNote: "On two-hour delay days, every pickup is exactly two hours later. When roads are icy, some routes skip hilly stops and pick up at the nearest main road instead. We post route changes on the school status page by 5:30 a.m.",
    officeName: "Transportation Office",
    officeHours: "Monday–Friday, 6:00 a.m.–5:00 p.m.",
    officePhone: "555-0160",
    officeEmail: "transportation@riverbendusd.example.org",
  },
  render: ({ id, heading, headingLevel, intro, findLabel, findHref, routes, weatherNote, officeName, officeHours, officePhone, officeEmail }) => {
    const H = headingLevel || "h2";
    const Sub = lower[H] || "h3";
    const uid = id || "bus-routes";
    const list = (routes ?? []).filter((r) => r?.number || r?.schools);
    const hasAside = Boolean(weatherNote || officeName);

    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">
          {heading || intro || findLabel ? (
            <div className="flex flex-col gap-6 md:flex-row md:items-end md:justify-between md:gap-12">
              <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}
              </div>
              {findLabel ? (
                <a
                  href={findHref || "#"}
                  className="inline-flex min-h-11 shrink-0 items-center gap-2 self-start 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 md:self-auto"
                >
                  <Icon d={icons.search} className="size-5 shrink-0" />
                  {findLabel}
                </a>
              ) : null}
            </div>
          ) : null}

          <div className={`grid grid-cols-1 gap-10 ${hasAside ? "lg:grid-cols-3" : ""} ${heading || intro || findLabel ? "mt-10 sm:mt-12" : ""}`}>
            {list.length ? (
              <ul role="list" className={`space-y-3 ${hasAside ? "lg:col-span-2" : ""}`}>
                {list.map((r, i) => {
                  const stops = parseStops(r.stops);
                  return (
                    <li key={`${r.number}-${i}`} className="rounded-2xl ring-1 ring-neutral-200">
                      <div className="flex gap-4 p-4 sm:items-center sm:gap-5 sm:p-5">
                        <p className="flex size-14 shrink-0 flex-col items-center justify-center rounded-xl bg-indigo-700 text-white">
                          <span className="text-xs leading-none font-semibold tracking-wide uppercase opacity-90">Route</span>
                          <span className="mt-0.5 text-xl leading-none font-semibold tabular-nums">{r.number || "—"}</span>
                        </p>
                        <div className="flex min-w-0 flex-1 flex-col gap-1 sm:flex-row sm:items-center sm:justify-between sm:gap-6">
                          <Sub className="text-base leading-6 font-semibold text-pretty text-neutral-950">
                            <span className="sr-only">Route {r.number}: </span>
                            {r.schools || "Schools to be announced"}
                          </Sub>
                          {r.firstPickup ? (
                            <p className="flex shrink-0 items-center gap-1.5 text-sm text-neutral-600">
                              <Icon d={icons.clock} className="size-4 shrink-0 text-neutral-400" />
                              First pickup <span className="font-semibold text-neutral-950 tabular-nums">{r.firstPickup}</span>
                            </p>
                          ) : null}
                        </div>
                      </div>
                      {stops.length ? (
                        <details className="group border-t border-neutral-200">
                          <summary className="flex min-h-11 cursor-pointer list-none items-center justify-between gap-3 rounded-b-2xl px-4 py-2.5 text-sm font-semibold text-indigo-700 hover:bg-neutral-50 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-indigo-700 group-open:rounded-b-none sm:px-5 [&::-webkit-details-marker]:hidden">
                            <span>
                              <span className="group-open:hidden">Show</span>
                              <span className="hidden group-open:inline">Hide</span> all {stops.length} stops
                              <span className="sr-only"> on route {r.number}</span>
                            </span>
                            <Icon d={icons.chevron} className="size-5 shrink-0 transition group-open:rotate-180" />
                          </summary>
                          <ol role="list" className="px-4 pt-1 pb-4 sm:px-5">
                            {stops.map((s, j) => (
                              <li key={j} className="relative flex gap-4 py-2">
                                {j < stops.length - 1 ? <span aria-hidden="true" className="absolute top-5 -bottom-2 left-1.25 w-0.5 bg-indigo-100" /> : null}
                                <span aria-hidden="true" className="relative mt-1.5 size-3 shrink-0 rounded-full bg-white ring-2 ring-indigo-600" />
                                <p className="flex min-w-0 flex-col text-sm leading-6 sm:flex-row sm:gap-4">
                                  {s.time ? <span className="w-20 shrink-0 font-semibold text-neutral-950 tabular-nums">{s.time}</span> : null}
                                  <span className="text-pretty text-neutral-700">{s.place}</span>
                                </p>
                              </li>
                            ))}
                          </ol>
                        </details>
                      ) : null}
                    </li>
                  );
                })}
              </ul>
            ) : null}

            {hasAside ? (
              <div className={`min-w-0 space-y-6 self-start ${list.length ? "" : "lg:col-span-3"}`}>
                {weatherNote ? (
                  <div className="flex gap-3 rounded-2xl bg-indigo-50 p-5 ring-1 ring-indigo-100 sm:p-6">
                    <Icon d={icons.cloud} className="mt-0.5 size-5 shrink-0 text-indigo-700" />
                    <div className="min-w-0">
                      <p className="text-sm font-semibold text-indigo-950">Bad weather days</p>
                      <p className="mt-1 text-sm leading-6 text-pretty text-indigo-950">{weatherNote}</p>
                    </div>
                  </div>
                ) : null}
                {officeName ? (
                  <div className="rounded-2xl bg-neutral-50 p-5 ring-1 ring-neutral-200 sm:p-6">
                    <p className="text-base font-semibold text-neutral-950">{officeName}</p>
                    {officeHours ? <p className="mt-1 text-sm leading-6 text-neutral-600">{officeHours}</p> : null}
                    {officePhone || officeEmail ? (
                      <div className="mt-2 flex flex-col">
                        {officePhone ? (
                          <a href={`tel:${officePhone.replace(/[^\d+]/g, "")}`} className={`${contactLink} tabular-nums`}>
                            <Icon d={icons.phone} className="size-5 shrink-0 text-indigo-700" />
                            {officePhone}
                          </a>
                        ) : null}
                        {officeEmail ? (
                          <a href={`mailto:${officeEmail}`} className={`${contactLink} break-all`}>
                            <Icon d={icons.mail} className="size-5 shrink-0 text-indigo-700" />
                            {officeEmail}
                          </a>
                        ) : null}
                      </div>
                    ) : null}
                  </div>
                ) : null}
              </div>
            ) : null}
          </div>
        </div>
      </section>
    );
  },
};
```
