# Add the "Contact & Hours" block to this P1 project

Add a Puck component from P1 Blocks (https://p1-blocks.prolificdigital.io/blocks/contact-info) to this Pantheon Content Publisher (P1) Next.js project. Address, phone, email, opening hours and directions, with tel: and mailto: links built for you.

## Steps

1. Create `components/puck/contact-info-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 { contactInfoBlock } from "./components/puck/contact-info-block";`
3. Register it under `components` as `ContactInfoBlock: contactInfoBlock`.
4. Add `"ContactInfoBlock"` to the best-fitting entry in `categories` (this block's library category is "Civic & utility"). 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/contact-info-block.tsx`

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

/**
 * Contact Info — address, phone, email, opening hours and directions beside a building
 * photo or map image. Phone and email links are built for you.
 * Register: `ContactInfoBlock: contactInfoBlock` in puck.config.tsx.
 */

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

export type ContactInfoProps = {
  heading: string;
  headingLevel: Heading;
  intro: string;
  address: string;
  phone: string;
  email: string;
  hoursHeading: string;
  hours: { days: string; hours: string }[];
  directionsLabel: string;
  directionsHref: string;
  imageUrl: string;
  imageAlt: string;
};

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

const icons = {
  address:
    "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.745l-1.051.35a.5.5 0 0 0-.31.637 10.48 10.48 0 0 0 6.548 6.548.5.5 0 0 0 .637-.31l.35-1.05a1.5 1.5 0 0 1 1.745-1.021l2.31.513A1.5 1.5 0 0 1 18 15.352V16.5a1.5 1.5 0 0 1-1.5 1.5H15C7.82 18 2 12.18 2 5V3.5Z",
  email:
    "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-2H3ZM19 8.839l-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 }: { d: string }) {
  return (
    <span aria-hidden="true" className="grid size-10 shrink-0 place-items-center rounded-full bg-indigo-50 text-indigo-700 ring-1 ring-indigo-600/10 ring-inset">
      <svg viewBox="0 0 20 20" fill="currentColor" className="size-5">
        <path fillRule="evenodd" d={d} clipRule="evenodd" />
      </svg>
    </span>
  );
}

const linkClass =
  "inline-flex min-h-11 items-center rounded font-semibold text-neutral-950 underline decoration-neutral-300 underline-offset-4 hover:decoration-indigo-600 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600";

export const contactInfoBlock: ComponentConfig<ContactInfoProps> = {
  label: "Contact Info",
  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" },
    address: { type: "textarea", label: "Address", metadata: { help: "One line per row, exactly as it should appear." } },
    phone: { type: "text", label: "Phone", metadata: { help: "Shown as typed. The tap-to-call link is built from the digits." } },
    email: { type: "text", label: "Email" },
    hoursHeading: { type: "text", label: "Hours heading", metadata: { help: "Leave blank to hide the hours card." } },
    hours: {
      type: "array",
      label: "Hours",
      min: 0,
      max: 10,
      getItemSummary: (item) => item?.days || "Days",
      defaultItemProps: { days: "Saturday", hours: "9:00 a.m. – 5:00 p.m." },
      arrayFields: {
        days: { type: "text", label: "Days", metadata: { help: "A day or range, like Monday – Friday." } },
        hours: { type: "text", label: "Hours", metadata: { help: "Free text, like 8:00 a.m. – 6:00 p.m. or Closed." } },
      },
    },
    directionsLabel: { type: "text", label: "Directions link text", metadata: { help: "Leave blank to hide it." } },
    directionsHref: { type: "text", label: "Directions link", metadata: { help: "Paste a map link, like a Google Maps or Apple Maps share URL." } },
    imageUrl: { type: "text", label: "Image URL", metadata: { help: "A building photo or a static map image. Leave blank to hide it." } },
    imageAlt: { type: "text", label: "Image alt text", metadata: { help: "Describe the photo for screen reader users. Leave blank only if it's purely decorative." } },
  },
  defaultProps: {
    heading: "Visit us",
    headingLevel: "h2",
    intro: "The Parks & Recreation main office handles program registration, facility rentals and permits. Free parking is available in the east lot.",
    address: "Oak Hollow Community Center\n1200 Meadowbrook Avenue\nSpringfield, IL 62704",
    phone: "(217) 555-0142",
    email: "parks@springfield.gov",
    hoursHeading: "Office hours",
    hours: [
      { days: "Monday – Friday", hours: "8:00 a.m. – 6:00 p.m." },
      { days: "Saturday", hours: "9:00 a.m. – 1:00 p.m." },
      { days: "Sunday", hours: "Closed" },
    ],
    directionsLabel: "Get directions",
    directionsHref: "https://maps.google.com/?q=1200+Meadowbrook+Avenue+Springfield+IL",
    imageUrl: "https://picsum.photos/seed/townhall/1200/900",
    imageAlt: "The brick front entrance of the Oak Hollow Community Center",
  },
  render: ({ heading, headingLevel, intro, address, phone, email, hoursHeading, hours, directionsLabel, directionsHref, imageUrl, imageAlt }) => {
    const H = headingLevel || "h2";
    const Sub = childLevel[H] ?? "h3";
    const lines = (address || "").split("\n").map((l) => l.trim()).filter(Boolean);
    const tel = (phone || "").replace(/[^\d+]/g, "");
    const mail = (email || "").trim();
    const rows = (hours ?? []).filter((r) => r?.days || r?.hours);
    const showHours = Boolean(hoursHeading) && rows.length > 0;

    const hoursCard = showHours ? (
      <div className="rounded-2xl bg-white p-6 shadow-lg ring-1 ring-neutral-900/5 sm:p-8">
        <Sub className="flex items-center gap-2 text-sm font-semibold tracking-widest text-neutral-950 uppercase">
          <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="size-5 text-indigo-600">
            <path fillRule="evenodd" d="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" clipRule="evenodd" />
          </svg>
          {hoursHeading}
        </Sub>
        <dl className="mt-4 divide-y divide-dashed divide-neutral-200 text-base leading-7">
          {rows.map((row, i) => (
            <div key={`${row.days}-${i}`} className="flex flex-wrap items-baseline justify-between gap-x-6 gap-y-0.5 py-3">
              <dt className="text-neutral-600">{row.days}</dt>
              <dd className="font-medium text-neutral-950 tabular-nums">{row.hours}</dd>
            </div>
          ))}
        </dl>
      </div>
    ) : null;

    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 grid max-w-7xl grid-cols-1 gap-12 lg:grid-cols-12 lg:gap-16">
          <div className="lg:col-span-5">
            {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}
            {lines.length || tel || mail ? (
              <dl className="mt-10 space-y-6">
                {lines.length ? (
                  <div className="flex gap-4">
                    <dt>
                      <span className="sr-only">Address</span>
                      <Icon d={icons.address} />
                    </dt>
                    <dd className="pt-2 text-base leading-7 text-neutral-950">
                      <address className="not-italic">
                        {lines.map((line, i) => (
                          <span key={i} className={i === 0 ? "block font-semibold" : "block text-neutral-600"}>
                            {line}
                          </span>
                        ))}
                      </address>
                    </dd>
                  </div>
                ) : null}
                {tel ? (
                  <div className="flex items-center gap-4">
                    <dt>
                      <span className="sr-only">Phone</span>
                      <Icon d={icons.phone} />
                    </dt>
                    <dd>
                      <a href={`tel:${tel}`} className={`${linkClass} tabular-nums`}>
                        {phone}
                      </a>
                    </dd>
                  </div>
                ) : null}
                {mail ? (
                  <div className="flex items-center gap-4">
                    <dt>
                      <span className="sr-only">Email</span>
                      <Icon d={icons.email} />
                    </dt>
                    <dd className="min-w-0">
                      <a href={`mailto:${mail}`} className={`${linkClass} break-all`}>
                        {mail}
                      </a>
                    </dd>
                  </div>
                ) : null}
              </dl>
            ) : null}
            {directionsLabel ? (
              <a
                href={directionsHref || "#"}
                className="group mt-10 inline-flex min-h-11 items-center justify-center gap-2 rounded-lg bg-indigo-600 px-5 py-3 text-base font-semibold text-white shadow-sm transition hover:bg-indigo-700 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600"
              >
                <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="size-5">
                  <path fillRule="evenodd" d={icons.address} clipRule="evenodd" />
                </svg>
                {directionsLabel}
              </a>
            ) : null}
          </div>
          {imageUrl || hoursCard ? (
            <div className="lg:col-span-7">
              {imageUrl ? (
                <img
                  src={imageUrl}
                  alt={imageAlt || ""}
                  className="aspect-[4/3] w-full rounded-2xl bg-neutral-100 object-cover shadow-xl ring-1 ring-neutral-900/5"
                />
              ) : null}
              {hoursCard ? (
                <div className={imageUrl ? "relative mx-4 -mt-16 sm:mx-8 sm:-mt-20 lg:mr-auto lg:ml-10 lg:max-w-md" : "lg:max-w-md"}>{hoursCard}</div>
              ) : null}
            </div>
          ) : null}
        </div>
      </section>
    );
  },
};
```
