{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "activity-feed",
  "title": "Activity feed",
  "description": "A timeline of events with tone dots, avatars and relative timestamps.",
  "registryDependencies": [
    "@khaeli/utils"
  ],
  "files": [
    {
      "path": "registry/khaeli/ui/activity-feed.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\n\nimport { cn } from \"@/lib/utils\"\n\n// --- Variant types ---\n\ntype ActivityVariant =\n  | \"create\"\n  | \"update\"\n  | \"delete\"\n  | \"comment\"\n  | \"status-change\"\n\n// --- timeAgo utility ---\n\nconst DIVISIONS: { amount: number; unit: Intl.RelativeTimeFormatUnit }[] = [\n  { amount: 60, unit: \"second\" },\n  { amount: 60, unit: \"minute\" },\n  { amount: 24, unit: \"hour\" },\n  { amount: 7, unit: \"day\" },\n  { amount: 4.345, unit: \"week\" },\n  { amount: 12, unit: \"month\" },\n  { amount: Number.POSITIVE_INFINITY, unit: \"year\" },\n]\n\nfunction timeAgo(date: Date | string): string {\n  const d = typeof date === \"string\" ? new Date(date) : date\n  const now = new Date()\n  let elapsed = (d.getTime() - now.getTime()) / 1000\n\n  const rtf = new Intl.RelativeTimeFormat(\"en\", { numeric: \"auto\" })\n\n  for (const division of DIVISIONS) {\n    if (Math.abs(elapsed) < division.amount) {\n      return rtf.format(Math.round(elapsed), division.unit)\n    }\n    elapsed /= division.amount\n  }\n\n  return rtf.format(Math.round(elapsed), \"year\")\n}\n\n// --- Variant dot colors ---\n\nconst variantDotClasses: Record<ActivityVariant, string> = {\n  create: \"bg-positive\",\n  update: \"bg-tone-indigo\",\n  delete: \"bg-destructive\",\n  comment: \"bg-muted-foreground/50\",\n  \"status-change\": \"bg-tone-amber\",\n}\n\n// --- ActivityFeed ---\n\nfunction ActivityFeed({\n  className,\n  ...props\n}: React.ComponentProps<\"div\">) {\n  return (\n    <div\n      data-slot=\"activity-feed\"\n      className={cn(\"relative flex flex-col\", className)}\n      {...props}\n    />\n  )\n}\n\n// --- ActivityFeedItem ---\n\ntype ActivityFeedItemProps = React.ComponentProps<\"div\"> & {\n  variant?: ActivityVariant\n}\n\nfunction ActivityFeedItem({\n  variant = \"update\",\n  className,\n  children,\n  ...props\n}: ActivityFeedItemProps) {\n  return (\n    <div\n      data-slot=\"activity-feed-item\"\n      data-variant={variant}\n      className={cn(\n        \"relative grid grid-cols-[2rem_1fr] gap-x-3 pb-6 last:pb-0\",\n        // Timeline line on the left side — spans from avatar to next item\n        \"before:absolute before:left-[0.9375rem] before:top-8 before:bottom-0 before:w-px before:bg-border\",\n        // Hide the line on the last item\n        \"last:before:hidden\",\n        className\n      )}\n      {...props}\n    >\n      {/* Variant dot on the timeline */}\n      <div className=\"relative flex flex-col items-center\">\n        <div\n          className={cn(\n            \"z-10 mt-1.5 size-2 shrink-0 rounded-full ring-2 ring-background\",\n            variantDotClasses[variant]\n          )}\n          aria-hidden=\"true\"\n        />\n      </div>\n      <div className=\"flex min-w-0 flex-col gap-0.5\">{children}</div>\n    </div>\n  )\n}\n\n// --- ActivityFeedAvatar ---\n\nfunction ActivityFeedAvatar({\n  className,\n  ...props\n}: React.ComponentProps<\"div\">) {\n  return (\n    <div\n      data-slot=\"activity-feed-avatar\"\n      className={cn(\n        \"relative z-10 flex shrink-0 items-center justify-center\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\n// --- ActivityFeedContent ---\n\nfunction ActivityFeedContent({\n  className,\n  ...props\n}: React.ComponentProps<\"div\">) {\n  return (\n    <div\n      data-slot=\"activity-feed-content\"\n      className={cn(\"text-xs text-foreground\", className)}\n      {...props}\n    />\n  )\n}\n\n// --- ActivityFeedTimestamp ---\n\ntype ActivityFeedTimestampProps = Omit<\n  React.ComponentProps<\"time\">,\n  \"dateTime\"\n> & {\n  date: Date | string\n}\n\nfunction ActivityFeedTimestamp({\n  date,\n  className,\n  ...props\n}: ActivityFeedTimestampProps) {\n  const d = typeof date === \"string\" ? new Date(date) : date\n\n  return (\n    <time\n      data-slot=\"activity-feed-timestamp\"\n      dateTime={d.toISOString()}\n      className={cn(\"text-xs text-muted-foreground\", className)}\n      {...props}\n    >\n      {timeAgo(date)}\n    </time>\n  )\n}\n\nexport {\n  ActivityFeed,\n  ActivityFeedItem,\n  ActivityFeedAvatar,\n  ActivityFeedContent,\n  ActivityFeedTimestamp,\n  type ActivityVariant,\n  type ActivityFeedItemProps,\n  type ActivityFeedTimestampProps,\n}\n",
      "type": "registry:ui"
    }
  ],
  "docs": "Install @khaeli/foundation first: this item's styling lives in its tokens and [data-slot] rules.",
  "type": "registry:ui"
}