# Add the "Grant Opportunities" block to this P1 project

Add a Puck component from P1 Blocks (https://p1-blocks.prolificdigital.io/blocks/grant-opportunities) to this Pantheon Content Publisher (P1) Next.js project. Open funding cycles sorted by deadline, with focus area, award range, labeled cycle status, eligibility and RFP links.

## Steps

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

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

// spec: status-colors

/**
 * Grant Opportunities — open funding cycles with focus area, award range, deadline,
 * a labeled cycle status, eligibility and apply/RFP links, sorted soonest deadline first.
 * Register: `GrantOpportunitiesBlock: grantOpportunitiesBlock` in puck.config.tsx.
 */

type Heading = "h1" | "h2" | "h3" | "h4";
type Status = "open" | "soon" | "closed";

type Opportunity = {
  name: string;
  focusArea: string;
  awardRange: string;
  deadlineIso: string;
  deadline: string;
  status: Status;
  eligibility: string;
  applyLabel: string;
  applyHref: string;
  rfpLabel: string;
  rfpHref: string;
};

export type GrantOpportunitiesProps = {
  eyebrow: string;
  heading: string;
  headingLevel: Heading;
  intro: string;
  opportunities: Opportunity[];
  footnote: string;
  ctaLabel: string;
  ctaHref: string;
};

const childHeading: Record<Heading, "h2" | "h3" | "h4" | "h5"> = { h1: "h2", h2: "h3", h3: "h4", h4: "h5" };
const focusRing = "focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600";

const isoPattern = /^\d{4}-\d{2}-\d{2}$/;
const longDate = new Intl.DateTimeFormat("en-US", { month: "long", day: "numeric", year: "numeric", timeZone: "UTC" });
const monthShort = new Intl.DateTimeFormat("en-US", { month: "short", timeZone: "UTC" });
const parseIso = (iso: string) => {
  const d = new Date(`${iso}T00:00:00Z`);
  return Number.isNaN(d.getTime()) ? null : d;
};

const statusMeta: Record<Status, { label: string; pill: string; dot: string }> = {
  open: { label: "Open", pill: "bg-emerald-50 text-emerald-800 ring-emerald-600/25", dot: "bg-emerald-600" },
  soon: { label: "Opening soon", pill: "bg-amber-50 text-amber-900 ring-amber-600/30", dot: "bg-amber-500" },
  closed: { label: "Closed", pill: "bg-neutral-100 text-neutral-700 ring-neutral-500/25", dot: "bg-neutral-400" },
};

const 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";

export const grantOpportunitiesBlock: ComponentConfig<GrantOpportunitiesProps> = {
  label: "Grant Opportunities",
  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." },
    },
    intro: { type: "textarea", label: "Intro" },
    opportunities: {
      type: "array",
      label: "Opportunities",
      min: 1,
      max: 20,
      getItemSummary: (item) => [item?.name, item?.deadlineIso].filter(Boolean).join(" · ") || "Opportunity",
      defaultItemProps: {
        name: "New grant program",
        focusArea: "Community",
        awardRange: "$10,000–$25,000",
        deadlineIso: "2027-03-01",
        deadline: "",
        status: "soon",
        eligibility: "501(c)(3) nonprofits serving Harlow County",
        applyLabel: "Apply",
        applyHref: "/grants/apply",
        rfpLabel: "Read the RFP",
        rfpHref: "/grants/rfp.pdf",
      },
      arrayFields: {
        name: { type: "text", label: "Program name" },
        focusArea: { type: "text", label: "Focus area" },
        awardRange: { type: "text", label: "Award range", metadata: { help: "As it should appear, such as $10,000–$50,000." } },
        deadlineIso: { type: "text", label: "Deadline date (YYYY-MM-DD)", metadata: { help: "Sorts the list soonest first and is read by calendars and screen readers. Items without a date go last." } },
        deadline: { type: "text", label: "Deadline text (optional)", metadata: { help: "Overrides the displayed date, such as Rolling or March 1 at 5 p.m. Leave blank to show the date above." } },
        status: {
          type: "select",
          label: "Cycle status",
          options: [
            { label: "Open", value: "open" },
            { label: "Opening soon", value: "soon" },
            { label: "Closed", value: "closed" },
          ],
          metadata: { help: "Shown as a labeled badge. Closed cycles hide the apply link." },
        },
        eligibility: { type: "textarea", label: "Eligibility summary", metadata: { help: "One or two sentences. Link the full criteria from the RFP." } },
        applyLabel: { type: "text", label: "Apply link text", metadata: { help: "Leave blank to hide the button." } },
        applyHref: { type: "text", label: "Apply link" },
        rfpLabel: { type: "text", label: "RFP link text", metadata: { help: "Leave blank to hide the link." } },
        rfpHref: { type: "text", label: "RFP link", metadata: { help: "Usually a PDF in your media library." } },
      },
    },
    footnote: { type: "textarea", label: "Footnote", metadata: { help: "Small print under the list. Leave blank to hide it." } },
    ctaLabel: { type: "text", label: "Button text", metadata: { help: "Leave blank to hide the button." } },
    ctaHref: { type: "text", label: "Button link" },
  },
  defaultProps: {
    eyebrow: "Funding opportunities",
    heading: "Open grant cycles",
    headingLevel: "h2",
    intro: "Harlow Community Foundation funds nonprofits, schools and public agencies working in Harlow County. Read the request for proposals before you apply, and call a program officer if you're unsure which cycle fits.",
    opportunities: [
      {
        name: "Thriving Neighborhoods Fund",
        focusArea: "Housing & neighborhoods",
        awardRange: "$25,000–$75,000",
        deadlineIso: "2026-11-14",
        deadline: "",
        status: "open",
        eligibility: "501(c)(3) organizations and resident associations with a fiscal sponsor, working in one of the county's twelve priority census tracts.",
        applyLabel: "Start a letter of inquiry",
        applyHref: "/grants/apply/thriving-neighborhoods",
        rfpLabel: "Read the RFP (PDF)",
        rfpHref: "/files/rfp-thriving-neighborhoods-2027.pdf",
      },
      {
        name: "Early Learning Initiative",
        focusArea: "Education",
        awardRange: "$10,000–$40,000",
        deadlineIso: "2027-01-30",
        deadline: "",
        status: "soon",
        eligibility: "Licensed child care providers, Head Start partners and nonprofits serving children from birth to age five. Applications open December 1.",
        applyLabel: "Get notified",
        applyHref: "/grants/early-learning",
        rfpLabel: "Preview the RFP (PDF)",
        rfpHref: "/files/rfp-early-learning-2027.pdf",
      },
      {
        name: "Arts Access Grants",
        focusArea: "Arts & culture",
        awardRange: "$2,500–$10,000",
        deadlineIso: "2026-12-05",
        deadline: "",
        status: "open",
        eligibility: "Arts organizations with budgets under $1 million offering free or low-cost programs to Harlow County residents.",
        applyLabel: "Apply",
        applyHref: "/grants/apply/arts-access",
        rfpLabel: "Guidelines (PDF)",
        rfpHref: "/files/arts-access-guidelines.pdf",
      },
      {
        name: "Capacity Building Grants",
        focusArea: "Nonprofit strength",
        awardRange: "Up to $15,000",
        deadlineIso: "2026-09-12",
        deadline: "",
        status: "closed",
        eligibility: "Current or past Harlow grantees investing in strategic planning, technology, financial systems or leadership transitions.",
        applyLabel: "Apply",
        applyHref: "/grants/apply/capacity",
        rfpLabel: "2026 guidelines (PDF)",
        rfpHref: "/files/capacity-guidelines-2026.pdf",
      },
    ],
    footnote: "Award ranges are sample figures. All deadlines are 5 p.m. Eastern. We do not fund individuals, political campaigns or religious instruction.",
    ctaLabel: "Talk to a program officer",
    ctaHref: "/grants/contact",
  },
  render: ({ eyebrow, heading, headingLevel, intro, opportunities, footnote, ctaLabel, ctaHref }) => {
    const H = headingLevel || "h2";
    const Sub = childHeading[H] ?? "h3";
    const list = (opportunities ?? [])
      .filter((o) => o?.name)
      .map((o, i) => ({ ...o, order: i, iso: isoPattern.test((o.deadlineIso || "").trim()) ? o.deadlineIso.trim() : "" }))
      .sort((a, b) => {
        if (a.iso && b.iso) return a.iso < b.iso ? -1 : a.iso > b.iso ? 1 : a.order - b.order;
        if (a.iso) return -1;
        if (b.iso) return 1;
        return a.order - b.order;
      });
    const hasHeader = Boolean(eyebrow || heading || intro || ctaLabel);

    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-6xl">
          {hasHeader ? (
            <div className="flex flex-col gap-6 lg:flex-row lg:items-end lg:justify-between lg:gap-16">
              <div className="max-w-2xl">
                {eyebrow ? <p className="text-sm font-semibold tracking-widest text-indigo-700 uppercase">{eyebrow}</p> : null}
                {heading ? <H className={`text-3xl font-semibold tracking-tight text-balance text-neutral-950 sm:text-4xl ${eyebrow ? "mt-3" : ""}`}>{heading}</H> : null}
                {intro ? <p className="mt-4 text-lg leading-8 text-pretty text-neutral-600">{intro}</p> : null}
              </div>
              {ctaLabel ? (
                <a href={ctaHref || "#"} className={`inline-flex min-h-11 shrink-0 items-center justify-center self-start rounded-lg px-5 py-3 text-base font-semibold text-neutral-950 ring-1 ring-neutral-300 transition ring-inset hover:bg-neutral-50 hover:ring-indigo-400 lg:self-auto ${focusRing}`}>
                  {ctaLabel}
                </a>
              ) : null}
            </div>
          ) : null}

          {list.length ? (
            <ol role="list" className={`divide-y divide-neutral-200 border-y border-neutral-200 ${hasHeader ? "mt-10 sm:mt-14" : ""}`}>
              {list.map((o, i) => {
                const status = statusMeta[o.status] ?? statusMeta.open;
                const date = o.iso ? parseIso(o.iso) : null;
                const shownDeadline = o.deadline || (date ? longDate.format(date) : "");
                const closed = o.status === "closed";
                return (
                  <li key={`${o.name}-${i}`}>
                    <article className={`grid grid-cols-1 gap-5 py-8 sm:grid-cols-12 sm:gap-8 ${closed ? "opacity-80" : ""}`}>
                      <div className="flex items-center gap-4 sm:col-span-3 sm:flex-col sm:items-start sm:gap-3 lg:col-span-2">
                        {date && !o.deadline ? (
                          <p className="flex items-baseline gap-2 sm:flex-col sm:gap-0">
                            <span className="sr-only">Deadline: </span>
                            <time dateTime={o.iso} className="contents">
                              <span className="text-sm font-semibold tracking-widest text-indigo-700 uppercase">{monthShort.format(date)}</span>
                              <span className="text-4xl leading-none font-semibold tracking-tight text-neutral-950 tabular-nums sm:text-5xl">{date.getUTCDate()}</span>
                              <span className="text-sm text-neutral-600 tabular-nums sm:mt-1">{date.getUTCFullYear()}</span>
                            </time>
                          </p>
                        ) : shownDeadline ? (
                          <p className="text-sm leading-6">
                            <span className="block font-medium text-neutral-600">Deadline</span>
                            {o.iso ? (
                              <time dateTime={o.iso} className="block text-base font-semibold text-neutral-950">{shownDeadline}</time>
                            ) : (
                              <span className="block text-base font-semibold text-neutral-950">{shownDeadline}</span>
                            )}
                          </p>
                        ) : null}
                        <p className={`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-xs font-semibold ring-1 ring-inset ${status.pill}`}>
                          <span aria-hidden="true" className={`size-1.5 rounded-full ${status.dot}`} />
                          <span className="sr-only">Status: </span>
                          {status.label}
                        </p>
                      </div>

                      <div className="min-w-0 sm:col-span-9 lg:col-span-6">
                        {o.focusArea ? <p className="text-sm font-medium text-neutral-600">{o.focusArea}</p> : null}
                        <Sub className={`text-xl leading-7 font-semibold tracking-tight text-balance text-neutral-950 sm:text-2xl ${o.focusArea ? "mt-1" : ""}`}>{o.name}</Sub>
                        {o.eligibility ? (
                          <p className="mt-3 text-base leading-7 text-pretty text-neutral-600">
                            <span className="font-medium text-neutral-900">Who can apply: </span>
                            {o.eligibility}
                          </p>
                        ) : null}
                      </div>

                      <div className="flex flex-col gap-4 sm:col-span-9 sm:col-start-4 lg:col-span-4 lg:col-start-auto lg:items-end lg:text-right">
                        {o.awardRange ? (
                          <p>
                            <span className="block text-sm font-medium text-neutral-600">Award range</span>
                            <span className="block text-xl font-semibold tracking-tight text-neutral-950 tabular-nums">{o.awardRange}</span>
                          </p>
                        ) : null}
                        <div className="flex flex-col gap-2 sm:flex-row sm:flex-wrap sm:items-center lg:justify-end">
                          {o.applyLabel && !closed ? (
                            <a href={o.applyHref || "#"} className={`inline-flex min-h-11 items-center justify-center gap-1.5 rounded-lg bg-indigo-600 px-4 py-2.5 text-sm font-semibold text-white shadow-xs transition hover:bg-indigo-700 ${focusRing}`}>
                              {o.applyLabel}
                              <span className="sr-only">: {o.name}</span>
                              <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="size-4">
                                <path fillRule="evenodd" d={arrow} clipRule="evenodd" />
                              </svg>
                            </a>
                          ) : null}
                          {o.rfpLabel ? (
                            <a href={o.rfpHref || "#"} className={`inline-flex min-h-11 items-center justify-center gap-1.5 rounded-lg px-3 py-2.5 text-sm font-semibold text-indigo-700 underline decoration-indigo-300 underline-offset-4 hover:text-indigo-900 hover:decoration-indigo-700 ${focusRing}`}>
                              <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="size-4">
                                <path fillRule="evenodd" d="M4.5 2A1.5 1.5 0 0 0 3 3.5v13A1.5 1.5 0 0 0 4.5 18h11a1.5 1.5 0 0 0 1.5-1.5V7.621a1.5 1.5 0 0 0-.44-1.06l-4.12-4.122A1.5 1.5 0 0 0 11.378 2H4.5Zm2.25 8.5a.75.75 0 0 0 0 1.5h6.5a.75.75 0 0 0 0-1.5h-6.5Zm0 3a.75.75 0 0 0 0 1.5h6.5a.75.75 0 0 0 0-1.5h-6.5Z" clipRule="evenodd" />
                              </svg>
                              {o.rfpLabel}
                              <span className="sr-only">: {o.name}</span>
                            </a>
                          ) : null}
                        </div>
                      </div>
                    </article>
                  </li>
                );
              })}
            </ol>
          ) : null}

          {footnote ? <p className="mt-8 max-w-3xl text-sm leading-6 text-pretty text-neutral-600">{footnote}</p> : null}
        </div>
      </section>
    );
  },
};
```
