# Add the "Volunteer Roles" block to this P1 project

Add a Puck component from P1 Blocks (https://p1-blocks.prolificdigital.io/blocks/volunteer-roles) to this Pantheon Content Publisher (P1) Next.js project. Volunteer opportunities with time commitment, location, skill tags, spots left and an apply link.

## Steps

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

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

/**
 * Volunteer Roles — open volunteer opportunities as cards with time commitment, location,
 * skills and spots left, each with its own apply link.
 * Register: `VolunteerRolesBlock: volunteerRolesBlock` in puck.config.tsx.
 */

type Heading = "h1" | "h2" | "h3" | "h4";
type Mode = "in-person" | "remote" | "hybrid";

export type VolunteerRolesProps = {
  heading: string;
  headingLevel: Heading;
  intro: string;
  roles: {
    title: string;
    summary: string;
    commitment: string;
    mode: Mode;
    location: string;
    skills: string;
    spots: string;
    href: string;
  }[];
  applyLabel: string;
  footerText: string;
  footerLabel: string;
  footerHref: string;
};

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

const modeLabel: Record<Mode, string> = { "in-person": "In person", remote: "Remote", hybrid: "Hybrid" };

const icons = {
  clock: "M12 6v6h4.5m4.5 0a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z",
  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",
  globe:
    "M12 21a9.004 9.004 0 0 0 8.716-6.747M12 21a9.004 9.004 0 0 1-8.716-6.747M12 21c2.485 0 4.5-4.03 4.5-9S14.485 3 12 3m0 18c-2.485 0-4.5-4.03-4.5-9S9.515 3 12 3m0 0a8.997 8.997 0 0 1 7.843 4.582M12 3a8.997 8.997 0 0 0-7.843 4.582m15.686 0A11.953 11.953 0 0 1 12 10.5c-2.998 0-5.74-1.1-7.843-2.918m15.686 0A8.959 8.959 0 0 1 21 12c0 .778-.099 1.533-.284 2.253m0 0A17.919 17.919 0 0 1 12 16.5c-3.162 0-6.133-.815-8.716-2.247m0 0A9.015 9.015 0 0 1 3 12c0-1.605.42-3.113 1.157-4.418",
};

const Icon = ({ d }: { d: string }) => (
  <svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={1.5} strokeLinecap="round" strokeLinejoin="round" className="size-5 shrink-0 text-neutral-500">
    <path d={d} />
  </svg>
);

export const volunteerRolesBlock: ComponentConfig<VolunteerRolesProps> = {
  label: "Volunteer Roles",
  fields: {
    heading: { type: "textarea", 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" },
    roles: {
      type: "array",
      label: "Roles",
      min: 1,
      max: 12,
      getItemSummary: (item) => item?.title || "Role",
      defaultItemProps: {
        title: "New role",
        summary: "What a volunteer in this role does, in a sentence or two.",
        commitment: "2 hrs/week",
        mode: "in-person",
        location: "Main office",
        skills: "",
        spots: "",
        href: "/volunteer/apply",
      },
      arrayFields: {
        title: { type: "text", label: "Role title" },
        summary: { type: "textarea", label: "Summary" },
        commitment: { type: "text", label: "Time commitment", metadata: { help: "Like 3 hrs/week or One Saturday a month." } },
        mode: {
          type: "select",
          label: "Where",
          options: [
            { label: "In person", value: "in-person" },
            { label: "Remote", value: "remote" },
            { label: "Hybrid", value: "hybrid" },
          ],
        },
        location: { type: "text", label: "Location", metadata: { help: "Neighborhood, site or building. Leave blank for remote roles." } },
        skills: { type: "textarea", label: "Skills", metadata: { help: "One per line. Each shows as a tag." } },
        spots: { type: "text", label: "Spots left", metadata: { help: "Free text, like 4 spots left or Ongoing. Leave blank to hide it." } },
        href: { type: "text", label: "Apply link", metadata: { help: "Your application form for this role, a path or full URL." } },
      },
    },
    applyLabel: { type: "text", label: "Apply link text", metadata: { help: "Shown on every card, like Apply. The role name is added for screen readers." } },
    footerText: { type: "text", label: "Footer text", metadata: { help: "A line under the list, like Don't see a fit? Leave blank to hide it." } },
    footerLabel: { type: "text", label: "Footer link text" },
    footerHref: { type: "text", label: "Footer link" },
  },
  defaultProps: {
    heading: "Show up for a young person this year",
    headingLevel: "h2",
    intro: "Bright Path Mentoring pairs caring adults with students in grades 6 through 12. Every role includes a background check, a two-hour orientation and a staff contact you can call any time.",
    roles: [
      {
        title: "One-to-one mentor",
        summary: "Meet with the same student every week to talk, play a game or work on goals they set themselves.",
        commitment: "2 hrs/week for one school year",
        mode: "in-person",
        location: "Eastside middle schools",
        skills: "Patience\nReliable schedule\nBilingual a plus",
        spots: "12 spots left",
        href: "/volunteer/apply?role=mentor",
      },
      {
        title: "Homework help tutor",
        summary: "Drop into our after-school study hall and help students untangle algebra, essays and science labs.",
        commitment: "3 hrs/week",
        mode: "in-person",
        location: "Westgate Library annex",
        skills: "Middle school math\nWriting\nEncouragement",
        spots: "5 spots left",
        href: "/volunteer/apply?role=tutor",
      },
      {
        title: "Virtual career coach",
        summary: "Run mock interviews and review résumés with high school seniors over video, on your own schedule.",
        commitment: "4 sessions/semester",
        mode: "remote",
        location: "",
        skills: "Hiring experience\nRésumé review\nVideo calls",
        spots: "Ongoing",
        href: "/volunteer/apply?role=coach",
      },
      {
        title: "Event crew",
        summary: "Set up, greet families and keep the day running at our quarterly match celebrations and fall 5K.",
        commitment: "One Saturday a quarter",
        mode: "hybrid",
        location: "Riverside Park pavilion",
        skills: "Lifting up to 30 lbs\nFriendly greeter\nPhotography",
        spots: "20 spots left",
        href: "/volunteer/apply?role=events",
      },
    ],
    applyLabel: "Apply",
    footerText: "Don't see a fit? We'll find one with you.",
    footerLabel: "Tell us how you'd like to help",
    footerHref: "/volunteer/interest",
  },
  render: ({ heading, headingLevel, intro, roles, applyLabel, footerText, footerLabel, footerHref }) => {
    const H = headingLevel || "h2";
    const Sub = childHeading[H] ?? "h3";
    const list = (roles ?? []).filter((r) => r?.title);
    const apply = applyLabel || "Apply";

    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">
          <div className="max-w-2xl">
            {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-lg leading-8 text-pretty text-neutral-600">{intro}</p> : null}
          </div>

          {list.length ? (
            <ul role="list" className="mt-12 grid gap-5 md:grid-cols-2 lg:mt-14 lg:gap-6">
              {list.map((r, i) => {
                const mode: Mode = r.mode && modeLabel[r.mode] ? r.mode : "in-person";
                const skills = (r.skills || "")
                  .split("\n")
                  .map((s) => s.trim())
                  .filter(Boolean);
                const where = [modeLabel[mode], r.location].filter(Boolean).join(" · ");
                return (
                  <li key={`${r.title}-${i}`}>
                    <article className="flex h-full flex-col rounded-2xl bg-neutral-50 p-6 ring-1 ring-neutral-200 sm:p-8">
                      <div className="flex flex-wrap items-start justify-between gap-x-4 gap-y-2">
                        <Sub className="text-xl font-semibold tracking-tight text-neutral-950">{r.title}</Sub>
                        {r.spots ? (
                          <p className="inline-flex items-center gap-1.5 rounded-full bg-white px-2.5 py-1 text-sm font-medium text-indigo-700 ring-1 ring-indigo-600/20 ring-inset">
                            <span aria-hidden="true" className="size-1.5 rounded-full bg-indigo-600" />
                            {r.spots}
                          </p>
                        ) : null}
                      </div>
                      {r.summary ? <p className="mt-3 text-base leading-7 text-pretty text-neutral-600">{r.summary}</p> : null}

                      <dl className="mt-5 grid gap-2 text-sm text-neutral-700 sm:grid-cols-2 sm:gap-4">
                        {r.commitment ? (
                          <div>
                            <dt className="sr-only">Time commitment</dt>
                            <dd className="flex items-start gap-2">
                              <Icon d={icons.clock} />
                              {r.commitment}
                            </dd>
                          </div>
                        ) : null}
                        <div>
                          <dt className="sr-only">Where</dt>
                          <dd className="flex items-start gap-2">
                            <Icon d={mode === "remote" ? icons.globe : icons.pin} />
                            {where}
                          </dd>
                        </div>
                      </dl>

                      {skills.length ? (
                        <div className="mt-5">
                          <p className="sr-only">Helpful skills</p>
                          <ul role="list" className="flex flex-wrap gap-2">
                            {skills.map((s, j) => (
                              <li key={`${s}-${j}`} className="rounded-md bg-white px-2.5 py-1 text-sm text-neutral-700 ring-1 ring-neutral-200 ring-inset">
                                {s}
                              </li>
                            ))}
                          </ul>
                        </div>
                      ) : null}

                      <div className="mt-auto pt-7">
                        <a
                          href={r.href || "#"}
                          className="group inline-flex min-h-11 items-center gap-2 rounded-lg bg-neutral-950 px-4 py-2.5 text-sm font-semibold text-white transition hover:bg-indigo-700 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600"
                        >
                          {apply}
                          <span className="sr-only">: {r.title}</span>
                          <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="size-4 transition group-hover:translate-x-0.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>
                      </div>
                    </article>
                  </li>
                );
              })}
            </ul>
          ) : null}

          {footerText || footerLabel ? (
            <p className="mt-10 flex flex-col gap-1 text-base text-neutral-600 sm:flex-row sm:flex-wrap sm:items-center sm:gap-x-3">
              {footerText ? <span>{footerText}</span> : null}
              {footerLabel ? (
                <a
                  href={footerHref || "#"}
                  className="inline-flex min-h-11 items-center font-semibold text-indigo-700 underline decoration-indigo-300 underline-offset-4 hover:decoration-indigo-700 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600"
                >
                  {footerLabel}
                </a>
              ) : null}
            </p>
          ) : null}
        </div>
      </section>
    );
  },
};
```
