{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "activity-feed-02",
  "description": "The history of one record as a timeline, with each change shown from the old value to the new one and comments quoted in full.",
  "registryDependencies": [
    "card",
    "https://www.dashboardblocks.com/r/radix/activity-feed.json",
    "https://www.dashboardblocks.com/r/radix/block-state.json",
    "https://www.dashboardblocks.com/r/radix/status-label.json",
    "https://www.dashboardblocks.com/r/radix/value-change.json"
  ],
  "files": [
    {
      "path": "registry/components/dashboardblocks/activity-feed/activity-feed-02.tsx",
      "content": "'use client'\n\nimport {\n  ActivityFeed,\n  ActivityFeedItem,\n  ActivityIcon,\n  ActivityTime,\n  type ActivityTone,\n} from '@/registry/components/dashboardblocks/activity-feed'\nimport {\n  BlockReady,\n  BlockStateProvider,\n  BlockStateRows,\n  type BlockStateProps,\n  getBlockState,\n} from '@/registry/components/dashboardblocks/block-state'\nimport {\n  StatusLabel,\n  type StatusTone,\n} from '@/registry/components/dashboardblocks/status-label'\nimport { ValueChange } from '@/registry/components/dashboardblocks/value-change'\nimport { IconPlaceholder } from '@/registry/icons/icon-placeholder'\nimport type { ReactNode } from 'react'\n\nimport { Card, CardContent } from '@/components/ui/card'\n\ntype HistoryKind =\n  | 'created'\n  | 'assigned'\n  | 'changed'\n  | 'labelled'\n  | 'commented'\n  | 'resolved'\n\ninterface HistoryEvent {\n  action: string\n  actor: string\n  at: Date\n  change?: { from: string; to: string }\n  comment?: string\n  id: string\n  kind: HistoryKind\n}\n\ntype RecordStatusTone = 'success' | 'warning' | 'danger' | 'info' | 'neutral'\n\ninterface ActivityFeed2Props extends BlockStateProps {\n  /** What the record is about; a sentence on its history follows it. */\n  description: string\n  /** Oldest first, so the history reads as a story. Leave out, or pass none, to show the empty state. */\n  events?: HistoryEvent[]\n  /** Pass a fixed date, so the block renders the same on the server and in the browser. */\n  now: Date\n  recordStatus: { label: string; tone?: RecordStatusTone }\n  timeZone?: string\n  title: string\n}\n\nconst kindConfig: Record<HistoryKind, { icon: ReactNode; tone: ActivityTone }> = {\n  assigned: {\n    icon: (\n      <IconPlaceholder\n        lucide='UserCheckIcon'\n        tabler='IconUserCheck'\n        hugeicons='UserCheck01Icon'\n        phosphor='UserCheckIcon'\n        remixicon='RiUserFollowLine'\n      />\n    ),\n    tone: 'info',\n  },\n  changed: {\n    icon: (\n      <IconPlaceholder\n        lucide='ArrowRightIcon'\n        tabler='IconArrowRight'\n        hugeicons='ArrowRight01Icon'\n        phosphor='ArrowRightIcon'\n        remixicon='RiArrowRightLine'\n      />\n    ),\n    tone: 'accent',\n  },\n  commented: {\n    icon: (\n      <IconPlaceholder\n        lucide='MessageSquareIcon'\n        tabler='IconMessage'\n        hugeicons='MessageIcon'\n        phosphor='ChatCircleIcon'\n        remixicon='RiChat1Line'\n      />\n    ),\n    tone: 'neutral',\n  },\n  created: {\n    icon: (\n      <IconPlaceholder\n        lucide='CirclePlusIcon'\n        tabler='IconCirclePlus'\n        hugeicons='AddCircleIcon'\n        phosphor='PlusCircleIcon'\n        remixicon='RiAddCircleLine'\n      />\n    ),\n    tone: 'neutral',\n  },\n  labelled: {\n    icon: (\n      <IconPlaceholder\n        lucide='TagIcon'\n        tabler='IconTag'\n        hugeicons='Tag01Icon'\n        phosphor='TagIcon'\n        remixicon='RiPriceTag3Line'\n      />\n    ),\n    tone: 'accent',\n  },\n  resolved: {\n    icon: (\n      <IconPlaceholder\n        lucide='CircleCheckIcon'\n        tabler='IconCircleCheck'\n        hugeicons='CheckmarkCircle02Icon'\n        phosphor='CheckCircleIcon'\n        remixicon='RiCheckboxCircleLine'\n      />\n    ),\n    tone: 'success',\n  },\n}\n\nconst NOW = new Date(Date.UTC(2026, 8, 26, 15, 0))\nconst minutesAgo = (minutes: number) => new Date(NOW.getTime() - minutes * 60_000)\n\nconst exampleProps: ActivityFeed2Props = {\n  description: 'Checkout fails with a saved card',\n  events: [\n    {\n      action: 'opened this ticket',\n      actor: 'Amara Okafor',\n      at: minutesAgo(60 * 26),\n      id: 'h1',\n      kind: 'created',\n    },\n    {\n      action: 'added the labels Payments and Safari',\n      actor: 'Priya Nair',\n      at: minutesAgo(60 * 25),\n      id: 'h2',\n      kind: 'labelled',\n    },\n    {\n      action: 'assigned this to Kevin Moore',\n      actor: 'Priya Nair',\n      at: minutesAgo(60 * 25 - 2),\n      id: 'h3',\n      kind: 'assigned',\n    },\n    {\n      action: 'changed the priority',\n      actor: 'Kevin Moore',\n      at: minutesAgo(60 * 6),\n      change: { from: 'Normal', to: 'High' },\n      id: 'h4',\n      kind: 'changed',\n    },\n    {\n      action: 'commented',\n      actor: 'Kevin Moore',\n      at: minutesAgo(95),\n      comment:\n        'Reproduced on Safari 18 with a saved card. The card token refreshes after the form submits, so the first charge is declined. Fix is in review.',\n      id: 'h5',\n      kind: 'commented',\n    },\n    {\n      action: 'changed the status',\n      actor: 'Kevin Moore',\n      at: minutesAgo(12),\n      change: { from: 'In progress', to: 'Resolved' },\n      id: 'h6',\n      kind: 'resolved',\n    },\n  ],\n  now: NOW,\n  recordStatus: { label: 'Resolved', tone: 'success' },\n  title: 'Ticket #4821',\n}\n\nconst statusTones: Record<RecordStatusTone, StatusTone> = {\n  danger: 'bad',\n  info: 'info',\n  neutral: 'neutral',\n  success: 'good',\n  warning: 'warning',\n}\n\nconst HOUR = 3_600_000\n\nfunction formatSpan(from: Date, to: Date) {\n  const hours = Math.round((to.getTime() - from.getTime()) / HOUR)\n  if (hours < 1) return 'under an hour'\n  if (hours < 48) return `${hours} ${hours === 1 ? 'hour' : 'hours'}`\n  return `${Math.round(hours / 24)} days`\n}\n\nconst summarize = (events: HistoryEvent[]) => {\n  const first = events[0]\n  const last = events[events.length - 1]\n  if (!first || !last) return 'No history yet.'\n  const people = new Set(events.map((event) => event.actor)).size\n  return `${events.length} ${events.length === 1 ? 'change' : 'changes'} by ${people} ${people === 1 ? 'person' : 'people'} over ${formatSpan(first.at, last.at)}.`\n}\n\nconst ActivityFeed2 = (props: ActivityFeed2Props) => {\n  const {\n    description,\n    events = [],\n    now,\n    recordStatus,\n    errorMessage,\n    status,\n    timeZone = 'UTC',\n    title,\n  } = props\n  const state = getBlockState(status, events)\n\n  return (\n    <BlockStateProvider errorMessage={errorMessage} state={state}>\n      <Card>\n        <CardContent>\n          <section className='@container flex flex-col gap-4'>\n            <header className='flex items-start justify-between gap-3'>\n              <div className='flex min-w-0 flex-col gap-0.5'>\n                <h2 className='font-semibold tracking-tight'>{title}</h2>\n                <p className='text-muted-foreground text-sm'>\n                  {description}. <BlockReady>{summarize(events)}</BlockReady>\n                </p>\n              </div>\n              <BlockReady className='w-20 text-sm'>\n                <StatusLabel tone={statusTones[recordStatus.tone ?? 'neutral']}>\n                  {recordStatus.label}\n                </StatusLabel>\n              </BlockReady>\n            </header>\n            {state && (\n              <div className='border-t'>\n                <BlockStateRows rows={5} />\n              </div>\n            )}\n            {!state && (\n              <ActivityFeed aria-label={`History of ${title}`} className='border-t pt-4'>\n                {events.map((event) => {\n                  const config = kindConfig[event.kind]\n                  return (\n                    <ActivityFeedItem key={event.id} className='pb-5 last:pb-0' connector>\n                      <ActivityIcon\n                        className='ring-background'\n                        icon={config.icon}\n                        tone={config.tone}\n                      />\n                      <div className='flex min-w-0 flex-1 flex-col gap-2 pt-1.5'>\n                        <div className='flex items-start justify-between gap-3'>\n                          <p className='text-sm'>\n                            <span className='font-medium'>{event.actor}</span>{' '}\n                            <span className='text-muted-foreground'>{event.action}</span>\n                            {event.change && (\n                              <>\n                                {' '}\n                                <ValueChange\n                                  from={event.change.from}\n                                  to={event.change.to}\n                                />\n                              </>\n                            )}\n                          </p>\n                          <ActivityTime\n                            className='mt-0.5'\n                            date={event.at}\n                            now={now}\n                            timeZone={timeZone}\n                          />\n                        </div>\n                        {event.comment && (\n                          <blockquote className='border-l-2 pl-3 text-sm'>\n                            {event.comment}\n                          </blockquote>\n                        )}\n                      </div>\n                    </ActivityFeedItem>\n                  )\n                })}\n              </ActivityFeed>\n            )}\n          </section>\n        </CardContent>\n      </Card>\n    </BlockStateProvider>\n  )\n}\n\nexport {\n  ActivityFeed2,\n  exampleProps as activityFeed2ExampleProps,\n  type ActivityFeed2Props,\n  type HistoryEvent,\n  type HistoryKind,\n  type RecordStatusTone,\n}\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/activity-feed/activity-feed-02.tsx"
    }
  ],
  "meta": {
    "shows": "The history of one record as a timeline, with each change shown from the old value to the new one and comments quoted in full.",
    "size": "half",
    "usedWith": [
      "activity-feed-01",
      "comments-01"
    ],
    "component": "ActivityFeed2",
    "props": "{ description: string; events?: { action: string; actor: string; at: Date; change?: { from: string; to: string }; comment?: string; id: string; kind: \"created\" | \"assigned\" | \"changed\" | \"labelled\" | \"commented\" | \"resolved\" }[]; now: Date; recordStatus: { label: string; tone?: \"success\" | \"warning\" | \"danger\" | \"info\" | \"neutral\" }; timeZone?: string; title: string; errorMessage?: string; status?: \"loading\" | \"error\" }"
  },
  "type": "registry:component"
}
