{
  "name": "thread-preview",
  "type": "registry:ui",
  "framework": "react",
  "title": "Thread Preview",
  "description": "The thread hanging off a message: its name, its reply count and the last thing said.",
  "files": [
    {
      "path": "ui/thread-preview.tsx",
      "content": "import * as React from \"react\"\n\nimport { cn } from \"@/lib/utils\"\n\n/*\n * The thread hanging off a message: its name, how many replies it holds, and\n * who spoke last. It is a link to somewhere else, so the whole card is one\n * control rather than a card with a link inside it — one tab stop, one target,\n * and the hover state belongs to all of it.\n */\nconst ThreadPreview = React.forwardRef<\n  HTMLAnchorElement,\n  React.AnchorHTMLAttributes<HTMLAnchorElement>\n>(({ className, ...props }, ref) => (\n  <a\n    ref={ref}\n    className={cn(\n      \"flex max-w-[440px] items-center gap-2 rounded-[var(--newt-radius-md)] bg-newt-bg-surface px-3 py-2 text-sm no-underline\",\n      \"transition-colors duration-fast ease-newt hover:bg-newt-bg-elevated\",\n      \"focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-newt-text-link\",\n      className\n    )}\n    {...props}\n  />\n))\nThreadPreview.displayName = \"ThreadPreview\"\n\n/*\n * The elbow that ties the card back to the message above it. Decorative: the\n * relationship is already in the markup, so it is hidden from a reader who is\n * not looking at it.\n */\nconst ThreadPreviewSpine = React.forwardRef<\n  HTMLSpanElement,\n  React.HTMLAttributes<HTMLSpanElement>\n>(({ className, ...props }, ref) => (\n  <span\n    ref={ref}\n    aria-hidden=\"true\"\n    className={cn(\n      \"block h-3 w-4 shrink-0 rounded-ss-[8px] border-s-2 border-t-2 border-newt-border\",\n      className\n    )}\n    {...props}\n  />\n))\nThreadPreviewSpine.displayName = \"ThreadPreviewSpine\"\n\nconst ThreadPreviewName = React.forwardRef<\n  HTMLSpanElement,\n  React.HTMLAttributes<HTMLSpanElement>\n>(({ className, ...props }, ref) => (\n  <span\n    ref={ref}\n    className={cn(\"truncate font-medium text-newt-text-link\", className)}\n    {...props}\n  />\n))\nThreadPreviewName.displayName = \"ThreadPreviewName\"\n\nexport interface ThreadPreviewCountProps extends React.HTMLAttributes<HTMLSpanElement> {\n  /** How many messages the thread holds. */\n  count: number\n  /** Builds the text from the count. Defaults to `1 message`, `3 messages`. */\n  formatCount?: (count: number) => string\n}\n\n/** The English default. Pass `formatCount` to translate it. */\nexport function defaultThreadPreviewCount(count: number): string {\n  return count === 1 ? \"1 message\" : `${count} messages`\n}\n\nconst ThreadPreviewCount = React.forwardRef<\n  HTMLSpanElement,\n  ThreadPreviewCountProps\n>(\n  (\n    { className, count, formatCount = defaultThreadPreviewCount, ...props },\n    ref\n  ) => (\n    <span\n      ref={ref}\n      className={cn(\n        \"shrink-0 text-xs font-medium tabular-nums text-newt-text-muted\",\n        className\n      )}\n      {...props}\n    >\n      {/* Spelled out rather than a bare number, which would read as an index. */}\n      {formatCount(count)}\n    </span>\n  )\n)\nThreadPreviewCount.displayName = \"ThreadPreviewCount\"\n\n/** The last thing said in the thread, which is why anyone opens it. */\nconst ThreadPreviewLast = React.forwardRef<\n  HTMLSpanElement,\n  React.HTMLAttributes<HTMLSpanElement>\n>(({ className, ...props }, ref) => (\n  <span\n    ref={ref}\n    className={cn(\"min-w-0 flex-1 truncate text-newt-text-muted\", className)}\n    {...props}\n  />\n))\nThreadPreviewLast.displayName = \"ThreadPreviewLast\"\n\nexport {\n  ThreadPreview,\n  ThreadPreviewCount,\n  ThreadPreviewLast,\n  ThreadPreviewName,\n  ThreadPreviewSpine,\n}\n",
      "type": "registry:ui"
    }
  ]
}