{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "timeline-10",
  "title": "Activity feed",
  "description": "Who did what and how long ago, with an icon per action.",
  "dependencies": [],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/avatar.json",
    "https://ui.ndekocode.dev/r/icons.json",
    "https://ui.ndekocode.dev/r/recipes.json",
    "https://ui.ndekocode.dev/r/theme.json",
    "https://ui.ndekocode.dev/r/timeline.json",
    "https://ui.ndekocode.dev/r/utils.json"
  ],
  "files": [
    {
      "path": "registry/ndeko/components/timeline/timeline-10.tsx",
      "content": "import {\n  BookOpenIcon,\n  MessageCircleIcon,\n  PencilIcon,\n  PlusIcon,\n  type Icon,\n} from '@/registry/ndeko/lib/icons';\nimport { FOCUS_RING } from '@/registry/ndeko/lib/recipes';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { Avatar } from '@/registry/ndeko/ui/avatar';\nimport {\n  Timeline,\n  TimelineContent,\n  TimelineItem,\n} from '@/registry/ndeko/ui/timeline';\n\ntype ActionType = 'post' | 'reply' | 'edit' | 'create';\n\ntype Activity = {\n  id: number;\n  user: string;\n  action: ActionType;\n  secondsAgo: number;\n};\n\nconst ACTIONS: Record<ActionType, { icon: Icon; text: string }> = {\n  post: { icon: BookOpenIcon, text: 'wrote a new post' },\n  reply: { icon: MessageCircleIcon, text: 'replied to a comment' },\n  edit: { icon: PencilIcon, text: 'edited a post' },\n  create: { icon: PlusIcon, text: 'created a new project' },\n};\n\nconst ITEMS: Activity[] = [\n  {\n    id: 1,\n    user: 'Matt',\n    action: 'post',\n    secondsAgo: 59,\n  },\n  {\n    id: 2,\n    user: 'Matt',\n    action: 'reply',\n    secondsAgo: 180,\n  },\n  {\n    id: 3,\n    user: 'Matt',\n    action: 'edit',\n    secondsAgo: 300,\n  },\n  {\n    id: 4,\n    user: 'Matt',\n    action: 'create',\n    secondsAgo: 600,\n  },\n];\n\nconst SECONDS_PER_MINUTE = 60;\nconst SECONDS_PER_HOUR = 3600;\nconst SECONDS_PER_DAY = 86400;\n\nconst LINK = cn('rounded-sm hover:underline', FOCUS_RING);\n\nfunction countOf(value: number, unit: string) {\n  if (value === 1) {\n    return `1 ${unit} ago`;\n  }\n  return `${value} ${unit}s ago`;\n}\n\nfunction relativeTimeOf(secondsAgo: number) {\n  if (secondsAgo < SECONDS_PER_MINUTE) {\n    return countOf(secondsAgo, 'second');\n  }\n  if (secondsAgo < SECONDS_PER_HOUR) {\n    const minutes = Math.floor(secondsAgo / SECONDS_PER_MINUTE);\n    return countOf(minutes, 'minute');\n  }\n  if (secondsAgo < SECONDS_PER_DAY) {\n    const hours = Math.floor(secondsAgo / SECONDS_PER_HOUR);\n    return countOf(hours, 'hour');\n  }\n  const days = Math.floor(secondsAgo / SECONDS_PER_DAY);\n  return countOf(days, 'day');\n}\n\nexport default function Timeline10() {\n  return (\n    <div className='flex w-full flex-col gap-3'>\n      <div className='text-muted-foreground text-xs font-medium'>Activity</div>\n      <Timeline>\n        {ITEMS.map((item) => {\n          const action = ACTIONS[item.action];\n          return (\n            <TimelineItem\n              key={item.id}\n              step={item.id}\n              className='m-0! flex-row items-center gap-3 py-2.5!'\n            >\n              <action.icon className='text-muted-foreground size-4' />\n              <Avatar className='size-6' seed={item.user} />\n              <TimelineContent className='text-foreground'>\n                <a href='#' className={cn(LINK, 'font-medium')}>\n                  {item.user}\n                </a>{' '}\n                {action.text}{' '}\n                <a href='#' className={cn(LINK, 'text-muted-foreground')}>\n                  {relativeTimeOf(item.secondsAgo)}\n                </a>\n              </TimelineContent>\n            </TimelineItem>\n          );\n        })}\n      </Timeline>\n    </div>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "categories": [
    "components",
    "timeline"
  ],
  "type": "registry:component"
}