# Add the "Feature Grid" block to this P1 project

Add a Puck component from P1 Blocks (https://p1-blocks.prolificdigital.io/blocks/feature-grid) to this Pantheon Content Publisher (P1) Next.js project. Programs, services or benefits as an icon grid in two, three or four columns.

## Steps

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

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

/**
 * Feature Grid — section heading and intro over a ruled grid of features, each with a
 * built-in icon, short description and optional link. Two, three or four columns.
 * Register: `FeatureGridBlock: featureGridBlock` in puck.config.tsx.
 */

type Heading = "h1" | "h2" | "h3" | "h4";
type IconName = "heart" | "leaf" | "users" | "calendar" | "shield" | "book" | "map-pin" | "sparkles";

export type FeatureGridProps = {
  eyebrow: string;
  heading: string;
  headingLevel: Heading;
  intro: string;
  columns: "2" | "3" | "4";
  features: { icon: IconName; title: string; description: string; linkLabel: string; linkHref: string }[];
};

const iconPaths: Record<IconName, string[]> = {
  heart: ["M21 8.25c0-2.485-2.099-4.5-4.688-4.5-1.935 0-3.597 1.126-4.312 2.733-.715-1.607-2.377-2.733-4.313-2.733C5.1 3.75 3 5.765 3 8.25c0 7.22 9 12 9 12s9-4.78 9-12Z"],
  leaf: ["M4.5 19.5c0-8.284 6.716-15 15-15 0 8.284-6.716 15-15 15Z", "M4.5 19.5 13.5 10.5"],
  users: [
    "M15 19.128a9.38 9.38 0 0 0 2.625.372 9.337 9.337 0 0 0 4.121-.952 4.125 4.125 0 0 0-7.533-2.493M15 19.128v-.003c0-1.113-.285-2.16-.786-3.07M15 19.128v.106A12.318 12.318 0 0 1 8.624 21c-2.331 0-4.512-.645-6.374-1.766l-.001-.109a6.375 6.375 0 0 1 11.964-3.07M12 6.375a3.375 3.375 0 1 1-6.75 0 3.375 3.375 0 0 1 6.75 0Zm8.25 2.25a2.625 2.625 0 1 1-5.25 0 2.625 2.625 0 0 1 5.25 0Z",
  ],
  calendar: [
    "M6.75 3v2.25M17.25 3v2.25M3 18.75V7.5a2.25 2.25 0 0 1 2.25-2.25h13.5A2.25 2.25 0 0 1 21 7.5v11.25m-18 0A2.25 2.25 0 0 0 5.25 21h13.5A2.25 2.25 0 0 0 21 18.75m-18 0v-7.5A2.25 2.25 0 0 1 5.25 9h13.5A2.25 2.25 0 0 1 21 11.25v7.5",
  ],
  shield: [
    "M9 12.75 11.25 15 15 9.75m-3-7.036A11.959 11.959 0 0 1 3.598 6 11.99 11.99 0 0 0 3 9.749c0 5.592 3.824 10.29 9 11.623 5.176-1.332 9-6.03 9-11.622 0-1.31-.21-2.571-.598-3.751h-.152c-3.196 0-6.1-1.248-8.25-3.285Z",
  ],
  book: [
    "M12 6.042A8.967 8.967 0 0 0 6 3.75c-1.052 0-2.062.18-3 .512v14.25A8.987 8.987 0 0 1 6 18c2.305 0 4.408.867 6 2.292m0-14.25a8.966 8.966 0 0 1 6-2.292c1.052 0 2.062.18 3 .512v14.25A8.987 8.987 0 0 0 18 18a8.967 8.967 0 0 0-6 2.292m0-14.25v14.25",
  ],
  "map-pin": ["M15 10.5a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z", "M19.5 10.5c0 7.142-7.5 11.25-7.5 11.25S4.5 17.642 4.5 10.5a7.5 7.5 0 1 1 15 0Z"],
  sparkles: [
    "M9.813 15.904 9 18.75l-.813-2.846a4.5 4.5 0 0 0-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 0 0 3.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 0 0 3.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 0 0-3.09 3.09ZM18.259 8.715 18 9.75l-.259-1.035a3.375 3.375 0 0 0-2.455-2.456L14.25 6l1.036-.259a3.375 3.375 0 0 0 2.455-2.456L18 2.25l.259 1.035a3.375 3.375 0 0 0 2.456 2.456L21.75 6l-1.035.259a3.375 3.375 0 0 0-2.456 2.456ZM16.894 20.567 16.5 21.75l-.394-1.183a2.25 2.25 0 0 0-1.423-1.423L13.5 18.75l1.183-.394a2.25 2.25 0 0 0 1.423-1.423l.394-1.183.394 1.183a2.25 2.25 0 0 0 1.423 1.423l1.183.394-1.183.394a2.25 2.25 0 0 0-1.423 1.423Z",
  ],
};

const iconOptions: { label: string; value: IconName }[] = [
  { label: "Heart", value: "heart" },
  { label: "Leaf", value: "leaf" },
  { label: "People", value: "users" },
  { label: "Calendar", value: "calendar" },
  { label: "Shield", value: "shield" },
  { label: "Book", value: "book" },
  { label: "Map pin", value: "map-pin" },
  { label: "Sparkles", value: "sparkles" },
];

const gridCols: Record<FeatureGridProps["columns"], string> = {
  "2": "sm:grid-cols-2",
  "3": "sm:grid-cols-2 lg:grid-cols-3",
  "4": "sm:grid-cols-2 lg:grid-cols-4",
};

const childHeading: Record<Heading, "h2" | "h3" | "h4" | "h5"> = { h1: "h2", h2: "h3", h3: "h4", h4: "h5" };

export const featureGridBlock: ComponentConfig<FeatureGridProps> = {
  label: "Feature Grid",
  fields: {
    eyebrow: { type: "text", label: "Eyebrow", metadata: { help: "Small line above the heading. 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. Feature titles use the next level down." },
    },
    intro: { type: "textarea", label: "Intro" },
    columns: {
      type: "select",
      label: "Columns",
      options: [
        { label: "2 columns", value: "2" },
        { label: "3 columns", value: "3" },
        { label: "4 columns", value: "4" },
      ],
      metadata: { help: "Columns on wide screens. Phones always show one column; tablets show two." },
    },
    features: {
      type: "array",
      label: "Features",
      min: 1,
      max: 12,
      getItemSummary: (item) => item?.title?.slice(0, 48) || "Feature",
      defaultItemProps: { icon: "sparkles", title: "New feature", description: "One or two sentences on why this matters.", linkLabel: "", linkHref: "" },
      arrayFields: {
        icon: { type: "select", label: "Icon", options: iconOptions },
        title: { type: "text", label: "Title" },
        description: { type: "textarea", label: "Description" },
        linkLabel: { type: "text", label: "Link text", metadata: { help: "Say where it goes, like “See volunteer shifts”. Leave blank to hide the link." } },
        linkHref: { type: "text", label: "Link" },
      },
    },
  },
  defaultProps: {
    eyebrow: "How we help",
    heading: "Everything a growing neighborhood needs",
    headingLevel: "h2",
    intro: "Our programs meet people where they are, from a first library card to a seat on a park advisory board.",
    columns: "3",
    features: [
      {
        icon: "leaf",
        title: "Community gardens",
        description: "Twenty-two shared plots with free seeds, tools and Saturday workshops led by master gardeners.",
        linkLabel: "Reserve a garden plot",
        linkHref: "/gardens",
      },
      {
        icon: "book",
        title: "Free tutoring",
        description: "Trained volunteers help K–12 students with reading and math four afternoons a week, no sign-up required.",
        linkLabel: "See tutoring hours",
        linkHref: "/tutoring",
      },
      {
        icon: "users",
        title: "Volunteer crews",
        description: "Join a weekend crew for trail cleanups, mural projects and neighborhood repair days.",
        linkLabel: "Find a volunteer shift",
        linkHref: "/volunteer",
      },
      {
        icon: "calendar",
        title: "Seasonal events",
        description: "Concerts, night markets and cultural festivals that bring thousands of neighbors together every year.",
        linkLabel: "",
        linkHref: "",
      },
      {
        icon: "heart",
        title: "Senior wellness",
        description: "Low-impact fitness, health screenings and social hours designed with and for older adults.",
        linkLabel: "",
        linkHref: "",
      },
      {
        icon: "map-pin",
        title: "Parks within reach",
        description: "Ninety percent of residents live within a ten-minute walk of a park. We're working on the last ten.",
        linkLabel: "",
        linkHref: "",
      },
    ],
  },
  render: ({ eyebrow, heading, headingLevel, intro, columns, features }) => {
    const H = headingLevel || "h2";
    const Item = childHeading[H] ?? "h3";
    const list = (features ?? []).filter((f) => f?.title || f?.description);
    const cols = gridCols[columns] ?? gridCols["3"];
    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 ? (
            <div className="max-w-2xl">
              {eyebrow ? <p className="text-sm font-semibold tracking-wide text-indigo-700 uppercase">{eyebrow}</p> : null}
              {heading ? (
                <H className={`${eyebrow ? "mt-3" : ""} 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}

          {list.length > 0 ? (
            <ul role="list" className={`${hasHeader ? "mt-12 sm:mt-16" : ""} grid grid-cols-1 gap-x-8 gap-y-10 sm:gap-y-12 ${cols}`}>
              {list.map((feature, i) => {
                const paths = iconPaths[feature.icon] ?? iconPaths.sparkles;
                return (
                  <li key={`${feature.title}-${i}`} className="flex flex-col border-t border-neutral-200 pt-6">
                    <span aria-hidden="true" className="grid size-11 place-items-center rounded-xl bg-indigo-50 text-indigo-700 ring-1 ring-indigo-600/10 ring-inset">
                      <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={1.5} strokeLinecap="round" strokeLinejoin="round" className="size-6">
                        {paths.map((d, j) => (
                          <path key={j} d={d} />
                        ))}
                      </svg>
                    </span>
                    {feature.title ? <Item className="mt-5 text-lg font-semibold text-neutral-950">{feature.title}</Item> : null}
                    {feature.description ? <p className="mt-2 flex-auto text-base leading-7 text-pretty text-neutral-600">{feature.description}</p> : null}
                    {feature.linkLabel ? (
                      <p className="mt-4">
                        <a
                          href={feature.linkHref || "#"}
                          className="group inline-flex min-h-11 items-center gap-1.5 rounded-sm text-sm font-semibold text-indigo-700 hover:text-indigo-900 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600"
                        >
                          {feature.linkLabel}
                          <svg aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" className="size-4 transition group-hover:translate-x-0.5">
                            <path fillRule="evenodd" d="M2 8a.75.75 0 0 1 .75-.75h8.69L8.22 4.03a.75.75 0 0 1 1.06-1.06l4.5 4.5a.75.75 0 0 1 0 1.06l-4.5 4.5a.75.75 0 0 1-1.06-1.06l3.22-3.22H2.75A.75.75 0 0 1 2 8Z" clipRule="evenodd" />
                          </svg>
                        </a>
                      </p>
                    ) : null}
                  </li>
                );
              })}
            </ul>
          ) : null}
        </div>
      </section>
    );
  },
};
```
