{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "activity-feed",
  "title": "Activity Feed",
  "description": "Primitives for activity feeds: a list with connectors that line up with the markers, tinted icons by tone, an unread dot, a Mark all as read button, relative times and \"Today\" and \"Yesterday\" day headings that take a fixed now and a time zone, and grouping by day.",
  "registryDependencies": [
    "button",
    "https://www.dashboardblocks.com/r/radix/format.json"
  ],
  "files": [
    {
      "path": "registry/components/dashboardblocks/activity-feed.tsx",
      "content": "'use client'\n\nimport { IconPlaceholder } from '@/registry/icons/icon-placeholder'\nimport {\n  dayIn,\n  formatDate,\n  formatDayHeading,\n  formatRelativeTime,\n} from '@/registry/lib/dashboardblocks/format'\nimport type { ComponentProps, ReactNode } from 'react'\n\nimport { Button } from '@/components/ui/button'\n\nimport { cn } from '@/lib/utils'\n\ntype ActivityTone = 'neutral' | 'info' | 'success' | 'warning' | 'danger' | 'accent'\n\nconst activityToneClasses: Record<ActivityTone, string> = {\n  accent: 'bg-chart-2/15 text-foreground',\n  danger: 'bg-red-500/10 text-red-700 dark:text-red-400',\n  info: 'bg-sky-500/10 text-sky-700 dark:text-sky-400',\n  neutral: 'bg-muted text-foreground',\n  success: 'bg-emerald-500/10 text-emerald-700 dark:text-emerald-400',\n  warning: 'bg-orange-500/10 text-orange-700 dark:text-orange-400',\n}\n\nconst activityToneColors: Record<ActivityTone, string> = {\n  accent: 'var(--color-chart-2)',\n  danger: 'var(--color-red-600)',\n  info: 'var(--color-sky-600)',\n  neutral: 'var(--color-muted-foreground)',\n  success: 'var(--color-emerald-600)',\n  warning: 'var(--color-orange-500)',\n}\n\nfunction ActivityFeed({ className, ...props }: ComponentProps<'ol'>) {\n  return (\n    <ol className={cn('flex flex-col [--activity-marker:2rem]', className)} {...props} />\n  )\n}\n\ninterface ActivityFeedItemProps extends ComponentProps<'li'> {\n  /** Draws the line to the next item. `'done'` fills it in green, for a step that's finished. */\n  connector?: boolean | 'done'\n}\n\nfunction ActivityFeedItem({\n  children,\n  className,\n  connector = false,\n  ...props\n}: ActivityFeedItemProps) {\n  return (\n    <li\n      className={cn(\n        'relative flex gap-3 [&:last-child>[data-slot=activity-connector]]:hidden',\n        className,\n      )}\n      {...props}\n    >\n      {connector && (\n        <span\n          aria-hidden\n          data-slot='activity-connector'\n          className='bg-border absolute top-[calc(var(--activity-marker)+0.25rem)] bottom-1 left-[calc(var(--activity-marker)/2)] w-px -translate-x-1/2 overflow-hidden'\n        >\n          <span\n            className={cn(\n              'absolute inset-x-0 top-0 bg-emerald-600 transition-[height] duration-700 ease-out motion-reduce:transition-none dark:bg-emerald-400',\n              connector === 'done' ? 'h-full' : 'h-0',\n            )}\n          />\n        </span>\n      )}\n      {children}\n    </li>\n  )\n}\n\nfunction ActivityIcon({\n  className,\n  icon,\n  tone = 'neutral',\n}: {\n  className?: string\n  icon: ReactNode\n  /** @default 'neutral' */\n  tone?: ActivityTone\n}) {\n  return (\n    <span\n      aria-hidden\n      className={cn(\n        'ring-card relative flex size-(--activity-marker) shrink-0 items-center justify-center rounded-full ring-4 [&_svg]:size-4',\n        activityToneClasses[tone],\n        className,\n      )}\n    >\n      {icon}\n    </span>\n  )\n}\n\nfunction UnreadDot({\n  className,\n  label = 'Unread',\n}: {\n  className?: string\n  /** What the dot tells a screen reader, such as `Changed since you last looked`. */\n  label?: string\n}) {\n  return (\n    <span\n      className={cn(\n        'size-1.5 shrink-0 rounded-full bg-sky-600 dark:bg-sky-400',\n        className,\n      )}\n    >\n      <span className='sr-only'>{label}</span>\n    </span>\n  )\n}\n\nfunction MarkAllReadButton({\n  className,\n  disabled,\n  onClick,\n  variant = 'ghost',\n}: {\n  className?: string\n  disabled?: boolean\n  onClick: () => void\n  /** @default 'ghost' */\n  variant?: 'ghost' | 'outline'\n}) {\n  return (\n    <Button\n      className={className}\n      disabled={disabled}\n      onClick={onClick}\n      size='sm'\n      variant={variant}\n    >\n      <IconPlaceholder\n        lucide='CheckCheckIcon'\n        tabler='IconChecks'\n        hugeicons='TickDouble02Icon'\n        phosphor='ChecksIcon'\n        remixicon='RiCheckDoubleLine'\n        data-icon='inline-start'\n      />\n      Mark all as read\n    </Button>\n  )\n}\n\nfunction groupActivityByDay<T extends { at: Date }>(\n  items: T[],\n  now: Date,\n  timeZone = 'UTC',\n) {\n  const groups: { items: T[]; key: string; label: string }[] = []\n  for (const item of items) {\n    const key = dayIn(item.at, timeZone)\n    const group = groups.find((existing) => existing.key === key)\n    if (group) group.items.push(item)\n    else\n      groups.push({\n        items: [item],\n        key,\n        label: formatDayHeading(item.at, now, timeZone),\n      })\n  }\n  return groups\n}\n\ninterface ActivityTimeProps {\n  className?: string\n  date: Date\n  /** Pass a fixed date, so it renders the same on the server and in the browser. */\n  now: Date\n  /** @default 'UTC' */\n  timeZone?: string\n}\n\nfunction ActivityTime({ className, date, now, timeZone = 'UTC' }: ActivityTimeProps) {\n  return (\n    <time\n      dateTime={date.toISOString()}\n      title={formatDate(date, 'date-time', timeZone)}\n      className={cn('text-muted-foreground text-xs whitespace-nowrap', className)}\n    >\n      {formatRelativeTime(date, now, { timeZone })}\n    </time>\n  )\n}\n\nexport {\n  ActivityFeed,\n  ActivityFeedItem,\n  ActivityIcon,\n  ActivityTime,\n  MarkAllReadButton,\n  UnreadDot,\n  activityToneClasses,\n  activityToneColors,\n  groupActivityByDay,\n}\n\nexport type { ActivityFeedItemProps, ActivityTimeProps, ActivityTone }\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/activity-feed.tsx"
    }
  ],
  "type": "registry:component"
}
