# Add the "Activity Feed" block to this P1 project

Add a Puck component from P1 Blocks (https://p1-blocks.prolificdigital.io/blocks/activity-feed) to this Pantheon Content Publisher (P1) Next.js project. Recent gifts, sign-ups, updates, alerts and milestones on a vertical timeline with a view-all link.

## Steps

1. Create `components/puck/activity-feed-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 { activityFeedBlock } from "./components/puck/activity-feed-block";`
3. Register it under `components` as `ActivityFeedBlock: activityFeedBlock`.
4. Add `"ActivityFeedBlock"` to the best-fitting entry in `categories` (this block's library category is "Dashboards"). Create a category only if none fits.
5. Dashboard widgets are designed to sit inside the Dashboard Grid block (https://p1-blocks.prolificdigital.io/r/dashboard-grid.md). If the project doesn't have it yet, offer to add it too.
6. Run the project's type check (usually `pnpm typecheck`) and resolve anything project-specific.
7. 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-`.
- Data values are text fields on purpose: P1 data-source tokens (`{{ source.field }}`) only bind in text fields. Don't convert them to number fields.
- Don't change prop names in `defaultProps`. Content editors' saved pages depend on them.

## File: `components/puck/activity-feed-block.tsx`

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

/**
 * Activity Feed — recent events (gifts, sign-ups, updates, alerts, milestones) on a vertical
 * timeline. Bind the list to a P1 data source ({{ source.items }}) or type it. Place inside a
 * Dashboard Grid.
 * Register: `ActivityFeedBlock: activityFeedBlock` in puck.config.tsx.
 */

type Heading = "h2" | "h3" | "h4" | "p";
type EventType = "donation" | "signup" | "update" | "alert" | "milestone";

export type ActivityFeedProps = {
  title: string;
  headingLevel: Heading;
  subtitle: string;
  items: {
    time: string;
    datetime: string;
    actor: string;
    action: string;
    detail: string;
    type: EventType;
    href: string;
  }[];
  viewAllLabel: string;
  viewAllHref: string;
  footnote: string;
};

const TYPES: Record<EventType, { label: string; tone: string; icon: React.ReactNode }> = {
  donation: {
    label: "Donation",
    tone: "bg-indigo-600 text-white ring-indigo-600",
    icon: <path d="M10 16.25s-6-3.5-6-7.9A3.1 3.1 0 0 1 10 6.6a3.1 3.1 0 0 1 6 1.75c0 4.4-6 7.9-6 7.9Z" />,
  },
  milestone: {
    label: "Milestone",
    tone: "bg-indigo-100 text-indigo-700 ring-indigo-200",
    icon: <path d="M5.5 17V3.5M5.5 4.25h8.75l-1.9 3.1 1.9 3.15H5.5" />,
  },
  signup: {
    label: "Sign-up",
    tone: "bg-white text-indigo-700 ring-indigo-200",
    icon: (
      <>
        <circle cx="8" cy="7" r="2.75" />
        <path d="M3.25 16c.6-2.5 2.45-3.9 4.75-3.9s4.15 1.4 4.75 3.9M15.25 6.25v5M12.75 8.75h5" />
      </>
    ),
  },
  update: {
    label: "Update",
    tone: "bg-neutral-100 text-neutral-600 ring-neutral-200",
    icon: <path d="M12.25 4.5l3.25 3.25L8 15.25H4.75V12l7.5-7.5ZM10.5 6.25l3.25 3.25" />,
  },
  alert: {
    label: "Alert",
    tone: "bg-neutral-900 text-white ring-neutral-900",
    icon: <path d="M10 3.75 17 16H3l7-12.25ZM10 8.5v3M10 13.75v.01" />,
  },
};

const ISO = /^\d{4}-\d{2}-\d{2}/;

export const activityFeedBlock: ComponentConfig<ActivityFeedProps> = {
  label: "Activity Feed",
  fields: {
    title: { type: "text", label: "Title" },
    headingLevel: {
      type: "select",
      label: "Heading level",
      options: [
        { label: "H2", value: "h2" },
        { label: "H3 (recommended inside a dashboard)", value: "h3" },
        { label: "H4", value: "h4" },
        { label: "Not a heading", value: "p" },
      ],
      metadata: { help: "Sets the page outline for screen readers and search. The look doesn't change." },
    },
    subtitle: { type: "text", label: "Subtitle", metadata: { help: "e.g. Last 24 hours. Leave blank to hide." } },
    items: {
      type: "array",
      label: "Events",
      min: 0,
      max: 20,
      getItemSummary: (item) => (item?.actor || item?.action ? [item.actor, item.action].filter(Boolean).join(" ") : "Event"),
      defaultItemProps: { time: "Just now", datetime: "", actor: "Someone", action: "did something", detail: "", type: "update", href: "" },
      arrayFields: {
        time: { type: "text", label: "When", metadata: { help: "As visitors should read it, e.g. 12 min ago or Oct 6." } },
        datetime: {
          type: "text",
          label: "Timestamp (ISO)",
          metadata: { help: "Optional, for machines and screen readers, e.g. 2026-10-07T09:12:00-04:00 or {{ item.created_at }}." },
        },
        actor: { type: "text", label: "Who", metadata: { help: "Shown in bold, e.g. Maria L. or The program team." } },
        action: { type: "text", label: "What happened", metadata: { help: "Reads after the name, e.g. gave $250 to the Winter Coat Drive." } },
        detail: { type: "text", label: "Detail", metadata: { help: "A quieter second line. Leave blank to hide." } },
        type: {
          type: "select",
          label: "Type",
          options: [
            { label: "Donation", value: "donation" },
            { label: "Sign-up", value: "signup" },
            { label: "Update", value: "update" },
            { label: "Alert", value: "alert" },
            { label: "Milestone", value: "milestone" },
          ],
          metadata: { help: "Sets the icon." },
        },
        href: { type: "text", label: "Link", metadata: { help: "Optional. Makes the event a link to its details." } },
      },
    },
    viewAllLabel: { type: "text", label: "View all link text", metadata: { help: "Leave blank to hide the link." } },
    viewAllHref: { type: "text", label: "View all link" },
    footnote: { type: "text", label: "Footnote", metadata: { help: "Where the events come from. Leave blank to hide." } },
  },
  defaultProps: {
    title: "Recent activity",
    headingLevel: "h3",
    subtitle: "Across giving, volunteers and programs",
    items: [
      { time: "12 min ago", datetime: "2026-10-07T09:48:00-04:00", actor: "Maria L.", action: "gave $250 to the Winter Coat Drive", detail: "Second gift this year", type: "donation", href: "" },
      { time: "48 min ago", datetime: "2026-10-07T09:12:00-04:00", actor: "14 volunteers", action: "signed up for Saturday's riverfront cleanup", detail: "6 spots left", type: "signup", href: "" },
      { time: "2 hr ago", datetime: "2026-10-07T07:55:00-04:00", actor: "Annual campaign", action: "passed $500,000 raised", detail: "83% of the $600,000 goal", type: "milestone", href: "" },
      { time: "Yesterday", datetime: "2026-10-06T16:20:00-04:00", actor: "Online giving", action: "card payments were delayed for 22 minutes", detail: "Resolved · no gifts were lost", type: "alert", href: "" },
      { time: "Oct 5", datetime: "2026-10-05T11:00:00-04:00", actor: "The program team", action: "published the Q3 impact report", detail: "", type: "update", href: "#" },
    ],
    viewAllLabel: "View all activity",
    viewAllHref: "#",
    footnote: "Sample data · Source: donor and volunteer records",
  },
  render: ({ title, headingLevel, subtitle, items, viewAllLabel, viewAllHref, footnote }) => {
    const H = headingLevel || "h3";
    const list = (items ?? []).filter((item) => item?.actor || item?.action);

    return (
      <div className="@container flex h-full flex-col rounded-xl bg-white p-5 shadow-xs ring-1 ring-neutral-950/5 sm:p-6 not-in-data-[dashboard-grid]:mx-4 not-in-data-[dashboard-grid]:my-8 sm:not-in-data-[dashboard-grid]:mx-auto sm:not-in-data-[dashboard-grid]:max-w-2xl">
        {title || subtitle ? (
          <div>
            {title ? <H className="text-base font-semibold text-neutral-950">{title}</H> : null}
            {subtitle ? <p className="mt-1 text-sm text-neutral-600">{subtitle}</p> : null}
          </div>
        ) : null}

        {list.length ? (
          <ol role="list" className={title || subtitle ? "mt-5" : ""}>
            {list.map((item, i) => {
              const t = TYPES[item.type] ?? TYPES.update;
              const last = i === list.length - 1;
              const sentence = (
                <>
                  <span className="sr-only">{t.label}: </span>
                  {item.actor ? <span className="font-semibold text-neutral-950">{item.actor}</span> : null}
                  {item.actor && item.action ? " " : null}
                  {item.action}
                </>
              );
              const when = item.time?.trim();
              return (
                <li key={`${item.actor}-${i}`} className="relative flex gap-3.5">
                  {!last ? <span aria-hidden="true" className="absolute top-9 bottom-1 left-4 w-px -translate-x-1/2 bg-neutral-200" /> : null}
                  <span aria-hidden="true" className={`relative flex size-8 shrink-0 items-center justify-center rounded-full ring-1 ring-inset ${t.tone}`}>
                    <svg viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" className="size-4">
                      {t.icon}
                    </svg>
                  </span>
                  <div className={`min-w-0 flex-1 pt-1.5 ${last ? "" : "pb-6"}`}>
                    <div className="flex flex-col gap-0.5 @sm:flex-row @sm:items-baseline @sm:justify-between @sm:gap-4">
                      <p className="min-w-0 text-sm leading-5 text-pretty text-neutral-700">
                        {item.href ? (
                          <a
                            href={item.href}
                            className="rounded-sm underline decoration-neutral-300 underline-offset-4 transition hover:decoration-indigo-600 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600"
                          >
                            {sentence}
                          </a>
                        ) : (
                          sentence
                        )}
                      </p>
                      {when ? (
                        ISO.test(item.datetime?.trim() ?? "") ? (
                          <time dateTime={item.datetime.trim()} className="shrink-0 text-xs text-neutral-500 tabular-nums">
                            {when}
                          </time>
                        ) : (
                          <span className="shrink-0 text-xs text-neutral-500 tabular-nums">{when}</span>
                        )
                      ) : null}
                    </div>
                    {item.detail ? <p className="mt-1 text-xs leading-5 text-neutral-500">{item.detail}</p> : null}
                  </div>
                </li>
              );
            })}
          </ol>
        ) : (
          <p className="mt-4 text-sm text-neutral-500">No recent activity.</p>
        )}

        {viewAllLabel || footnote ? (
          <div className="mt-auto pt-5">
            {viewAllLabel ? (
              <a
                href={viewAllHref || "#"}
                className="group inline-flex min-h-11 items-center gap-1.5 rounded-md 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"
              >
                {viewAllLabel}
                <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="size-4 transition group-hover:translate-x-0.5 motion-reduce:transition-none">
                  <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}
            {footnote ? <p className={`text-xs text-neutral-500 ${viewAllLabel ? "mt-2 border-t border-neutral-100 pt-3" : ""}`}>{footnote}</p> : null}
          </div>
        ) : null}
      </div>
    );
  },
};
```
