{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"orbiting-icons","type":"registry:block","title":"Orbiting icons","description":"Three counter-rotating rings of integration icons orbit a lens centre; hover, focus or tap a node to hold the orbit and read what it connects.","dependencies":["motion","lucide-react"],"registryDependencies":["utils"],"files":[{"path":"registry/prequel/orbiting-icons/orbiting-icons.tsx","type":"registry:component","content":"\"use client\";\n\nimport {\n  useId,\n  useState,\n  type CSSProperties,\n} from \"react\";\nimport {\n  AnimatePresence,\n  motion,\n  useReducedMotion,\n} from \"motion/react\";\nimport {\n  Boxes,\n  Braces,\n  Cloud,\n  Cpu,\n  Database,\n  GitBranch,\n  Globe,\n  Layers,\n  Lock,\n  Server,\n  Terminal,\n  Workflow,\n  type LucideIcon,\n} from \"lucide-react\";\nimport { cn } from \"@/lib/utils\";\n\nconst EASE: [number, number, number, number] = [0.22, 1, 0.36, 1];\n\n/* Each ring turns at its own pace; the icon inside turns back so the glyph\n   always stays upright. Hovering or focusing the stage holds the orbit still. */\nconst ORBIT_CSS = `\n@keyframes prequel-orbit-cw { to { transform: rotate(360deg); } }\n@keyframes prequel-orbit-ccw { to { transform: rotate(-360deg); } }\n@keyframes prequel-orbit-glint { to { transform: rotate(360deg); } }\n.prequel-orbit-ring-cw { animation: prequel-orbit-cw linear infinite; }\n.prequel-orbit-ring-ccw { animation: prequel-orbit-ccw linear infinite; }\n.prequel-orbit-fix-cw { animation: prequel-orbit-cw linear infinite; }\n.prequel-orbit-fix-ccw { animation: prequel-orbit-ccw linear infinite; }\n.prequel-orbit-glint { animation: prequel-orbit-glint 18s linear infinite; }\n.prequel-orbit-stage:hover .prequel-orbit-ring-cw,\n.prequel-orbit-stage:hover .prequel-orbit-ring-ccw,\n.prequel-orbit-stage:hover .prequel-orbit-fix-cw,\n.prequel-orbit-stage:hover .prequel-orbit-fix-ccw,\n.prequel-orbit-stage:focus-within .prequel-orbit-ring-cw,\n.prequel-orbit-stage:focus-within .prequel-orbit-ring-ccw,\n.prequel-orbit-stage:focus-within .prequel-orbit-fix-cw,\n.prequel-orbit-stage:focus-within .prequel-orbit-fix-ccw {\n  animation-play-state: paused;\n}\n@media (prefers-reduced-motion: reduce) {\n  .prequel-orbit-ring-cw,\n  .prequel-orbit-ring-ccw,\n  .prequel-orbit-fix-cw,\n  .prequel-orbit-fix-ccw,\n  .prequel-orbit-glint {\n    animation: none;\n  }\n}\n`;\n\n/* ------------------------------------------------------------------ */\n/* types                                                               */\n/* ------------------------------------------------------------------ */\n\nexport type OrbitingIconsItem = {\n  /** Stable key, also used as the accessible name. */\n  id: string;\n  label: string;\n  description: string;\n  icon: LucideIcon;\n  /** Ring index, 0 (inner) to 2 (outer). Defaults to a round-robin. */\n  ring?: 0 | 1 | 2;\n};\n\nexport type OrbitingIconsProps = {\n  className?: string;\n  /** Heading above the orbit. */\n  title?: string;\n  /** One short paragraph under the heading. */\n  description?: string;\n  /** The nodes placed on the three rings. */\n  items?: OrbitingIconsItem[];\n  /** Maximum diameter of the orbit, in pixels. Defaults to 460. */\n  size?: number;\n  /** Speed multiplier for every ring. Defaults to 1. */\n  speed?: number;\n};\n\n/* ------------------------------------------------------------------ */\n/* defaults                                                            */\n/* ------------------------------------------------------------------ */\n\nconst DEFAULT_ITEMS: OrbitingIconsItem[] = [\n  {\n    id: \"database\",\n    label: \"Database\",\n    description: \"Managed Postgres with point-in-time restore.\",\n    icon: Database,\n    ring: 0,\n  },\n  {\n    id: \"terminal\",\n    label: \"Terminal\",\n    description: \"Run scripts against any environment.\",\n    icon: Terminal,\n    ring: 0,\n  },\n  {\n    id: \"git-branch\",\n    label: \"Branches\",\n    description: \"Preview every branch on its own URL.\",\n    icon: GitBranch,\n    ring: 0,\n  },\n  {\n    id: \"cloud\",\n    label: \"Deploy\",\n    description: \"Ship to the edge in 40 seconds.\",\n    icon: Cloud,\n    ring: 1,\n  },\n  {\n    id: \"boxes\",\n    label: \"Components\",\n    description: \"Reusable pieces across every project.\",\n    icon: Boxes,\n    ring: 1,\n  },\n  {\n    id: \"workflow\",\n    label: \"Automations\",\n    description: \"Jobs that retry on their own.\",\n    icon: Workflow,\n    ring: 1,\n  },\n  {\n    id: \"braces\",\n    label: \"SDKs\",\n    description: \"Typed clients for every language.\",\n    icon: Braces,\n    ring: 1,\n  },\n  {\n    id: \"globe\",\n    label: \"Routing\",\n    description: \"Anycast routing across six regions.\",\n    icon: Globe,\n    ring: 2,\n  },\n  {\n    id: \"lock\",\n    label: \"Identity\",\n    description: \"SSO, SCIM and a full audit log.\",\n    icon: Lock,\n    ring: 2,\n  },\n  {\n    id: \"cpu\",\n    label: \"Compute\",\n    description: \"Dedicated capacity for long jobs.\",\n    icon: Cpu,\n    ring: 2,\n  },\n  {\n    id: \"server\",\n    label: \"Workers\",\n    description: \"Private workers inside your network.\",\n    icon: Server,\n    ring: 2,\n  },\n  {\n    id: \"layers\",\n    label: \"Cache\",\n    description: \"One cache shared by every service.\",\n    icon: Layers,\n    ring: 2,\n  },\n];\n\nconst RINGS = [\n  { radius: 27, duration: 46, direction: -1, offset: 18 },\n  { radius: 36, duration: 62, direction: 1, offset: 54 },\n  { radius: 42, duration: 78, direction: -1, offset: 30 },\n] as const;\n\n/* ------------------------------------------------------------------ */\n/* block                                                               */\n/* ------------------------------------------------------------------ */\n\nexport function OrbitingIcons({\n  className,\n  title = \"One orbit, every integration.\",\n  description = \"Connect the tools your team already runs on. Hover or focus a node to hold the orbit and read what it unlocks.\",\n  items = DEFAULT_ITEMS,\n  size = 460,\n  speed = 1,\n}: OrbitingIconsProps) {\n  const titleId = useId();\n  const reduce = Boolean(useReducedMotion());\n  const [selected, setSelected] = useState(0);\n  const [hovered, setHovered] = useState(false);\n  const [focused, setFocused] = useState(false);\n  const paused = hovered || focused;\n\n  const safeSpeed = Number.isFinite(speed) ? Math.max(0.25, speed) : 1;\n  const activeIndex = items.length > 0 ? Math.min(selected, items.length - 1) : -1;\n  const active = activeIndex >= 0 ? items[activeIndex] : undefined;\n  const ActiveIcon = active?.icon;\n\n  return (\n    <section\n      aria-labelledby={titleId}\n      className={cn(\n        \"min-w-0 overflow-hidden rounded-xl border border-border bg-card p-4 text-card-foreground sm:p-6\",\n        className\n      )}\n    >\n      <style>{ORBIT_CSS}</style>\n\n      <div className=\"flex flex-col gap-1 text-center\">\n        <h2\n          id={titleId}\n          className=\"text-balance text-[20px] font-semibold tracking-tight sm:text-[22px]\"\n        >\n          {title}\n        </h2>\n        <p className=\"mx-auto max-w-lg text-[13px] leading-relaxed text-muted-foreground\">\n          {description}\n        </p>\n      </div>\n\n      <div\n        className=\"prequel-orbit-stage relative mx-auto mt-5 aspect-square w-full\"\n        style={{ maxWidth: size }}\n        onPointerEnter={() => setHovered(true)}\n        onPointerLeave={() => setHovered(false)}\n        onFocusCapture={() => setFocused(true)}\n        onBlurCapture={(event) => {\n          if (!event.currentTarget.contains(event.relatedTarget as Node | null)) {\n            setFocused(false);\n          }\n        }}\n      >\n        {/* static ring tracks */}\n        <div aria-hidden=\"true\" className=\"absolute inset-[8%] rounded-full border border-border/70\" />\n        <div aria-hidden=\"true\" className=\"absolute inset-[14%] rounded-full border border-border/70\" />\n        <div aria-hidden=\"true\" className=\"absolute inset-[23%] rounded-full border border-border/70\" />\n\n        {RINGS.map((ring, ringIndex) => {\n          const ringItems = items\n            .map((item, index) => ({ item, index }))\n            .filter(({ item, index }) => (item.ring ?? index % 3) === ringIndex);\n          if (ringItems.length === 0) return null;\n\n          const duration = ring.duration / safeSpeed;\n          const ringClass = reduce\n            ? undefined\n            : ring.direction === 1\n              ? \"prequel-orbit-ring-cw\"\n              : \"prequel-orbit-ring-ccw\";\n          const fixClass = reduce\n            ? undefined\n            : ring.direction === 1\n              ? \"prequel-orbit-fix-ccw\"\n              : \"prequel-orbit-fix-cw\";\n          const durationStyle: CSSProperties = { animationDuration: `${duration}s` };\n\n          return (\n            <div\n              key={ringIndex}\n              className={cn(\"pointer-events-none absolute inset-0\", ringClass)}\n              style={durationStyle}\n            >\n              {ringItems.map(({ item, index }, position) => {\n                const degrees =\n                  ring.offset + (position / ringItems.length) * 360;\n                const radians = (degrees * Math.PI) / 180;\n                /* Round the percentage so server and client render the\n                   exact same style string (no hydration mismatch). */\n                const left = Math.round((50 + Math.cos(radians) * ring.radius) * 1000) / 1000;\n                const top = Math.round((50 + Math.sin(radians) * ring.radius) * 1000) / 1000;\n                const Icon = item.icon;\n                const isActive = index === activeIndex;\n\n                return (\n                  <span\n                    key={item.id}\n                    className=\"pointer-events-auto absolute -translate-x-1/2 -translate-y-1/2\"\n                    style={{ left: `${left}%`, top: `${top}%` }}\n                  >\n                    <button\n                      type=\"button\"\n                      aria-label={`${item.label}. ${item.description}`}\n                      aria-pressed={isActive}\n                      onClick={() => setSelected(index)}\n                      onFocus={() => setSelected(index)}\n                      className={cn(\n                        \"grid h-8 w-8 place-items-center rounded-full border bg-card transition-colors duration-200 sm:h-9 sm:w-9\",\n                        \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background\",\n                        isActive\n                          ? \"border-foreground text-foreground\"\n                          : \"border-border text-muted-foreground hover:border-muted-foreground/40 hover:text-foreground\",\n                        fixClass\n                      )}\n                      style={durationStyle}\n                    >\n                      <Icon className=\"h-3.5 w-3.5 sm:h-4 sm:w-4\" aria-hidden=\"true\" />\n                    </button>\n                  </span>\n                );\n              })}\n            </div>\n          );\n        })}\n\n        {/* centre lens, with the selected node repeated inside */}\n        <div\n          aria-hidden=\"true\"\n          className=\"absolute left-1/2 top-1/2 flex aspect-square w-[34%] -translate-x-1/2 -translate-y-1/2 flex-col items-center justify-center gap-1 rounded-full border border-border bg-card px-2 text-center\"\n        >\n          {!reduce ? (\n            <span className=\"prequel-orbit-glint absolute inset-0 rounded-full\">\n              <span className=\"absolute left-1/2 top-0 h-1.5 w-1.5 -translate-x-1/2 -translate-y-1/2 rounded-full bg-foreground\" />\n            </span>\n          ) : (\n            <span className=\"absolute left-1/2 top-0 h-1.5 w-1.5 -translate-x-1/2 -translate-y-1/2 rounded-full bg-foreground\" />\n          )}\n\n          <AnimatePresence mode=\"wait\" initial={false}>\n            <motion.span\n              key={active?.id ?? \"empty\"}\n              initial={reduce ? false : { opacity: 0, scale: 0.85 }}\n              animate={{ opacity: 1, scale: 1 }}\n              exit={reduce ? undefined : { opacity: 0, scale: 0.85 }}\n              transition={{ duration: reduce ? 0 : 0.2, ease: EASE }}\n              className=\"flex flex-col items-center gap-1\"\n            >\n              {ActiveIcon ? (\n                <ActiveIcon className=\"h-5 w-5 text-foreground\" aria-hidden=\"true\" />\n              ) : null}\n              {active ? (\n                <span className=\"max-w-full truncate text-[10.5px] font-medium text-foreground\">\n                  {active.label}\n                </span>\n              ) : null}\n            </motion.span>\n          </AnimatePresence>\n\n          <span className=\"flex items-center gap-1 text-[9.5px] text-muted-foreground\">\n            <span className=\"h-1 w-1 rounded-full bg-success\" />\n            {paused ? \"Paused\" : \"Connected\"}\n          </span>\n        </div>\n      </div>\n\n      <div className=\"mx-auto mt-4 min-h-[44px] max-w-md text-center\" aria-live=\"polite\">\n        <AnimatePresence mode=\"wait\" initial={false}>\n          <motion.div\n            key={active?.id ?? \"empty\"}\n            initial={reduce ? false : { opacity: 0, y: 4 }}\n            animate={{ opacity: 1, y: 0 }}\n            exit={reduce ? undefined : { opacity: 0, y: -4 }}\n            transition={{ duration: reduce ? 0 : 0.22, ease: EASE }}\n          >\n            {active ? (\n              <>\n                <p className=\"text-[13px] font-medium text-foreground\">{active.label}</p>\n                <p className=\"mx-auto mt-0.5 max-w-sm text-[11.5px] leading-relaxed text-muted-foreground\">\n                  {active.description}\n                </p>\n              </>\n            ) : (\n              <p className=\"text-[11.5px] text-muted-foreground\">\n                Add a few items to draw the orbit.\n              </p>\n            )}\n          </motion.div>\n        </AnimatePresence>\n      </div>\n    </section>\n  );\n}\n\n/* Ready-made instance for previews and docs. */\nexport function OrbitingIconsDemo() {\n  return <OrbitingIcons />;\n}\n\nexport default OrbitingIcons;\n"}]}