{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "card-06",
  "title": "Tag rows",
  "description": "A feature card whose rows of tags drift against each other behind faded edges, above a short headline, and hold still off screen and under the pointer.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/brand-logos.json",
    "https://ui.ndekocode.dev/r/brand-tile.json",
    "https://ui.ndekocode.dev/r/button.json",
    "https://ui.ndekocode.dev/r/card.json",
    "https://ui.ndekocode.dev/r/chat-motion.json",
    "https://ui.ndekocode.dev/r/icons.json",
    "https://ui.ndekocode.dev/r/theme.json",
    "https://ui.ndekocode.dev/r/use-agent-run.json",
    "https://ui.ndekocode.dev/r/use-kept-height.json",
    "https://ui.ndekocode.dev/r/use-prefers-reduced-motion.json",
    "https://ui.ndekocode.dev/r/utils.json"
  ],
  "files": [
    {
      "path": "registry/ndeko/components/card/card-06.tsx",
      "content": "'use client';\n\nimport { useInView } from 'motion/react';\nimport { useId, useRef, useState, type CSSProperties } from 'react';\n\nimport { useDocumentVisible } from '@/registry/ndeko/hooks/use-agent-run';\nimport { useKeptHeight } from '@/registry/ndeko/hooks/use-kept-height';\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport type { BrandSlug } from '@/registry/ndeko/lib/brand-logos';\nimport { PauseIcon, PlayIcon } from '@/registry/ndeko/lib/icons';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { BrandTile } from '@/registry/ndeko/ui/brand-tile';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport { Card } from '@/registry/ndeko/ui/card';\nimport { Swap } from '@/registry/ndeko/ui/chat-motion';\n\nimport { isKeyboardArrival } from './_parts/keys';\n\nexport type RowTag = {\n  id: string;\n  label: string;\n  /** A known product wears its own mark. Leave it out for a plain tag. */\n  brand?: BrandSlug;\n};\n\ntype RowStyle = CSSProperties & { '--marquee-duration': string };\n\n/** One full turn of a row, in seconds. Each row has its own, so two rows never move as one. */\nconst ROW_SECONDS = [52, 64, 58];\n\n/** A row holds at least this many tags per half, so a short list still fills the card from edge to edge. */\nconst MIN_TAGS_PER_HALF = 8;\n\nconst FADED_EDGES =\n  '[mask-image:linear-gradient(to_right,transparent,black_3rem,black_calc(100%_-_3rem),transparent)]';\n\nconst TRACK =\n  'flex w-max animate-marquee group-hover/tags:[animation-play-state:paused]';\n\nconst HALF = 'flex shrink-0 gap-2 pe-2';\n\nconst TAG =\n  'bg-foreground/[0.05] inline-flex h-7 shrink-0 items-center gap-1.5 rounded-full px-2.5 text-[13px] whitespace-nowrap';\n\nconst BRAND_TAG = 'ps-1';\n\nfunction durationOf(rowIndex: number) {\n  const slot = rowIndex % ROW_SECONDS.length;\n  const seconds = ROW_SECONDS[slot];\n  return `${seconds}s`;\n}\n\nfunction copiesOf(tagCount: number) {\n  if (tagCount === 0) {\n    return 0;\n  }\n  const needed = MIN_TAGS_PER_HALF / tagCount;\n  return Math.ceil(needed);\n}\n\nfunction directionOf(rowIndex: number) {\n  const remainder = rowIndex % 2;\n  const isOddRow = remainder === 1;\n  if (isOddRow) {\n    return '[animation-direction:reverse]';\n  }\n  return undefined;\n}\n\nfunction playStateOf(isPlaying: boolean) {\n  if (isPlaying) {\n    return undefined;\n  }\n  return '[animation-play-state:paused]';\n}\n\nfunction pauseLabelOf(isPaused: boolean) {\n  if (isPaused) {\n    return 'Play the tags';\n  }\n  return 'Pause the tags';\n}\n\ntype TagProps = {\n  tag: RowTag;\n  /** A tag drawn again to fill the row or to close the loop is not read a second time. */\n  isCopy: boolean;\n};\n\nfunction Tag({ tag, isCopy }: TagProps) {\n  const hasBrand = tag.brand !== undefined;\n\n  return (\n    <li aria-hidden={isCopy} className={cn(TAG, hasBrand && BRAND_TAG)}>\n      {tag.brand && <BrandTile brand={tag.brand} className='rounded-full' />}\n      {tag.label}\n    </li>\n  );\n}\n\ntype TagHalfProps = {\n  tags: RowTag[];\n  copies: number;\n  /** The second half only closes the loop: it repeats the first and stays out of the reading order. */\n  isRepeat: boolean;\n};\n\nfunction TagHalf({ tags, copies, isRepeat }: TagHalfProps) {\n  const rounds = Array.from({ length: copies }, (_, round) => round);\n\n  return (\n    <ul aria-hidden={isRepeat} className={HALF}>\n      {rounds.map((round) => {\n        const isLaterRound = round > 0;\n        const isCopy = isRepeat || isLaterRound;\n        return tags.map((tag) => (\n          <Tag key={`${round}-${tag.id}`} tag={tag} isCopy={isCopy} />\n        ));\n      })}\n    </ul>\n  );\n}\n\ntype TagRowProps = {\n  tags: RowTag[];\n  rowIndex: number;\n  isPlaying: boolean;\n};\n\nfunction TagRow({ tags, rowIndex, isPlaying }: TagRowProps) {\n  const copies = copiesOf(tags.length);\n  const rowStyle: RowStyle = { '--marquee-duration': durationOf(rowIndex) };\n\n  return (\n    <div className='flex overflow-hidden'>\n      <div\n        style={rowStyle}\n        className={cn(TRACK, directionOf(rowIndex), playStateOf(isPlaying))}\n      >\n        <TagHalf tags={tags} copies={copies} isRepeat={false} />\n        <TagHalf tags={tags} copies={copies} isRepeat />\n      </div>\n    </div>\n  );\n}\n\nexport type TagRowsCardProps = {\n  title: string;\n  description: string;\n  /** Each list is one row. Odd rows drift the other way. */\n  rows: RowTag[][];\n  className?: string;\n};\n\nexport function TagRowsCard({\n  title,\n  description,\n  rows,\n  className,\n}: TagRowsCardProps) {\n  const cardRef = useRef<HTMLDivElement>(null);\n  const titleId = useId();\n  const [isPaused, setIsPaused] = useState(false);\n  const isInView = useInView(cardRef, { amount: 0.3 });\n  const isVisible = useDocumentVisible();\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const isOnScreen = isInView && isVisible;\n  const isPlaying = isOnScreen && !isPaused;\n\n  function togglePause() {\n    setIsPaused((current) => !current);\n  }\n\n  /** The rows hold still for someone who arrives with the keyboard, and the button then offers to play them. */\n  function holdOnKeyboardFocus(event: React.FocusEvent<HTMLDivElement>) {\n    if (isKeyboardArrival(event)) {\n      setIsPaused(true);\n    }\n  }\n\n  return (\n    <Card\n      ref={cardRef}\n      role='group'\n      aria-labelledby={titleId}\n      onFocus={holdOnKeyboardFocus}\n      className={cn('group/tags w-full gap-5 overflow-hidden p-0', className)}\n    >\n      <div className={cn('flex flex-col gap-2 pt-5', FADED_EDGES)}>\n        {rows.map((tags, rowIndex) => (\n          <TagRow\n            key={rowIndex}\n            tags={tags}\n            rowIndex={rowIndex}\n            isPlaying={isPlaying}\n          />\n        ))}\n      </div>\n      <div className='flex items-end justify-between gap-3 px-5 pb-5'>\n        <div className='min-w-0'>\n          <h3 id={titleId} className='text-sm font-medium text-balance'>\n            {title}\n          </h3>\n          <p className='text-muted-foreground mt-1 text-[13px] leading-5'>\n            {description}\n          </p>\n        </div>\n        {!shouldReduceMotion && (\n          <Button\n            type='button'\n            variant='ghost'\n            size='icon-sm'\n            aria-label={pauseLabelOf(isPaused)}\n            onClick={togglePause}\n            className='text-muted-foreground -me-1.5 -mb-1'\n          >\n            <Swap swapKey={String(isPaused)}>\n              {isPaused && <PlayIcon />}\n              {!isPaused && <PauseIcon />}\n            </Swap>\n          </Button>\n        )}\n      </div>\n    </Card>\n  );\n}\n\nconst ROWS: RowTag[][] = [\n  [\n    { id: 'github', label: 'GitHub', brand: 'github' },\n    { id: 'linear', label: 'Linear', brand: 'linear' },\n    { id: 'notion', label: 'Notion', brand: 'notion' },\n    { id: 'figma', label: 'Figma', brand: 'figma' },\n    { id: 'sentry', label: 'Sentry', brand: 'sentry' },\n    { id: 'stripe', label: 'Stripe', brand: 'stripe' },\n    { id: 'vercel', label: 'Vercel', brand: 'vercel' },\n    { id: 'jira', label: 'Jira', brand: 'jira' },\n  ],\n  [\n    { id: 'commits', label: 'Commits' },\n    { id: 'issues', label: 'Issues' },\n    { id: 'designs', label: 'Design files' },\n    { id: 'errors', label: 'Errors' },\n    { id: 'payments', label: 'Payments' },\n    { id: 'deploys', label: 'Deploys' },\n    { id: 'meetings', label: 'Meetings' },\n    { id: 'documents', label: 'Documents' },\n  ],\n  [\n    { id: 'calendar', label: 'Google Calendar', brand: 'googlecalendar' },\n    { id: 'zoom', label: 'Zoom', brand: 'zoom' },\n    { id: 'discord', label: 'Discord', brand: 'discord' },\n    { id: 'asana', label: 'Asana', brand: 'asana' },\n    { id: 'trello', label: 'Trello', brand: 'trello' },\n    { id: 'zapier', label: 'Zapier', brand: 'zapier' },\n    { id: 'gitlab', label: 'GitLab', brand: 'gitlab' },\n    { id: 'hubspot', label: 'HubSpot', brand: 'hubspot' },\n  ],\n];\n\nexport default function Card06() {\n  const ref = useRef<HTMLDivElement>(null);\n\n  useKeptHeight(ref);\n\n  return (\n    <div ref={ref} className='min-h-[15.25rem] w-full max-w-[24rem]'>\n      <TagRowsCard\n        title='One timeline for the tools your team already uses'\n        description='Commits, issues, designs and payments land in the same place, in the order they happened.'\n        rows={ROWS}\n      />\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/card/card-06.tsx"
    },
    {
      "path": "registry/ndeko/components/card/_parts/keys.ts",
      "content": "/** The step an arrow key asks for along a row: -1 for Left, 1 for Right, 0 for any other key. */\nexport function sideStepOf(key: string) {\n  if (key === 'ArrowLeft') {\n    return -1;\n  }\n  if (key === 'ArrowRight') {\n    return 1;\n  }\n  return 0;\n}\n\n/** True when a press landed on a control inside a surface that also answers presses of its own. */\nexport function isOnControl(target: EventTarget) {\n  if (!(target instanceof Element)) {\n    return false;\n  }\n  return target.closest('button, a, input') !== null;\n}\n\n/** True when the keyboard brings focus into an element from outside it, not when focus moves within it. */\nexport function isKeyboardArrival(event: React.FocusEvent<HTMLElement>) {\n  const isKeyboardFocus = event.target.matches(':focus-visible');\n  const cameFromInside = event.currentTarget.contains(event.relatedTarget);\n  return isKeyboardFocus && !cameFromInside;\n}\n\n/**\n * A card that goes behind the others turns inert and would drop the focus it holds. Before a deck\n * turns from the keyboard, the group takes the focus, so the next arrow key still reaches it.\n */\nexport function holdFocusOutsideCards(group: HTMLElement) {\n  const focused = document.activeElement;\n  if (!(focused instanceof Element)) {\n    return;\n  }\n  const card = focused.closest('li');\n  if (!card) {\n    return;\n  }\n  if (group.contains(card)) {\n    group.focus();\n  }\n}\n",
      "type": "registry:component",
      "target": "components/card/_parts/keys.ts"
    }
  ],
  "categories": [
    "components",
    "card"
  ],
  "type": "registry:component"
}