{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"logo-assemble","type":"registry:component","title":"Logo Assemble","description":"Logo reveal animation: image cards orbit and collapse into your logo and brand name. A single ring of image cards revolves around a centred title, then spins inward and drains to the middle — giving birth to a simple logo that slides left as the brand name reveals to its right.","dependencies":["remotion"],"docs":"Needs a Remotion project. If a frame renders black, the component is drawing on a transparent layer: put a background behind it, e.g. <AbsoluteFill style={{ background: \"#faf9f6\" }}><Component /></AbsoluteFill>. Pass mode=\"dark\" for dark frames.","registryDependencies":["https://kuchi.kalarislabs.com/r/kuchi-ui.json"],"files":[{"path":"components/kuchi/logo-assemble.tsx","type":"registry:component","target":"components/kuchi/logo-assemble.tsx","content":"/*! Portions Copyright (c) 2026 Sri Nath (snap-cn). MIT License. See THIRD_PARTY_LICENSES. */\n\"use client\";\r\n\r\nimport {\r\n  Easing,\r\n  getRemotionEnvironment,\r\n  Img,\r\n  interpolate,\r\n  staticFile,\r\n  useCurrentFrame,\r\n  useVideoConfig,\r\n} from \"remotion\";\r\nimport {\r\n  Item,\r\n  mixOklch,\r\n  resolveFont,\r\n  type KuchiTheme,\r\n  useKuchiTheme,\r\n  withAlpha,\r\n} from \"@/lib/kuchi-ui\";\r\n\r\n/**\r\n * A logo build: a single ring of image cards revolves around the centre, then\r\n * spins inward and vanishes into the middle — giving birth to a simple logo and\r\n * the brand name. One circle, no colour on the mark; the images do the motion.\r\n */\r\n\r\nexport interface LogoAssembleProps {\r\n  /** The logo mark (kept simple/monochrome — it sits on the dark backdrop). */\r\n  logoSrc?: string;\r\n  /** Brand name that appears to the right of the logo. */\r\n  brandName?: string;\r\n  /** Text held in the middle of the ring while the images revolve (\\n for lines). */\r\n  middleText?: string;\r\n  /** Image URLs for the ring, cycled around the circle. */\r\n  images?: string[];\r\n  /** How many cards ride the ring. */\r\n  count?: number;\r\n  /** Backdrop color. Overrides the design system's `background`. */\r\n  background?: string;\r\n  speed?: number;\r\n  className?: string;\r\n  /** Design-system token overrides. */\r\n  theme?: Partial<KuchiTheme>;\r\n  /**\r\n   * Defaults to `\"dark\"`: the shipped `logoSrc` is a white mark, so the stage\r\n   * has to be dark for it to read. Pass `\"light\"` with a dark logo asset.\r\n   */\r\n  mode?: \"light\" | \"dark\";\r\n  /**\r\n   * The face this scene paints its words in — a label from `fonts.ts`\r\n   * (\"Inter\", \"Space Grotesk\", \"Instrument Serif\") or a CSS family you have\r\n   * loaded yourself. Unset, the scene keeps the face it was designed around.\r\n   *\r\n   * Overrides `theme.fontFamily`, which is how a brand kit re-skins a whole\r\n   * timeline from one value.\r\n   */\r\n  fontFamily?: string;\r\n}\r\n\r\nconst FONT_FAMILY =\r\n  'Inter, -apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif';\r\n\r\n/** Sample images. Absolute, because a root-relative default becomes\r\n *  `staticFile()` in a render and 404s in the project this file was just\r\n *  copied into. Pass your own — root-relative or remote, both resolve. */\r\nconst DEFAULT_IMAGES = [\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-11.svg\",\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-11.svg\",\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-02.svg\",\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-08.svg\",\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-08.svg\",\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-07.svg\",\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-07.svg\",\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-02.svg\",\r\n];\r\n\r\n// ─── Timeline (frames @ 30fps; ~3.6s) ──────────────────────────────────────────\r\n/** The ring spins inward from here (radius → 0, cards vanish). */\r\nexport const CONTRACT_START = 50;\r\nexport const CONTRACT_END = 66;\r\n/** The middle text fades out as the ring collapses. */\r\nexport const MIDDLE_OUT = 52;\r\n/** The logo is born at the centre, then slides left to make room for the name. */\r\nexport const LOGO_IN = 58;\r\nexport const LOGO_SHIFT_START = 74;\r\nexport const LOGO_SHIFT_END = 90;\r\n/** The name reveals in step with the slide — the logo moving and the name\r\n *  coming happen simultaneously, not one after the other. */\r\nexport const NAME_IN = LOGO_SHIFT_START;\r\n\r\n/** Base angular speed of the ring (radians / frame). */\r\nexport const ORBIT_SPEED = 0.1;\r\n/** Extra spin added as the ring drains inward — the dr, water-down-the-plughole. */\r\nexport const DRAIN_SPIN = Math.PI * 1.1;\r\nconst CARD_RATIO = 1.22; // portrait cards\r\n\r\nexport const EASE = Easing.bezier(0.2, 0.6, 0.35, 1);\r\n/** Accelerate into the centre — the collapse, not a drift. */\r\nexport const EASE_IN = Easing.bezier(0.5, 0, 0.75, 0.4);\r\nconst CLAMP = { extrapolateLeft: \"clamp\", extrapolateRight: \"clamp\" } as const;\r\n\r\n/** 0 while orbiting, 1 when fully drained to the centre. */\r\nexport function contractProgress(frame: number): number {\r\n  return interpolate(frame, [CONTRACT_START, CONTRACT_END], [0, 1], {\r\n    ...CLAMP,\r\n    easing: EASE_IN,\r\n  });\r\n}\r\n\r\n/**\r\n * The ring's rotation (radians). Steady while orbiting, then a burst of extra\r\n * spin as it drains inward.\r\n */\r\nexport function orbitAngle(frame: number): number {\r\n  return frame * ORBIT_SPEED + contractProgress(frame) * DRAIN_SPIN;\r\n}\r\n\r\n/** Radius multiplier: 1 while orbiting, → 0 as the ring drains in. */\r\nexport function ringScale(frame: number): number {\r\n  return 1 - contractProgress(frame);\r\n}\r\n\r\n/** Card scale: full size on the ring, shrinking as it pulls to the centre. */\r\nexport function cardScale(frame: number): number {\r\n  return 1 - 0.66 * contractProgress(frame);\r\n}\r\n\r\n/** Card opacity: solid on the ring, vanishing near the end of the drain. */\r\nexport function cardOpacity(frame: number): number {\r\n  return interpolate(frame, [CONTRACT_END - 8, CONTRACT_END], [1, 0], CLAMP);\r\n}\r\n\r\n/** Center text: fades in early, holds through the orbit, out as the ring drains. */\r\nexport function middleTextOpacity(frame: number): number {\r\n  return interpolate(\r\n    frame,\r\n    [6, 16, MIDDLE_OUT - 6, MIDDLE_OUT],\r\n    [0, 1, 1, 0],\r\n    CLAMP,\r\n  );\r\n}\r\n\r\nexport interface LogoPose {\r\n  opacity: number;\r\n  scale: number;\r\n}\r\n\r\n/** The logo is born at the centre — a small overshoot as the ring vanishes. */\r\nexport function logoPose(frame: number): LogoPose {\r\n  return {\r\n    opacity: interpolate(frame, [LOGO_IN, LOGO_IN + 8], [0, 1], CLAMP),\r\n    scale: interpolate(\r\n      frame,\r\n      [LOGO_IN, LOGO_IN + 10, LOGO_IN + 18],\r\n      [0.6, 1.05, 1],\r\n      { ...CLAMP, easing: EASE },\r\n    ),\r\n  };\r\n}\r\n\r\n/** Fraction the logo has slid from centre toward its left resting spot (0 → 1). */\r\nexport function logoShift(frame: number): number {\r\n  return interpolate(frame, [LOGO_SHIFT_START, LOGO_SHIFT_END], [0, 1], {\r\n    ...CLAMP,\r\n    easing: EASE,\r\n  });\r\n}\r\n\r\nexport interface NamePose {\r\n  opacity: number;\r\n  dx: number;\r\n}\r\n\r\n/** Brand name: fades and slides in from the right, after the logo has moved. */\r\nexport function namePose(frame: number): NamePose {\r\n  return {\r\n    opacity: interpolate(frame, [NAME_IN, NAME_IN + 10], [0, 1], CLAMP),\r\n    dx: interpolate(frame, [NAME_IN, NAME_IN + 12], [18, 0], {\r\n      ...CLAMP,\r\n      easing: EASE,\r\n    }),\r\n  };\r\n}\r\n\r\n/** Rewrite root-relative assets through staticFile everywhere but the Player. */\r\nfunction resolveSrc(src: string): string {\r\n  const isLocal = src.startsWith(\"/\") && !src.startsWith(\"//\");\r\n  if (!isLocal || getRemotionEnvironment().isPlayer) return src;\r\n  // A value that already came out of staticFile() carries the static base\r\n  // (`/static-<hash>/…`); running it through again would prefix it twice.\r\n  const base = staticFile(\"_\").slice(0, -2);\r\n  if (base && src.startsWith(`${base}/`)) return src;\r\n  try {\r\n    return staticFile(src.replace(/^\\/+/, \"\"));\r\n  } catch {\r\n    return src;\r\n  }\r\n}\r\n\r\nexport function LogoAssemble({\r\n  logoSrc = \"https://kuchi-media.kalarislabs.com/components/art/mark-white.svg\",\r\n  brandName = \"kuchi\",\r\n  middleText = \"Cinematic components\\nfor React\",\r\n  images = DEFAULT_IMAGES,\r\n  count = 10,\r\n  background,\r\n  speed = 1,\r\n  className,\r\n  theme,\r\n  mode,\r\n  fontFamily,\r\n}: LogoAssembleProps) {\r\n  const frame = useCurrentFrame() * speed;\r\n  const { width, height } = useVideoConfig();\r\n  const t = useKuchiTheme(theme, mode ?? \"dark\");\r\n  const face = resolveFont(fontFamily ?? t.fontFamily) ?? FONT_FAMILY;\r\n  const stage = background ?? t.background;\r\n  // A shadow is cast in the dark direction whatever the mode, so it is walked\r\n  // from the stage toward black — not toward `foreground`, which is near-white\r\n  // in dark mode and would light the card from below instead of grounding it.\r\n  const cardShadow = withAlpha(mixOklch(stage, \"#000\", 0.75), 0.4);\r\n  const cx = width / 2;\r\n  const cy = height / 2;\r\n  const short = Math.min(width, height);\r\n  const isRendering = getRemotionEnvironment().isRendering;\r\n\r\n  const R = short * 0.36;\r\n  // Smaller than the arc between cards, so the ring has clear gaps.\r\n  const cardW = Math.round(short * 0.15);\r\n  const cardH = cardW * CARD_RATIO;\r\n\r\n  const a = orbitAngle(frame);\r\n  const rs = ringScale(frame);\r\n  const cScale = cardScale(frame);\r\n  const cOpacity = cardOpacity(frame);\r\n  const middleOp = middleTextOpacity(frame);\r\n  const logo = logoPose(frame);\r\n  const shift = logoShift(frame);\r\n  const name = namePose(frame);\r\n  const n = Math.max(1, Math.floor(count));\r\n\r\n  // Logo slides from the centre to a left resting spot; the name sits to its right.\r\n  const logoSize = Math.round(short * 0.125);\r\n  const gap = Math.round(short * 0.035);\r\n  const restX = short * 0.13; // how far left the logo settles\r\n  const logoCX = cx - restX * shift;\r\n  const nameLeft = cx - restX + logoSize / 2 + gap;\r\n  const nameSize = Math.round(short * 0.055);\r\n\r\n  return (\r\n    <div\r\n      className={className}\r\n      style={{\r\n        position: \"absolute\",\r\n        inset: 0,\r\n        overflow: \"hidden\",\r\n        backgroundColor: stage,\r\n        fontFamily: face,\r\n        textRendering: \"geometricPrecision\",\r\n      }}\r\n    >\r\n      {/* The ring of images */}\r\n      {cOpacity > 0 &&\r\n        Array.from({ length: n }, (_, i) => {\r\n          const theta = (i / n) * Math.PI * 2 + a;\r\n          const x = cx + Math.cos(theta) * R * rs;\r\n          const y = cy + Math.sin(theta) * R * rs;\r\n          // The ring cycles `images`, so with more cards than images one\r\n          // image rides it twice. Studio outlines its first card; the others\r\n          // are only pictures of it.\r\n          const k = i % images.length;\r\n          // Cards stay upright and just revolve around the centre — no tangent\r\n          // spin, so no image ever tips onto its side.\r\n          return (\r\n            <Item\r\n              // biome-ignore lint/suspicious/noArrayIndexKey: the ring is a fixed positional set — the index IS the card's identity\r\n              key={`card-${i}`}\r\n              index={k}\r\n              primary={i === k}\r\n            >\r\n              <div\r\n                style={{\r\n                  position: \"absolute\",\r\n                  left: x - cardW / 2,\r\n                  top: y - cardH / 2,\r\n                  width: cardW,\r\n                  height: cardH,\r\n                  opacity: cOpacity,\r\n                  transform: `scale(${cScale})`,\r\n                  overflow: \"hidden\",\r\n                  borderRadius: 4,\r\n                  boxShadow: `0 14px 34px ${cardShadow}`,\r\n                  ...(isRendering ? {} : { willChange: \"transform\" as const }),\r\n                }}\r\n              >\r\n                <Img\r\n                  src={resolveSrc(images[k] ?? images[0])}\r\n                  style={{\r\n                    position: \"absolute\",\r\n                    inset: 0,\r\n                    width: \"100%\",\r\n                    height: \"100%\",\r\n                    maxWidth: \"none\",\r\n                    objectFit: \"cover\",\r\n                  }}\r\n                />\r\n              </div>\r\n            </Item>\r\n          );\r\n        })}\r\n\r\n      {/* Center text, held in the ring while the images revolve */}\r\n      {middleOp > 0 && middleText && (\r\n        <div\r\n          style={{\r\n            position: \"absolute\",\r\n            left: cx - R,\r\n            top: cy - cardH,\r\n            width: R * 2,\r\n            height: cardH * 2,\r\n            display: \"flex\",\r\n            alignItems: \"center\",\r\n            justifyContent: \"center\",\r\n            textAlign: \"center\",\r\n            opacity: middleOp,\r\n            color: t.foreground,\r\n            fontSize: Math.round(short * 0.04),\r\n            fontWeight: 600,\r\n            lineHeight: 1.2,\r\n            letterSpacing: \"-0.02em\",\r\n            whiteSpace: \"pre-line\",\r\n          }}\r\n        >\r\n          {middleText}\r\n        </div>\r\n      )}\r\n\r\n      {/* Simple logo, born at the centre, then sliding left */}\r\n      {logo.opacity > 0 && (\r\n        <Img\r\n          src={resolveSrc(logoSrc)}\r\n          style={{\r\n            position: \"absolute\",\r\n            left: logoCX - logoSize / 2,\r\n            top: cy - logoSize / 2,\r\n            width: logoSize,\r\n            height: logoSize,\r\n            maxWidth: \"none\",\r\n            objectFit: \"contain\",\r\n            opacity: logo.opacity,\r\n            transform: `scale(${logo.scale})`,\r\n            transformOrigin: \"center center\",\r\n          }}\r\n        />\r\n      )}\r\n\r\n      {/* Brand name, revealed to the right of the settled logo */}\r\n      {name.opacity > 0 && (\r\n        <div\r\n          style={{\r\n            position: \"absolute\",\r\n            left: nameLeft,\r\n            top: cy - nameSize,\r\n            height: nameSize * 2,\r\n            display: \"flex\",\r\n            alignItems: \"center\",\r\n            opacity: name.opacity,\r\n            transform: `translateX(${name.dx}px)`,\r\n            color: t.foreground,\r\n            fontSize: nameSize,\r\n            fontWeight: 600,\r\n            letterSpacing: \"-0.02em\",\r\n            whiteSpace: \"nowrap\",\r\n          }}\r\n        >\r\n          {brandName}\r\n        </div>\r\n      )}\r\n    </div>\r\n  );\r\n}\r\n"}]}