Blocks / Activity

Activity

The timeline of a record: its changes, its comments, a box to write one.

import { Activity, CommentComposer } from "@forgeron/ui";
/01 → Default

Activity

  1. Camille Roy created the issue 3 Nov
  2. Hugo Bernard moved it to In Review 2 h ago
  3. Nadia Petit1 h ago
    Thanks. Two suppliers called about it this morning.
import { Activity, StatusGlyph, type ActivityItem } from "@forgeron/ui";

const items: ActivityItem[] = [
  { kind: "event", id: "e1", author: "Camille Roy", text: "created the issue", time: "3 Nov" },
  {
    kind: "event",
    id: "e2",
    author: "Hugo Bernard",
    text: "moved it to In Review",
    time: "2 h ago",
    glyph: <StatusGlyph status="review" />,
  },
  {
    kind: "comment",
    id: "c1",
    author: "Nadia Petit",
    body: "Thanks. Two suppliers called about it this morning.",
    time: "1 h ago",
  },
];

export default function Default() {
  return (
    <div style={{ width: 340 }}>
      <Activity items={items} />
    </div>
  );
}
/02 → Thread

Activity

  1. Camille Roy created the issue 3 Nov
  2. Camille Roy set the priority to Urgent 3 Nov
  3. Camille Roy assigned it to Hugo Bernard 4 Nov
  4. Hugo Bernard
    Odoo sends the webhook twice when an invoice is validated, then posted. I dedupe on the move id now; the fix is in review.
  5. Hugo Bernard moved it to In Review 2 h ago
  6. Nadia Petit
    Thanks. Two suppliers called about it this morning.
import { Activity, Button, PriorityGlyph, StatusGlyph, type ActivityItem } from "@forgeron/ui";
import { useState } from "react";

const start: ActivityItem[] = [
  { kind: "event", id: "e1", author: "Camille Roy", text: "created the issue", time: "3 Nov" },
  {
    kind: "event",
    id: "e2",
    author: "Camille Roy",
    text: "set the priority to Urgent",
    time: "3 Nov",
    glyph: <PriorityGlyph level={1} />,
  },
  {
    kind: "event",
    id: "e3",
    author: "Camille Roy",
    text: "assigned it to Hugo Bernard",
    time: "4 Nov",
  },
  {
    kind: "comment",
    id: "c1",
    author: "Hugo Bernard",
    body: "Odoo sends the webhook twice when an invoice is validated, then posted. I dedupe on the move id now; the fix is in review.",
    time: "3 h ago",
    dateTime: "2026-11-17T09:10",
  },
  {
    kind: "event",
    id: "e4",
    author: "Hugo Bernard",
    text: "moved it to In Review",
    time: "2 h ago",
    glyph: <StatusGlyph status="review" />,
  },
  {
    kind: "comment",
    id: "c2",
    author: "Nadia Petit",
    body: "Thanks. Two suppliers called about it this morning.",
    time: "1 h ago",
    dateTime: "2026-11-17T11:02",
  },
];

export default function Thread() {
  const [items, setItems] = useState(start);
  const [subscribed, setSubscribed] = useState(true);
  return (
    <div style={{ width: "100%", maxWidth: 640 }}>
      <Activity
        items={items}
        actions={
          <Button variant="ghost" size="sm" onClick={() => setSubscribed((s) => !s)}>
            {subscribed ? "Unsubscribe" : "Subscribe"}
          </Button>
        }
        onSubmit={(text) =>
          setItems((list) => [
            ...list,
            {
              kind: "comment",
              id: `c${list.length + 1}`,
              author: "Camille Roy",
              body: text,
              time: "just now",
            },
          ])
        }
      />
    </div>
  );
}
/03 → Reply

Mentioned you

  1. Nadia Petit1 h ago
    Hugo Bernard
    I dedupe on the move id now; the fix is in review.
    Thanks. Two suppliers called about it this morning.
import { Activity, CommentComposer, type ActivityItem } from "@forgeron/ui";
import { useState } from "react";

const items: ActivityItem[] = [
  {
    kind: "comment",
    id: "c2",
    author: "Nadia Petit",
    body: "Thanks. Two suppliers called about it this morning.",
    quote: { author: "Hugo Bernard", text: "I dedupe on the move id now; the fix is in review." },
    time: "1 h ago",
    highlighted: true,
  },
];

export default function Reply() {
  const [draft, setDraft] = useState("");
  const [sent, setSent] = useState<string | null>(null);
  return (
    <div style={{ width: "100%", maxWidth: 640, display: "grid", gap: 12 }}>
      <Activity title="Mentioned you" items={items} />
      <CommentComposer
        label="Reply to Nadia Petit"
        placeholder="Reply…"
        submitLabel="Reply"
        value={draft}
        onChange={setDraft}
        onSubmit={(text) => {
          setSent(text);
          setDraft("");
        }}
      />
      {sent ? <p style={{ margin: 0, color: "var(--ink-muted)" }}>Sent: {sent}</p> : null}
    </div>
  );
}
API → Props
PropTypeDefaultDescription
itemsActivityItem[]—{ kind: "event", author, text, time, glyph? } or { kind: "comment", author, body, time, quote?, highlighted? }, oldest first.
time / dateTimestring—"2 h ago" as the caller words it; dateTime makes it a <time>.
onSubmit(text: string) => void—Shows the composer; the trimmed text on the button or ⌘↵.
draft / onDraftChangestring / (value: string) => void—The composer's text, when the caller keeps it.
title / actionsstring / ReactNode"Activity"The heading, and what sits at its end (Subscribe).
submitLabel / placeholderstring"Comment" / "Leave a comment…"The composer's button and empty text.
classNamestring—Extra classes.