{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "illustration-05",
  "title": "Tab overload",
  "description": "A pile of five browser windows where one lifts with a hairline in the brand ink: the one under the pointer, or each in turn when nobody points.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/brand-logos.json",
    "https://ui.ndekocode.dev/r/theme.json",
    "https://ui.ndekocode.dev/r/use-agent-run.json",
    "https://ui.ndekocode.dev/r/use-prefers-reduced-motion.json",
    "https://ui.ndekocode.dev/r/utils.json"
  ],
  "files": [
    {
      "path": "registry/ndeko/components/illustration/illustration-05.tsx",
      "content": "'use client';\n\nimport { useMemo, useState } from 'react';\n\nimport { BrandLogo, type BrandSlug } from '@/registry/ndeko/lib/brand-logos';\nimport { cn } from '@/registry/ndeko/lib/utils';\n\nimport { useSceneFrames, type SceneFrame } from './_parts/use-scene-frames';\nimport { useScenePlay } from './_parts/use-scene-play';\n\nexport type OverloadWindow = {\n  id: string;\n  /** The site in the tab that is open. */\n  title: string;\n  brand: BrandSlug;\n  /** How many more tabs wait behind it. */\n  tabCount: number;\n};\n\ntype Slot = {\n  left: string;\n  top: string;\n};\n\n/** Where each window of the pile sits, back to front. The pile holds five windows at most. */\nconst SLOTS: Slot[] = [\n  { left: '4%', top: '8%' },\n  { left: '30%', top: '4%' },\n  { left: '14%', top: '26%' },\n  { left: '46%', top: '24%' },\n  { left: '26%', top: '44%' },\n];\n\n/** The order the highlight visits the slots when nobody points: never two neighbours in a row. */\nconst TOUR = [4, 1, 3, 0, 2];\n\nconst WANDER_MS = 1800;\n\nconst MAX_STUB_TABS = 6;\n\nconst DOTS = [0, 1, 2];\n\nfunction tourOf(windowCount: number) {\n  const visited = TOUR.filter((slot) => slot < windowCount);\n  const frames: SceneFrame<number>[] = visited.map((slot) => ({\n    state: slot,\n    holdMs: WANDER_MS,\n  }));\n  if (frames.length === 0) {\n    return [{ state: 0, holdMs: WANDER_MS }];\n  }\n  return frames;\n}\n\nfunction stubsOf(tabCount: number) {\n  const shown = Math.min(tabCount, MAX_STUB_TABS);\n  return Array.from({ length: shown }, (_, index) => index);\n}\n\nfunction labelOf(windows: OverloadWindow[]) {\n  const titles = windows.map((site) => site.title);\n  const list = titles.join(', ');\n  return `${windows.length} browser windows piled on each other: ${list}`;\n}\n\ntype BrowserWindowProps = {\n  site: OverloadWindow;\n  slot: Slot;\n  isLit: boolean;\n  onPoint: () => void;\n};\n\nfunction BrowserWindow({ site, slot, isLit, onPoint }: BrowserWindowProps) {\n  return (\n    <div\n      data-lit={isLit}\n      style={slot}\n      onPointerEnter={onPoint}\n      className='bg-card absolute h-[46%] w-[48%] rounded-lg transition-[translate] duration-300 ease-(--ease-out-strong) data-[lit=true]:-translate-y-1.5'\n    >\n      <span className='hairline-ring ring-border absolute inset-0 rounded-[inherit] shadow-[0_1px_2px_rgb(0_0_0/0.06)]' />\n      <span\n        data-lit={isLit}\n        className='hairline-ring ring-primary-ink absolute inset-0 rounded-[inherit] opacity-0 shadow-[0_4px_8px_-2px_rgb(0_0_0/0.06),0_12px_32px_-4px_rgb(0_0_0/0.1)] transition-opacity duration-300 ease-(--ease-out-strong) data-[lit=true]:opacity-100'\n      />\n      <div className='relative flex h-full flex-col overflow-hidden rounded-[inherit]'>\n        <div className='bg-foreground/[0.04] flex h-6 shrink-0 items-center gap-1.5 px-2'>\n          <span className='flex shrink-0 gap-1'>\n            {DOTS.map((dot) => (\n              <span\n                key={dot}\n                className='bg-foreground/15 size-1.5 rounded-full'\n              />\n            ))}\n          </span>\n          <span className='bg-card flex h-4 max-w-[70%] shrink-0 items-center gap-1 rounded-[5px] px-1.5'>\n            <BrandLogo brand={site.brand} className='size-2.5 shrink-0' />\n            <span className='truncate text-[10px] leading-none font-medium'>\n              {site.title}\n            </span>\n          </span>\n          <span className='flex min-w-0 gap-1.5 overflow-hidden'>\n            {stubsOf(site.tabCount).map((stub) => (\n              <span\n                key={stub}\n                className='bg-foreground/[0.07] h-2.5 w-4 shrink-0 rounded-[3px]'\n              />\n            ))}\n          </span>\n        </div>\n        <div className='flex min-h-0 flex-1 flex-col gap-1.5 p-2'>\n          <span className='bg-foreground/[0.09] h-1.5 w-3/5 shrink-0 rounded-full' />\n          <span className='bg-foreground/[0.05] h-1.5 w-full shrink-0 rounded-full' />\n          <span className='bg-foreground/[0.05] h-1.5 w-4/5 shrink-0 rounded-full' />\n          <span className='bg-foreground/[0.04] mt-0.5 min-h-0 flex-1 rounded-md' />\n        </div>\n      </div>\n    </div>\n  );\n}\n\nexport type TabOverloadProps = {\n  /** Back to front. The pile shows the first five. */\n  windows: OverloadWindow[];\n  className?: string;\n};\n\nexport function TabOverload({ windows, className }: TabOverloadProps) {\n  const { ref, isPlaying, isStill } = useScenePlay();\n  const [pointed, setPointed] = useState<number | null>(null);\n  const pile = windows.slice(0, SLOTS.length);\n  const tour = useMemo(() => tourOf(pile.length), [pile.length]);\n  const isWandering = isPlaying && pointed === null;\n  const wandering = useSceneFrames(tour, { isPlaying: isWandering, isStill });\n  const lit = pointed ?? wandering;\n\n  return (\n    <div\n      ref={ref}\n      role='img'\n      aria-label={labelOf(pile)}\n      onPointerLeave={() => setPointed(null)}\n      className={cn(\n        'bg-foreground/[0.03] relative aspect-[4/3] w-full max-w-[22rem] rounded-xl',\n        className\n      )}\n    >\n      {pile.map((site, index) => (\n        <BrowserWindow\n          key={site.id}\n          site={site}\n          slot={SLOTS[index]}\n          isLit={index === lit}\n          onPoint={() => setPointed(index)}\n        />\n      ))}\n    </div>\n  );\n}\n\nconst WINDOWS: OverloadWindow[] = [\n  { id: 'linear', title: 'Linear', brand: 'linear', tabCount: 5 },\n  { id: 'github', title: 'GitHub', brand: 'github', tabCount: 3 },\n  { id: 'notion', title: 'Notion', brand: 'notion', tabCount: 6 },\n  { id: 'figma', title: 'Figma', brand: 'figma', tabCount: 4 },\n  { id: 'gmail', title: 'Gmail', brand: 'gmail', tabCount: 6 },\n];\n\nexport default function Illustration05() {\n  return <TabOverload windows={WINDOWS} />;\n}\n",
      "type": "registry:component",
      "target": "components/illustration/illustration-05.tsx"
    },
    {
      "path": "registry/ndeko/components/illustration/_parts/use-scene-frames.ts",
      "content": "'use client';\n\nimport { useEffect, useState } from 'react';\n\nimport type { ScenePlay } from './use-scene-play';\n\nexport type SceneFrame<State> = {\n  state: State;\n  /** Milliseconds the scene stays in this state before the next one. */\n  holdMs: number;\n};\n\nfunction nextIndexOf(index: number, count: number) {\n  const next = index + 1;\n  return next % count;\n}\n\n/**\n * A scene told as a flipbook: whole states, each held for a while, played in a loop. The first frame\n * is the resting picture: it shows before the scene plays and under reduced motion. While the scene\n * does not play the book stays on its page and no timer is left. `frames` holds at least one frame.\n */\nexport function useSceneFrames<State>(\n  frames: readonly SceneFrame<State>[],\n  { isPlaying, isStill }: ScenePlay\n) {\n  const [index, setIndex] = useState(0);\n  const frameCount = frames.length;\n  const shownIndex = index % frameCount;\n  const frame = frames[shownIndex];\n  const holdMs = frame.holdMs;\n\n  useEffect(() => {\n    if (!isPlaying) {\n      return;\n    }\n    const timer = window.setTimeout(() => {\n      setIndex(nextIndexOf(shownIndex, frameCount));\n    }, holdMs);\n    return () => window.clearTimeout(timer);\n  }, [isPlaying, shownIndex, frameCount, holdMs]);\n\n  if (isStill) {\n    return frames[0].state;\n  }\n  return frame.state;\n}\n",
      "type": "registry:component",
      "target": "components/illustration/_parts/use-scene-frames.ts"
    },
    {
      "path": "registry/ndeko/components/illustration/_parts/use-scene-play.ts",
      "content": "'use client';\n\nimport { useInView } from 'motion/react';\nimport { useRef } from 'react';\n\nimport { useDocumentVisible } from '@/registry/ndeko/hooks/use-agent-run';\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\n\nconst IN_VIEW_SHARE = 0.3;\n\nexport type ScenePlay = {\n  /** True while a visitor can see the scene move: on screen, in a visible tab, without reduced motion. */\n  isPlaying: boolean;\n  /** True under reduced motion: the scene rests on its still frame. */\n  isStill: boolean;\n};\n\n/**\n * An illustration moves only while someone can see it. Everything that loops in a scene hangs on\n * `isPlaying`, so nothing runs off screen, in a hidden tab or under reduced motion.\n */\nexport function useScenePlay<Element extends HTMLElement = HTMLDivElement>() {\n  const ref = useRef<Element>(null);\n  const isInView = useInView(ref, { amount: IN_VIEW_SHARE });\n  const isTabVisible = useDocumentVisible();\n  const isStill = usePrefersReducedMotion();\n  const isOnScreen = isInView && isTabVisible;\n  const isPlaying = isOnScreen && !isStill;\n\n  return { ref, isPlaying, isStill };\n}\n",
      "type": "registry:component",
      "target": "components/illustration/_parts/use-scene-play.ts"
    }
  ],
  "categories": [
    "components",
    "illustration"
  ],
  "type": "registry:component"
}