# Add the "Open Data Catalog" block to this P1 project

Add a Puck component from P1 Blocks (https://p1-blocks.prolificdigital.io/blocks/open-data-catalog) to this Pantheon Content Publisher (P1) Next.js project. A table of public datasets with department, update frequency, last updated date and download formats.

## Steps

1. Create `components/puck/open-data-catalog-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 { openDataCatalogBlock } from "./components/puck/open-data-catalog-block";`
3. Register it under `components` as `OpenDataCatalogBlock: openDataCatalogBlock`.
4. Add `"OpenDataCatalogBlock"` 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/open-data-catalog-block.tsx`

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

/**
 * Open Data Catalog — a table of public datasets with department, update frequency, last
 * updated date and available formats (CSV, JSON, API, shown as text badges). The table
 * scrolls sideways inside its own focusable region on small screens.
 * Register: `OpenDataCatalogBlock: openDataCatalogBlock` in puck.config.tsx.
 */

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

export type OpenDataCatalogProps = {
  eyebrow: string;
  heading: string;
  headingLevel: Heading;
  intro: string;
  caption: string;
  datasets: {
    title: string;
    description: string;
    department: string;
    frequency: string;
    lastUpdated: string;
    formats: string;
    href: string;
  }[];
  portalLabel: string;
  portalHref: string;
  requestLabel: string;
  requestHref: string;
  license: string;
};

const focusRing = "focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-700";

const formatStyle = (f: string) =>
  /^api$/i.test(f)
    ? "bg-indigo-700 text-white ring-indigo-700"
    : /^(geojson|shp|kml|map)$/i.test(f)
      ? "bg-indigo-50 text-indigo-900 ring-indigo-600/25"
      : "bg-white text-neutral-800 ring-neutral-300";

export const openDataCatalogBlock: ComponentConfig<OpenDataCatalogProps> = {
  label: "Open Data Catalog",
  fields: {
    eyebrow: { type: "text", label: "Eyebrow", metadata: { help: "Small line above the heading, like Open data. Leave blank to hide it." } },
    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." } },
    caption: { type: "text", label: "Table caption", metadata: { help: "Names the table for screen readers, like Featured datasets. Also shown above the table." } },
    datasets: {
      type: "array",
      label: "Datasets",
      min: 1,
      max: 40,
      getItemSummary: (item) => item?.title || "Dataset",
      defaultItemProps: { title: "New dataset", description: "", department: "", frequency: "", lastUpdated: "", formats: "CSV", href: "" },
      arrayFields: {
        title: { type: "text", label: "Dataset name" },
        description: { type: "textarea", label: "Description", metadata: { help: "One short sentence on what's in it. Leave blank to hide it." } },
        department: { type: "text", label: "Department" },
        frequency: { type: "text", label: "Update frequency", metadata: { help: "Like Daily, Weekly, Monthly or Annually." } },
        lastUpdated: { type: "text", label: "Last updated", metadata: { help: "Like Oct 7, 2026." } },
        formats: { type: "text", label: "Formats", metadata: { help: "Separate with commas, like CSV, JSON, API. API gets a filled badge so developers can spot it." } },
        href: { type: "text", label: "Dataset link", metadata: { help: "The dataset page on your open data portal." } },
      },
    },
    portalLabel: { type: "text", label: "Portal link text", metadata: { help: "Leave blank to hide the link." } },
    portalHref: { type: "text", label: "Portal link" },
    requestLabel: { type: "text", label: "Request link text", metadata: { help: "Like Request a dataset. Leave blank to hide the link." } },
    requestHref: { type: "text", label: "Request link" },
    license: { type: "textarea", label: "License note", metadata: { help: "How people may reuse the data. Leave blank to hide it." } },
  },
  defaultProps: {
    eyebrow: "Open data",
    heading: "Explore city data",
    headingLevel: "h2",
    intro: "Millbrook publishes the data behind its decisions so residents, reporters and researchers can check our work. Download it, map it, or connect to it live.",
    caption: "Featured datasets",
    datasets: [
      {
        title: "311 service requests",
        description: "Every request since 2019, with type, location, status and days to close.",
        department: "Customer Service",
        frequency: "Daily",
        lastUpdated: "Oct 8, 2026",
        formats: "CSV, JSON, API",
        href: "/data/311-requests",
      },
      {
        title: "Building permits issued",
        description: "Permit type, address, project value and contractor for each permit.",
        department: "Planning & Development",
        frequency: "Weekly",
        lastUpdated: "Oct 5, 2026",
        formats: "CSV, JSON, API",
        href: "/data/building-permits",
      },
      {
        title: "City budget and spending",
        description: "Adopted budget and actual spending by department and fund.",
        department: "Finance",
        frequency: "Monthly",
        lastUpdated: "Sep 30, 2026",
        formats: "CSV, XLSX",
        href: "/data/budget",
      },
      {
        title: "Park boundaries and trails",
        description: "Outlines of every city park and trail centerlines.",
        department: "Parks & Recreation",
        frequency: "Annually",
        lastUpdated: "Mar 12, 2026",
        formats: "GeoJSON, SHP",
        href: "/data/parks",
      },
      {
        title: "Water quality test results",
        description: "Lab results for lead, copper and bacteria from sampling sites.",
        department: "Public Utilities",
        frequency: "Monthly",
        lastUpdated: "Sep 28, 2026",
        formats: "CSV, PDF",
        href: "/data/water-quality",
      },
    ],
    portalLabel: "Browse all 140 datasets",
    portalHref: "/data",
    requestLabel: "Request a dataset",
    requestHref: "/data/request",
    license: "All datasets are free to use under the Open Data Commons Public Domain Dedication and License (PDDL). Please credit the City of Millbrook.",
  },
  render: ({ id, eyebrow, heading, headingLevel, intro, caption, datasets, portalLabel, portalHref, requestLabel, requestHref, license }) => {
    const H = headingLevel || "h2";
    const baseId = id || "open-data-catalog";
    const capId = `${baseId}-caption`;
    const list = (datasets ?? []).filter((d) => d?.title);
    const hasHeader = Boolean(eyebrow || heading || intro);
    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">
          {hasHeader || portalLabel ? (
            <div className="flex flex-col gap-6 lg:flex-row lg:items-end lg:justify-between lg:gap-16">
              {hasHeader ? (
                <div className="max-w-2xl">
                  {eyebrow ? <p className="font-mono text-sm font-semibold tracking-wide text-indigo-700">{eyebrow}</p> : null}
                  {heading ? <H className={`text-3xl font-semibold tracking-tight text-balance text-neutral-950 sm:text-4xl ${eyebrow ? "mt-2" : ""}`}>{heading}</H> : null}
                  {intro ? <p className="mt-4 text-lg leading-8 text-pretty text-neutral-600">{intro}</p> : null}
                </div>
              ) : null}
              {portalLabel ? (
                <a
                  href={portalHref || "#"}
                  className={`inline-flex min-h-12 shrink-0 items-center justify-center gap-2 self-start rounded-lg bg-neutral-950 px-5 text-base font-semibold text-white shadow-sm transition hover:bg-neutral-800 lg:self-auto ${focusRing}`}
                >
                  {portalLabel}
                  <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="size-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}
            </div>
          ) : null}

          {list.length ? (
            <div className={`overflow-hidden rounded-2xl ring-1 ring-neutral-200 ${hasHeader || portalLabel ? "mt-10 sm:mt-12" : ""}`}>
              <div role="region" aria-labelledby={capId} tabIndex={0} className={`relative overflow-x-auto ${focusRing} focus-visible:-outline-offset-2`}>
                <table className="w-full min-w-3xl text-left text-sm">
                  <caption id={capId} className="border-b border-neutral-200 bg-neutral-50 px-5 py-3 text-left text-sm font-semibold text-neutral-950 sm:px-6">
                    {caption || "Datasets"}
                    <span className="font-normal text-neutral-600">
                      {" "}
                      ({list.length} {list.length === 1 ? "dataset" : "datasets"})
                    </span>
                  </caption>
                  <thead className="bg-neutral-50">
                    <tr className="text-xs tracking-wide text-neutral-600 uppercase">
                      <th scope="col" className="w-2/5 px-5 py-3 font-semibold sm:px-6">Dataset</th>
                      <th scope="col" className="px-3 py-3 font-semibold">Department</th>
                      <th scope="col" className="px-3 py-3 font-semibold">Frequency</th>
                      <th scope="col" className="px-3 py-3 font-semibold">Last updated</th>
                      <th scope="col" className="px-5 py-3 font-semibold sm:px-6">Formats</th>
                    </tr>
                  </thead>
                  <tbody className="divide-y divide-neutral-200 bg-white">
                    {list.map((d, i) => {
                      const formats = (d.formats ?? "")
                        .split(",")
                        .map((f) => f.trim())
                        .filter(Boolean);
                      return (
                        <tr key={`${d.title}-${i}`} className="align-top">
                          <th scope="row" className="px-5 py-4 font-normal sm:px-6">
                            {d.href ? (
                              <a href={d.href} className={`-my-2.5 inline-flex min-h-11 items-center rounded text-base font-semibold text-indigo-700 underline decoration-indigo-300 underline-offset-4 hover:decoration-indigo-700 ${focusRing}`}>
                                {d.title}
                              </a>
                            ) : (
                              <span className="text-base font-semibold text-neutral-950">{d.title}</span>
                            )}
                            {d.description ? <p className="mt-1 max-w-md leading-6 text-pretty text-neutral-600">{d.description}</p> : null}
                          </th>
                          <td className="px-3 py-4 text-neutral-700">{d.department}</td>
                          <td className="px-3 py-4 whitespace-nowrap text-neutral-700">{d.frequency}</td>
                          <td className="px-3 py-4 whitespace-nowrap text-neutral-700 tabular-nums">{d.lastUpdated}</td>
                          <td className="px-5 py-4 sm:px-6">
                            {formats.length ? (
                              <ul role="list" aria-label="Formats" className="flex flex-wrap gap-1.5">
                                {formats.map((f, j) => (
                                  <li key={j} className={`rounded px-1.5 py-0.5 font-mono text-xs font-semibold tracking-wide uppercase ring-1 ring-inset ${formatStyle(f)}`}>
                                    {f}
                                  </li>
                                ))}
                              </ul>
                            ) : null}
                          </td>
                        </tr>
                      );
                    })}
                  </tbody>
                </table>
              </div>
            </div>
          ) : null}

          {requestLabel || license ? (
            <div className="mt-6 flex flex-col gap-3 md:flex-row md:items-start md:justify-between md:gap-10">
              {license ? <p className="max-w-2xl text-sm leading-6 text-pretty text-neutral-600">{license}</p> : null}
              {requestLabel ? (
                <a
                  href={requestHref || "#"}
                  className={`inline-flex min-h-11 shrink-0 items-center gap-2 rounded text-sm font-semibold text-indigo-700 underline decoration-indigo-300 underline-offset-4 hover:decoration-indigo-700 ${focusRing}`}
                >
                  {requestLabel}
                </a>
              ) : null}
            </div>
          ) : null}
        </div>
      </section>
    );
  },
};
```
