{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"logo-drift","type":"registry:component","title":"Logo Drift","description":"Logo wall animation: a logo cloud of integrations drifting behind a headline. A field of tiles drifting past a headline while the camera pulls steadily back, so the wall of things-it-works-with keeps arriving from every edge.","dependencies":["remotion","@remotion/google-fonts"],"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-drift.tsx","type":"registry:component","target":"components/kuchi/logo-drift.tsx","content":"/*! Portions Copyright (c) 2026 Sri Nath (snap-cn). MIT License. See THIRD_PARTY_LICENSES. */\n\"use client\";\r\n\r\nimport { loadFont as loadSans } from \"@remotion/google-fonts/Inter\";\r\nimport {\r\n  AbsoluteFill,\r\n  Easing,\r\n  getRemotionEnvironment,\r\n  interpolate,\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// Loaded through @remotion/google-fonts, never a CSS variable — a Remotion\r\n// bundle has none of the app's CSS, so a `var(--font-…)` gets you the right face\r\n// in the Player and a fallback in the mp4 (design-system rule 4).\r\nconst { fontFamily: SANS } = loadSans(\"normal\", {\r\n  weights: [\"400\", \"500\", \"600\"],\r\n  subsets: [\"latin\"],\r\n});\r\n\r\n// --- The stage -------------------------------------------------------------\r\n//\r\n// The reference recording is 810×458 — near enough 16:9 — and every number\r\n// below was read off its frames, so there is no second conversion to get wrong.\r\n// `stageScale` fits this rectangle into whatever composition it is given.\r\n\r\nconst REF_W = 810;\r\nconst REF_H = 458;\r\n\r\n// --- Measured timeline, in seconds -----------------------------------------\r\n\r\n/** Per-word entrance: it arrives 22% large and 4.3px soft, and lands in 140ms. */\r\nconst WORD_DUR = 0.14;\r\nconst WORD_SCALE = 1.216;\r\nconst WORD_BLUR = 4.3;\r\n/** Exit: the line recedes to 0.80, blurs to 6.5px and goes. */\r\nconst EXIT_DUR = 0.34;\r\nconst EXIT_SCALE = 0.8;\r\nconst EXIT_BLUR = 6.5;\r\n\r\n/** The entrance eases hard out — half the distance in the first quarter. */\r\nconst WORD_EASE = Easing.out(Easing.quad);\r\n\r\n// --- Pure helpers (unit-tested) --------------------------------------------\r\n\r\n/**\r\n * The pull-back, as a plain linear scale on the whole tile field.\r\n *\r\n * This is the measurement the whole component hangs off. Every tile in the\r\n * reference shrinks at the *same relative rate* — fit its on-screen size against\r\n * time and you get a straight line, and dividing that slope by the tile's own\r\n * size gives 0.176 per second for all seven tiles that are on screen long enough\r\n * to fit (spread: ±0.0016). Not a perspective dolly — `1/size` is visibly not\r\n * linear — just one linear scale over a field that is much bigger than the frame.\r\n */\r\nexport function pullbackScale(t: number, rate: number, floor = 0.02): number {\r\n  return Math.max(floor, 1 - rate * t);\r\n}\r\n\r\nexport interface DriftTile {\r\n  /** One to three characters, set large — a mark, not a paragraph. */\r\n  glyph: string;\r\n  /** Optional word under the glyph, for tiles big enough to carry one. */\r\n  label?: string;\r\n  background: string;\r\n  color?: string;\r\n  /** Position at t=0, in stage px from the centre, before the pull-back. */\r\n  x: number;\r\n  y: number;\r\n  /** Edge length at t=0, in stage px, before the pull-back. */\r\n  size: number;\r\n  /** Constant drift, in stage px per second. */\r\n  vx?: number;\r\n  vy?: number;\r\n  /** Seconds at which it starts fading up. */\r\n  at?: number;\r\n  /** Corner radius as a fraction of the tile's edge. Defaults to `tileRadius`. */\r\n  radius?: number;\r\n}\r\n\r\nexport interface PlacedTile {\r\n  left: number;\r\n  top: number;\r\n  size: number;\r\n  opacity: number;\r\n}\r\n\r\n/**\r\n * Where a tile is, how big, and how far up its fade has got.\r\n *\r\n * The field drifts *and* the camera pulls back, and those are two different\r\n * things: `x + vx·t` is where the tile has got to in the field, and the scale\r\n * outside it is the camera. Fitted that way, six of the reference's seven\r\n * long-lived tiles land within **0.3–1.0px per frame across their whole path**;\r\n * a static field (no drift) misses by 32px, and a perspective dolly cannot\r\n * produce a size that falls linearly at all.\r\n */\r\nexport function placeTile(\r\n  tile: DriftTile,\r\n  t: number,\r\n  o: { rate: number; fade: number; speed: number; scale: number },\r\n): PlacedTile {\r\n  const k = pullbackScale(t, o.rate);\r\n  const wx = tile.x + (tile.vx ?? 0) * o.speed * t;\r\n  const wy = tile.y + (tile.vy ?? 0) * o.speed * t;\r\n  const size = k * tile.size * o.scale;\r\n  const age = t - (tile.at ?? 0);\r\n  // An exponential approach, not a ramp: the reference's tiles are ~50% up\r\n  // 280ms after they appear and still creeping toward 1 a second later, which\r\n  // is the shape a `1 − e^(−age/τ)` gives and no linear fade does.\r\n  const opacity = age <= 0 ? 0 : 1 - Math.exp(-age / Math.max(1e-3, o.fade));\r\n  return {\r\n    left: REF_W / 2 + k * wx - size / 2,\r\n    top: REF_H / 2 + k * wy - size / 2,\r\n    size,\r\n    opacity,\r\n  };\r\n}\r\n\r\nexport interface WordState {\r\n  scale: number;\r\n  blur: number;\r\n  opacity: number;\r\n}\r\n\r\n/**\r\n * A word's entrance, and the whole line's exit, in one place.\r\n *\r\n * The entrance is **not** a fade. Measure the ink and it is conserved from the\r\n * first frame the word exists — what changes is that it is 1.216× too big and\r\n * carrying 4.3px of blur, both of which resolve in 140ms. Words land every\r\n * 150ms, so each one finishes exactly as the next begins.\r\n */\r\nexport function wordState(\r\n  t: number,\r\n  index: number,\r\n  o: {\r\n    at: number;\r\n    stagger: number;\r\n    dur: number;\r\n    scale: number;\r\n    blur: number;\r\n    exitAt: number;\r\n    exitDur: number;\r\n    exitScale: number;\r\n    exitBlur: number;\r\n  },\r\n): WordState {\r\n  const start = o.at + index * o.stagger;\r\n  if (t < start) return { scale: o.scale, blur: o.blur, opacity: 0 };\r\n  const p = interpolate(t, [start, start + o.dur], [0, 1], {\r\n    extrapolateLeft: \"clamp\",\r\n    extrapolateRight: \"clamp\",\r\n    easing: WORD_EASE,\r\n  });\r\n  const q = interpolate(t, [o.exitAt, o.exitAt + o.exitDur], [0, 1], {\r\n    extrapolateLeft: \"clamp\",\r\n    extrapolateRight: \"clamp\",\r\n  });\r\n  return {\r\n    scale: (o.scale + (1 - o.scale) * p) * (1 + (o.exitScale - 1) * q),\r\n    blur: o.blur * (1 - p) + o.exitBlur * q,\r\n    opacity: 1 - q,\r\n  };\r\n}\r\n\r\n// --- Content ---------------------------------------------------------------\r\n\r\n/**\r\n * The default field: the stack a kuchi component drops into.\r\n *\r\n * Positions, sizes, drifts and entry times are the ones fitted to the reference\r\n * recording, so the choreography is the measured one. The **labels and the paint\r\n * are ours** — a component that ships to strangers has no business carrying\r\n * somebody else's marks, and a wordmark tile says \"works with this\" without\r\n * borrowing a logo to say it.\r\n */\r\nexport const KUCHI_STACK: DriftTile[] = [\r\n  {\r\n    glyph: \"Rm\",\r\n    label: \"Remotion\",\r\n    background: \"#1f2430\",\r\n    color: \"#ffffff\",\r\n    x: 163,\r\n    y: 232,\r\n    vx: -54,\r\n    vy: 12,\r\n    size: 109,\r\n    at: 0.28,\r\n  },\r\n  {\r\n    glyph: \"sh\",\r\n    label: \"shadcn/ui\",\r\n    background: \"#f2f4f7\",\r\n    color: \"#16181d\",\r\n    x: 128,\r\n    y: -209,\r\n    vx: 81,\r\n    vy: 32,\r\n    size: 122,\r\n    at: 0.48,\r\n  },\r\n  {\r\n    glyph: \"Re\",\r\n    label: \"React\",\r\n    background: \"#10131a\",\r\n    color: \"#7dd3fc\",\r\n    x: -384,\r\n    y: 344,\r\n    vx: -27,\r\n    vy: -68,\r\n    size: 200,\r\n    at: 0.95,\r\n  },\r\n  {\r\n    glyph: \"N\",\r\n    label: \"Next.js\",\r\n    background: \"#e7e8ea\",\r\n    color: \"#16181d\",\r\n    x: 519,\r\n    y: 45,\r\n    vx: -31,\r\n    vy: 64,\r\n    size: 144,\r\n    at: 1.51,\r\n  },\r\n  {\r\n    glyph: \"tw\",\r\n    label: \"Tailwind\",\r\n    background: \"#f1ece2\",\r\n    color: \"#8a5a2b\",\r\n    x: -692,\r\n    y: -125,\r\n    vx: 41,\r\n    vy: -71,\r\n    size: 214,\r\n    at: 1.55,\r\n  },\r\n  {\r\n    glyph: \"Fg\",\r\n    label: \"Figma\",\r\n    background: \"#2b3a36\",\r\n    color: \"#ffffff\",\r\n    x: -350,\r\n    y: -339,\r\n    vx: 65,\r\n    vy: -26,\r\n    size: 188,\r\n    at: 1.75,\r\n  },\r\n  {\r\n    glyph: \"Mo\",\r\n    label: \"Motion\",\r\n    background: \"#f4703a\",\r\n    color: \"#ffffff\",\r\n    x: 672,\r\n    y: -277,\r\n    vx: 2,\r\n    vy: 81,\r\n    size: 256,\r\n    at: 1.76,\r\n  },\r\n  {\r\n    glyph: \"TS\",\r\n    label: \"TypeScript\",\r\n    background: \"#2f6fdb\",\r\n    color: \"#ffffff\",\r\n    x: -721,\r\n    y: 211,\r\n    vx: 9,\r\n    vy: -84,\r\n    size: 215,\r\n    at: 2.06,\r\n  },\r\n  {\r\n    glyph: \"▲\",\r\n    label: \"Vercel\",\r\n    background: \"#0b0b0d\",\r\n    color: \"#ffffff\",\r\n    x: 676,\r\n    y: 348,\r\n    vx: -65,\r\n    vy: 52,\r\n    size: 244,\r\n    at: 2.48,\r\n  },\r\n];\r\n\r\n// --- Props -----------------------------------------------------------------\r\n\r\nexport interface LogoDriftProps {\r\n  /** The line that writes itself, one word at a time. */\r\n  headline?: string;\r\n  /** The field. Positions are stage px from the centre, before the pull-back. */\r\n  tiles?: DriftTile[];\r\n\r\n  // --- Motion, in seconds and per-second rates. ---\r\n  /** How fast the camera pulls back, as a fraction of scale per second. */\r\n  pullback?: number;\r\n  /** Multiplies every tile's drift, and every tile's size. */\r\n  tileSpeed?: number;\r\n  tileScale?: number;\r\n  /** Time constant of a tile's fade-up. */\r\n  tileFade?: number;\r\n  /** Corner radius as a fraction of a tile's edge. */\r\n  tileRadius?: number;\r\n\r\n  /** When the first word lands, and the gap between words. */\r\n  wordAt?: number;\r\n  wordStagger?: number;\r\n  /** How long one word takes to land, and what it arrives as. */\r\n  wordDuration?: number;\r\n  wordScale?: number;\r\n  wordBlur?: number;\r\n\r\n  /** When the line leaves, over how long, and what it leaves as. */\r\n  exitAt?: number;\r\n  exitDuration?: number;\r\n  exitScale?: number;\r\n  exitBlur?: number;\r\n\r\n  // --- Size and paint. ---\r\n  /** Headline type size, in stage px. */\r\n  fontSize?: number;\r\n  fontWeight?: number;\r\n  /** Glyph size inside a tile, as a fraction of its edge. */\r\n  glyphScale?: number;\r\n  /** Show the soft wash behind the headline, and what colour it is. */\r\n  glow?: boolean;\r\n  glowColor?: string;\r\n  glowOpacity?: number;\r\n  /** Accent used for the wash when `glowColor` is not given. */\r\n  accentColor?: string;\r\n  theme?: Partial<KuchiTheme>;\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  speed?: number;\r\n}\r\n\r\n// --- Main composition ------------------------------------------------------\r\n\r\n/**\r\n * A field of tiles drifting past a headline while the camera pulls steadily\r\n * back, so the wall of things-it-works-with keeps arriving from every edge.\r\n *\r\n * ## Three measurements, and they are the component\r\n *\r\n * **The pull-back is one linear scale.** Every tile in the reference shrinks at\r\n * the same *relative* rate: fit on-screen size against time and it is a straight\r\n * line, and dividing the slope by the tile's own size gives **0.176 per second**\r\n * for every tile long enough to fit, to ±0.0016. It is not a perspective dolly —\r\n * under perspective `1/size` would be the straight line and it plainly is not.\r\n *\r\n * **The field drifts under it.** Take the scale out and each tile's path becomes\r\n * a straight world-line to within a pixel: a constant velocity, ~80 stage px per\r\n * second, in its own direction. Model it as a static field and you are 32px out;\r\n * model the drift and six of the seven fitted tiles land within **0.3–1.0px per\r\n * frame over their whole path**.\r\n *\r\n * **The words do not fade in.** Measure the ink and it is conserved from the\r\n * first frame a word exists. What resolves is 1.216× of scale and 4.3px of blur,\r\n * in 140ms, one word every 150ms — so each lands exactly as the next starts. The\r\n * line is centre-set, so the words already placed slide left to make room.\r\n *\r\n * ## What is not measured\r\n *\r\n * The labels and the paint. The reference is a specific product showing off a\r\n * specific set of other people's logos; none of that belongs in a component that\r\n * ships to strangers (design-system rule 5). The default field is the stack a\r\n * kuchi component actually drops into, drawn as wordmark tiles rather than\r\n * borrowed marks, and every tile — glyph, label, colour, position, drift, entry\r\n * — is a prop.\r\n */\r\nexport function LogoDrift({\r\n  headline = \"Built for the stack you already use.\",\r\n  tiles = KUCHI_STACK,\r\n  pullback = 0.1762,\r\n  tileSpeed = 1,\r\n  tileScale = 1,\r\n  tileFade = 0.4,\r\n  tileRadius = 0.02,\r\n  wordAt = 0.017,\r\n  wordStagger = 0.15,\r\n  wordDuration = WORD_DUR,\r\n  wordScale = WORD_SCALE,\r\n  wordBlur = WORD_BLUR,\r\n  exitAt = 3.13,\r\n  exitDuration = EXIT_DUR,\r\n  exitScale = EXIT_SCALE,\r\n  exitBlur = EXIT_BLUR,\r\n  fontSize = 20,\r\n  fontWeight = 500,\r\n  glyphScale = 0.34,\r\n  glow = true,\r\n  glowColor,\r\n  glowOpacity = 0.07,\r\n  accentColor,\r\n  theme,\r\n  mode,\r\n  fontFamily,\r\n  speed = 1,\r\n}: LogoDriftProps) {\r\n  const frame = useCurrentFrame();\r\n  const { width, height, fps } = useVideoConfig();\r\n  const t = useKuchiTheme(theme, mode);\r\n  const face = resolveFont(fontFamily ?? t.fontFamily) ?? SANS;\r\n  const accent = accentColor ?? t.primary;\r\n  const wash = glowColor ?? accent;\r\n\r\n  const now = (frame * speed) / fps;\r\n  const stageScale = Math.min(width / REF_W, height / REF_H);\r\n\r\n  const words = headline.split(/\\s+/).filter(Boolean);\r\n  const isRendering = getRemotionEnvironment().isRendering;\r\n  const willChange = isRendering ? undefined : (\"transform, filter\" as const);\r\n\r\n  return (\r\n    <AbsoluteFill style={{ background: t.background }}>\r\n      <div\r\n        style={{\r\n          position: \"absolute\",\r\n          left: \"50%\",\r\n          top: \"50%\",\r\n          width: REF_W,\r\n          height: REF_H,\r\n          transform: `translate(-50%, -50%) scale(${stageScale})`,\r\n          overflow: \"hidden\",\r\n          background: t.background,\r\n        }}\r\n      >\r\n        {/* The wash. Static — it does not move, breathe or follow the pull-back\r\n            on the reference, and a glow that animates under a headline reads as\r\n            a mistake rather than as light. Painted from the installer's accent\r\n            at a few percent, because at this strength it is a tint, not a shape:\r\n            the peak is seven luminance levels off the page. */}\r\n        {glow ? (\r\n          <div\r\n            style={{\r\n              position: \"absolute\",\r\n              left: 0,\r\n              top: 0,\r\n              width: REF_W,\r\n              height: REF_H,\r\n              background: `radial-gradient(${0.45 * REF_W}px ${0.34 * REF_H}px at 50% 49%, ${withAlpha(wash, glowOpacity)} 0%, transparent 74%)`,\r\n            }}\r\n          />\r\n        ) : null}\r\n\r\n        {/* ---- The field. Each tile is one object to Remotion Studio (`Item`),\r\n            numbered by its place in `tiles`. */}\r\n        {tiles.map((tile, i) => {\r\n          const p = placeTile(tile, now, {\r\n            rate: pullback,\r\n            fade: tileFade,\r\n            speed: tileSpeed,\r\n            scale: tileScale,\r\n          });\r\n          if (p.opacity <= 0.002 || p.size < 1) return null;\r\n          const fg = tile.color ?? t.background;\r\n          return (\r\n            <Item key={`${tile.glyph}-${tile.x}-${tile.y}`} index={i}>\r\n              <div\r\n                style={{\r\n                  position: \"absolute\",\r\n                  left: p.left,\r\n                  top: p.top,\r\n                  width: p.size,\r\n                  height: p.size,\r\n                  borderRadius: p.size * (tile.radius ?? tileRadius),\r\n                  background: tile.background,\r\n                  opacity: p.opacity,\r\n                  display: \"flex\",\r\n                  flexDirection: \"column\",\r\n                  alignItems: \"center\",\r\n                  justifyContent: \"center\",\r\n                  gap: p.size * 0.04,\r\n                  color: fg,\r\n                  fontFamily: face,\r\n                  overflow: \"hidden\",\r\n                  willChange,\r\n                }}\r\n              >\r\n                <span\r\n                  style={{\r\n                    fontSize: p.size * glyphScale,\r\n                    fontWeight: 600,\r\n                    lineHeight: 1,\r\n                    letterSpacing: \"-0.03em\",\r\n                    textRendering: \"geometricPrecision\",\r\n                  }}\r\n                >\r\n                  {tile.glyph}\r\n                </span>\r\n                {tile.label && p.size > 74 ? (\r\n                  <span\r\n                    style={{\r\n                      fontSize: p.size * 0.1,\r\n                      fontWeight: 500,\r\n                      lineHeight: 1,\r\n                      opacity: 0.72,\r\n                      textRendering: \"geometricPrecision\",\r\n                    }}\r\n                  >\r\n                    {tile.label}\r\n                  </span>\r\n                ) : null}\r\n              </div>\r\n            </Item>\r\n          );\r\n        })}\r\n\r\n        {/* ---- The headline. Above the field: a wall of logos that crosses the\r\n            one line the viewer is meant to read is a wall of logos that has won\r\n            an argument it should not have been in. */}\r\n        <div\r\n          style={{\r\n            position: \"absolute\",\r\n            left: 0,\r\n            top: 0,\r\n            width: REF_W,\r\n            height: REF_H,\r\n            display: \"flex\",\r\n            alignItems: \"center\",\r\n            justifyContent: \"center\",\r\n          }}\r\n        >\r\n          <div\r\n            style={{\r\n              display: \"flex\",\r\n              alignItems: \"baseline\",\r\n              justifyContent: \"center\",\r\n              gap: fontSize * 0.28,\r\n              fontFamily: face,\r\n              fontSize,\r\n              fontWeight,\r\n              lineHeight: 1.2,\r\n              letterSpacing: \"-0.012em\",\r\n              color: t.foreground,\r\n              whiteSpace: \"pre\",\r\n              textRendering: \"geometricPrecision\",\r\n            }}\r\n          >\r\n            {words.map((word, i) => {\r\n              const w = wordState(now, i, {\r\n                at: wordAt,\r\n                stagger: wordStagger,\r\n                dur: wordDuration,\r\n                scale: wordScale,\r\n                blur: wordBlur,\r\n                exitAt,\r\n                exitDur: exitDuration,\r\n                exitScale,\r\n                exitBlur,\r\n              });\r\n              return (\r\n                <span\r\n                  // biome-ignore lint/suspicious/noArrayIndexKey: words in a headline repeat, so the index is what makes each key unique\r\n                  key={`${word}-${i}`}\r\n                  style={{\r\n                    display: \"inline-block\",\r\n                    opacity: w.opacity,\r\n                    transform: `scale(${w.scale})`,\r\n                    filter: w.blur > 0.02 ? `blur(${w.blur}px)` : undefined,\r\n                    willChange,\r\n                  }}\r\n                >\r\n                  {word}\r\n                </span>\r\n              );\r\n            })}\r\n          </div>\r\n        </div>\r\n      </div>\r\n    </AbsoluteFill>\r\n  );\r\n}\r\n\r\n/** Kept for callers that want the accent-tinted tile default without a theme. */\r\nexport const driftTileTint = (t: KuchiTheme, amount: number): string =>\r\n  mixOklch(t.card, t.primary, amount);\r\n"}]}