Logo Assemble
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.
Source
components/kuchi/logo-assemble.tsx
1"use client";23import {4 Easing,5 getRemotionEnvironment,6 Img,7 interpolate,8 staticFile,9 useCurrentFrame,10 useVideoConfig,11} from "remotion";12import {13 Item,14 mixOklch,15 resolveFont,16 type KuchiTheme,17 useKuchiTheme,18 withAlpha,19} from "@/lib/kuchi-ui";2021/**22 * A logo build: a single ring of image cards revolves around the centre, then23 * spins inward and vanishes into the middle — giving birth to a simple logo and24 * the brand name. One circle, no colour on the mark; the images do the motion.25 */2627export interface LogoAssembleProps {28 /** The logo mark (kept simple/monochrome — it sits on the dark backdrop). */29 logoSrc?: string;30 /** Brand name that appears to the right of the logo. */31 brandName?: string;32 /** Text held in the middle of the ring while the images revolve (\n for lines). */33 middleText?: string;34 /** Image URLs for the ring, cycled around the circle. */35 images?: string[];36 /** How many cards ride the ring. */37 count?: number;38 /** Backdrop color. Overrides the design system's `background`. */39 background?: string;40 speed?: number;41 className?: string;42 /** Design-system token overrides. */43 theme?: Partial<KuchiTheme>;44 /**45 * Defaults to `"dark"`: the shipped `logoSrc` is a white mark, so the stage46 * has to be dark for it to read. Pass `"light"` with a dark logo asset.47 */48 mode?: "light" | "dark";49 /**50 * The face this scene paints its words in — a label from `fonts.ts`51 * ("Inter", "Space Grotesk", "Instrument Serif") or a CSS family you have52 * loaded yourself. Unset, the scene keeps the face it was designed around.53 *54 * Overrides `theme.fontFamily`, which is how a brand kit re-skins a whole55 * timeline from one value.56 */57 fontFamily?: string;58}5960const FONT_FAMILY =61 'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif';6263/** Sample images. Absolute, because a root-relative default becomes64 * `staticFile()` in a render and 404s in the project this file was just65 * copied into. Pass your own — root-relative or remote, both resolve. */66const DEFAULT_IMAGES = [67 "https://kuchi-media.kalarislabs.com/components/art/art-11.svg",68 "https://kuchi-media.kalarislabs.com/components/art/art-11.svg",69 "https://kuchi-media.kalarislabs.com/components/art/art-02.svg",70 "https://kuchi-media.kalarislabs.com/components/art/art-08.svg",71 "https://kuchi-media.kalarislabs.com/components/art/art-08.svg",72 "https://kuchi-media.kalarislabs.com/components/art/art-07.svg",73 "https://kuchi-media.kalarislabs.com/components/art/art-07.svg",74 "https://kuchi-media.kalarislabs.com/components/art/art-02.svg",75];7677// ─── Timeline (frames @ 30fps; ~3.6s) ──────────────────────────────────────────78/** The ring spins inward from here (radius → 0, cards vanish). */79export const CONTRACT_START = 50;80export const CONTRACT_END = 66;81/** The middle text fades out as the ring collapses. */82export const MIDDLE_OUT = 52;83/** The logo is born at the centre, then slides left to make room for the name. */84export const LOGO_IN = 58;85export const LOGO_SHIFT_START = 74;86export const LOGO_SHIFT_END = 90;87/** The name reveals in step with the slide — the logo moving and the name88 * coming happen simultaneously, not one after the other. */89export const NAME_IN = LOGO_SHIFT_START;9091/** Base angular speed of the ring (radians / frame). */92export const ORBIT_SPEED = 0.1;93/** Extra spin added as the ring drains inward — the dr, water-down-the-plughole. */94export const DRAIN_SPIN = Math.PI * 1.1;95const CARD_RATIO = 1.22; // portrait cards9697export const EASE = Easing.bezier(0.2, 0.6, 0.35, 1);98/** Accelerate into the centre — the collapse, not a drift. */99export const EASE_IN = Easing.bezier(0.5, 0, 0.75, 0.4);100const CLAMP = { extrapolateLeft: "clamp", extrapolateRight: "clamp" } as const;101102/** 0 while orbiting, 1 when fully drained to the centre. */103export function contractProgress(frame: number): number {104 return interpolate(frame, [CONTRACT_START, CONTRACT_END], [0, 1], {105 ...CLAMP,106 easing: EASE_IN,107 });108}109110/**111 * The ring's rotation (radians). Steady while orbiting, then a burst of extra112 * spin as it drains inward.113 */114export function orbitAngle(frame: number): number {115 return frame * ORBIT_SPEED + contractProgress(frame) * DRAIN_SPIN;116}117118/** Radius multiplier: 1 while orbiting, → 0 as the ring drains in. */119export function ringScale(frame: number): number {120 return 1 - contractProgress(frame);121}122123/** Card scale: full size on the ring, shrinking as it pulls to the centre. */124export function cardScale(frame: number): number {125 return 1 - 0.66 * contractProgress(frame);126}127128/** Card opacity: solid on the ring, vanishing near the end of the drain. */129export function cardOpacity(frame: number): number {130 return interpolate(frame, [CONTRACT_END - 8, CONTRACT_END], [1, 0], CLAMP);131}132133/** Center text: fades in early, holds through the orbit, out as the ring drains. */134export function middleTextOpacity(frame: number): number {135 return interpolate(136 frame,137 [6, 16, MIDDLE_OUT - 6, MIDDLE_OUT],138 [0, 1, 1, 0],139 CLAMP,140 );141}142143export interface LogoPose {144 opacity: number;145 scale: number;146}147148/** The logo is born at the centre — a small overshoot as the ring vanishes. */149export function logoPose(frame: number): LogoPose {150 return {151 opacity: interpolate(frame, [LOGO_IN, LOGO_IN + 8], [0, 1], CLAMP),152 scale: interpolate(153 frame,154 [LOGO_IN, LOGO_IN + 10, LOGO_IN + 18],155 [0.6, 1.05, 1],156 { ...CLAMP, easing: EASE },157 ),158 };159}160161/** Fraction the logo has slid from centre toward its left resting spot (0 → 1). */162export function logoShift(frame: number): number {163 return interpolate(frame, [LOGO_SHIFT_START, LOGO_SHIFT_END], [0, 1], {164 ...CLAMP,165 easing: EASE,166 });167}168169export interface NamePose {170 opacity: number;171 dx: number;172}173174/** Brand name: fades and slides in from the right, after the logo has moved. */175export function namePose(frame: number): NamePose {176 return {177 opacity: interpolate(frame, [NAME_IN, NAME_IN + 10], [0, 1], CLAMP),178 dx: interpolate(frame, [NAME_IN, NAME_IN + 12], [18, 0], {179 ...CLAMP,180 easing: EASE,181 }),182 };183}184185/** Rewrite root-relative assets through staticFile everywhere but the Player. */186function resolveSrc(src: string): string {187 const isLocal = src.startsWith("/") && !src.startsWith("//");188 if (!isLocal || getRemotionEnvironment().isPlayer) return src;189 // A value that already came out of staticFile() carries the static base190 // (`/static-<hash>/…`); running it through again would prefix it twice.191 const base = staticFile("_").slice(0, -2);192 if (base && src.startsWith(`${base}/`)) return src;193 try {194 return staticFile(src.replace(/^\/+/, ""));195 } catch {196 return src;197 }198}199200export function LogoAssemble({201 logoSrc = "https://kuchi-media.kalarislabs.com/components/art/mark-white.svg",202 brandName = "kuchi",203 middleText = "Cinematic components\nfor React",204 images = DEFAULT_IMAGES,205 count = 10,206 background,207 speed = 1,208 className,209 theme,210 mode,211 fontFamily,212}: LogoAssembleProps) {213 const frame = useCurrentFrame() * speed;214 const { width, height } = useVideoConfig();215 const t = useKuchiTheme(theme, mode ?? "dark");216 const face = resolveFont(fontFamily ?? t.fontFamily) ?? FONT_FAMILY;217 const stage = background ?? t.background;218 // A shadow is cast in the dark direction whatever the mode, so it is walked219 // from the stage toward black — not toward `foreground`, which is near-white220 // in dark mode and would light the card from below instead of grounding it.221 const cardShadow = withAlpha(mixOklch(stage, "#000", 0.75), 0.4);222 const cx = width / 2;223 const cy = height / 2;224 const short = Math.min(width, height);225 const isRendering = getRemotionEnvironment().isRendering;226227 const R = short * 0.36;228 // Smaller than the arc between cards, so the ring has clear gaps.229 const cardW = Math.round(short * 0.15);230 const cardH = cardW * CARD_RATIO;231232 const a = orbitAngle(frame);233 const rs = ringScale(frame);234 const cScale = cardScale(frame);235 const cOpacity = cardOpacity(frame);236 const middleOp = middleTextOpacity(frame);237 const logo = logoPose(frame);238 const shift = logoShift(frame);239 const name = namePose(frame);240 const n = Math.max(1, Math.floor(count));241242 // Logo slides from the centre to a left resting spot; the name sits to its right.243 const logoSize = Math.round(short * 0.125);244 const gap = Math.round(short * 0.035);245 const restX = short * 0.13; // how far left the logo settles246 const logoCX = cx - restX * shift;247 const nameLeft = cx - restX + logoSize / 2 + gap;248 const nameSize = Math.round(short * 0.055);249250 return (251 <div252 className={className}253 style={{254 position: "absolute",255 inset: 0,256 overflow: "hidden",257 backgroundColor: stage,258 fontFamily: face,259 textRendering: "geometricPrecision",260 }}261 >262 {/* The ring of images */}263 {cOpacity > 0 &&264 Array.from({ length: n }, (_, i) => {265 const theta = (i / n) * Math.PI * 2 + a;266 const x = cx + Math.cos(theta) * R * rs;267 const y = cy + Math.sin(theta) * R * rs;268 // The ring cycles `images`, so with more cards than images one269 // image rides it twice. Studio outlines its first card; the others270 // are only pictures of it.271 const k = i % images.length;272 // Cards stay upright and just revolve around the centre — no tangent273 // spin, so no image ever tips onto its side.274 return (275 <Item276 // biome-ignore lint/suspicious/noArrayIndexKey: the ring is a fixed positional set — the index IS the card's identity277 key={`card-${i}`}278 index={k}279 primary={i === k}280 >281 <div282 style={{283 position: "absolute",284 left: x - cardW / 2,285 top: y - cardH / 2,286 width: cardW,287 height: cardH,288 opacity: cOpacity,289 transform: `scale(${cScale})`,290 overflow: "hidden",291 borderRadius: 4,292 boxShadow: `0 14px 34px ${cardShadow}`,293 ...(isRendering ? {} : { willChange: "transform" as const }),294 }}295 >296 <Img297 src={resolveSrc(images[k] ?? images[0])}298 style={{299 position: "absolute",300 inset: 0,301 width: "100%",302 height: "100%",303 maxWidth: "none",304 objectFit: "cover",305 }}306 />307 </div>308 </Item>309 );310 })}311312 {/* Center text, held in the ring while the images revolve */}313 {middleOp > 0 && middleText && (314 <div315 style={{316 position: "absolute",317 left: cx - R,318 top: cy - cardH,319 width: R * 2,320 height: cardH * 2,321 display: "flex",322 alignItems: "center",323 justifyContent: "center",324 textAlign: "center",325 opacity: middleOp,326 color: t.foreground,327 fontSize: Math.round(short * 0.04),328 fontWeight: 600,329 lineHeight: 1.2,330 letterSpacing: "-0.02em",331 whiteSpace: "pre-line",332 }}333 >334 {middleText}335 </div>336 )}337338 {/* Simple logo, born at the centre, then sliding left */}339 {logo.opacity > 0 && (340 <Img341 src={resolveSrc(logoSrc)}342 style={{343 position: "absolute",344 left: logoCX - logoSize / 2,345 top: cy - logoSize / 2,346 width: logoSize,347 height: logoSize,348 maxWidth: "none",349 objectFit: "contain",350 opacity: logo.opacity,351 transform: `scale(${logo.scale})`,352 transformOrigin: "center center",353 }}354 />355 )}356357 {/* Brand name, revealed to the right of the settled logo */}358 {name.opacity > 0 && (359 <div360 style={{361 position: "absolute",362 left: nameLeft,363 top: cy - nameSize,364 height: nameSize * 2,365 display: "flex",366 alignItems: "center",367 opacity: name.opacity,368 transform: `translateX(${name.dx}px)`,369 color: t.foreground,370 fontSize: nameSize,371 fontWeight: 600,372 letterSpacing: "-0.02em",373 whiteSpace: "nowrap",374 }}375 >376 {brandName}377 </div>378 )}379 </div>380 );381}






