{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "swarm-loader-demo",
  "type": "registry:block",
  "title": "Swarm: Preloader",
  "description": "Particle Text Animation example, Preloader: A workspace loading: the brand mark starts as hollow rings and fills with solid dots as the load reports progress. A take on the particle effect (particles) and text animation (text effect). Fits hero, about, preloader and 404 page sections.",
  "author": "KeyframeUI <https://keyframeui.com>",
  "categories": [
    "hero",
    "about",
    "preloader",
    "404-page",
    "particle-effect",
    "text-animation",
    "text",
    "canvas"
  ],
  "docs": "Live preview, examples and props: https://keyframeui.com/components/swarm#swarm-loader-demo",
  "registryDependencies": [
    "https://keyframeui.com/r/swarm.json"
  ],
  "files": [
    {
      "path": "components/swarm-loader-demo.tsx",
      "type": "registry:component",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nimport { Swarm } from \"@/components/ui/swarm\";\n\n// Perihel's mark: an orbit broken at the top right, with its planet in the gap.\nconst MARK =\n  \"M22.625 9.153A11 11 0 1 1 14.847 1.375L13.812 5.239A7 7 0 1 0 18.761 10.188Z\" +\n  \"M18.364 3.036A2.6 2.6 0 1 1 18.364 8.236A2.6 2.6 0 1 1 18.364 3.036Z\";\n\n// What loading reports, as the share done, and how long each step takes in ms.\nconst STEPS: [number, number][] = [\n  [0.06, 500],\n  [0.19, 420],\n  [0.33, 640],\n  [0.41, 300],\n  [0.58, 520],\n  [0.66, 380],\n  [0.83, 600],\n  [0.92, 360],\n  [1, 480],\n];\n\nexport function SwarmLoaderDemo() {\n  const [progress, setProgress] = React.useState(0);\n  const [ready, setReady] = React.useState(false);\n  const [run, setRun] = React.useState(0);\n\n  // Walk the steps; a new run starts over from nothing.\n  React.useEffect(() => {\n    const timers: number[] = [];\n    let at = 700;\n    for (const [share, ms] of STEPS) {\n      at += ms;\n      timers.push(window.setTimeout(() => setProgress(share), at));\n    }\n    return () => timers.forEach(window.clearTimeout);\n  }, [run]);\n\n  const onSettle = React.useCallback(() => {\n    if (progress >= 1) setReady(true);\n  }, [progress]);\n\n  const again = () => {\n    setReady(false);\n    setProgress(0);\n    setRun((r) => r + 1);\n  };\n\n  const percent = Math.round(progress * 100);\n\n  return (\n    <div className=\"w-full max-w-md overflow-hidden rounded-2xl border border-zinc-950/10 bg-white text-zinc-950 dark:border-white/10 dark:bg-zinc-950 dark:text-white\">\n      <Swarm\n        path={MARK}\n        viewBox=\"0 0 24 24\"\n        fill={progress}\n        dotSize={5}\n        gap={1.5}\n        label=\"Perihel\"\n        dotClassName=\"text-[#ff2d87] dark:text-[#ff5ca8]\"\n        gradientClassName=\"text-[#ff8a00] dark:text-[#ffa53d]\"\n        ringClassName=\"text-zinc-300 dark:text-zinc-700\"\n        onSettle={onSettle}\n        className=\"aspect-square bg-zinc-100/70 dark:bg-white/[0.03]\"\n      />\n      <div className=\"flex items-center justify-between gap-4 border-t border-zinc-950/10 px-5 py-4 dark:border-white/10\">\n        <div className=\"min-w-0\">\n          <p className=\"text-sm font-medium tracking-tight\">{ready ? \"Your workspace is ready\" : \"Opening your workspace\"}</p>\n          <p className=\"mt-0.5 font-mono text-[11px] text-zinc-500 uppercase dark:text-zinc-400\">\n            {ready ? \"3 boards · 41 cards synced\" : \"Syncing boards and cards\"}\n          </p>\n        </div>\n        {ready ? (\n          <button\n            type=\"button\"\n            onClick={again}\n            className=\"shrink-0 rounded-full bg-zinc-950 px-3.5 py-1.5 font-mono text-xs text-white transition-colors hover:bg-zinc-800 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[#e0136f] dark:bg-white dark:text-zinc-950 dark:hover:bg-zinc-200 dark:focus-visible:outline-[#ff5ca8]\"\n          >\n            Load again\n          </button>\n        ) : (\n          <span\n            role=\"progressbar\"\n            aria-label=\"Loading\"\n            aria-valuemin={0}\n            aria-valuemax={100}\n            aria-valuenow={percent}\n            className=\"shrink-0 font-mono text-sm text-[#e0136f] tabular-nums dark:text-[#ff5ca8]\"\n          >\n            {String(percent).padStart(2, \"0\")}%\n          </span>\n        )}\n      </div>\n    </div>\n  );\n}\n"
    }
  ]
}