Version Hero
A chrome 2.0 version numeral rises inside a glowing ring with Now available beneath.
Source
components/kuchi/version-hero.tsx
1"use client";23import { loadFont } from "@remotion/google-fonts/BricolageGrotesque";4import type React from "react";5import { useId } from "react";6import {7 AbsoluteFill,8 Easing,9 interpolate,10 useCurrentFrame,11 useVideoConfig,12} from "remotion";1314const { fontFamily: bricolage } = loadFont("normal", {15 weights: ["400", "500"],16 subsets: ["latin"],17});1819/**20 * gradients.sh "radial-glow" palette: [#f3f1ff, #9db4ff, #5a46cb, #1d1240].21 * On dark it is a disc of light rising behind the object and catching its22 * faces; on paper it tints the stage under the numeral.23 */24const GLOW = ["#f3f1ff", "#9db4ff", "#5a46cb", "#1d1240"] as const;2526export interface VersionHeroProps {27 /** The release number, rendered as the extruded object. */28 version?: string;29 /** Product name in the label under the numeral. */30 name?: string;31 /** Second half of the label. */32 label?: string;33 /** Replaces the label's name: by default the acme logo when `name` is "acme". */34 logo?: React.ReactNode;35 accent?: string;36 /** Text color of the label's name and logo; overrides the theme. */37 ink?: string;38 /** Background fill; "transparent" drops it. */39 background?: string;40 /** Typeface for the numeral and label. Load it yourself; Bricolage Grotesque by default. */41 fontFamily?: string;42 /** Extrusion depth of the numeral, as a share of its font size. */43 depth?: number;44 /** Frames between slices as the stack docks. */45 stagger?: number;46 grain?: boolean;47 /** Size of the numeral and label, around the frame's center. */48 scale?: number;49 /** Frames to hold the first frame before anything moves. */50 delay?: number;51 /** Playback multiplier. */52 speed?: number;53 /** Dark = brushed aluminium; light = matte paper stock. */54 theme?: "dark" | "light";55}5657const SLICES = 10;58const SUB = 4;5960const EASE_IO = Easing.bezier(0.65, 0, 0.35, 1);61const EASE_OUT = Easing.bezier(0.22, 1, 0.36, 1);62const CLAMP = {63 extrapolateLeft: "clamp",64 extrapolateRight: "clamp",65} as const;6667/** Horizontal streak noise: brushed metal grain. Low x frequency, high y. */68const BRUSHED = `url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='600' height='300'><filter id='b'><feTurbulence type='fractalNoise' baseFrequency='0.003 0.75' numOctaves='2' seed='4' stitchTiles='stitch'/><feColorMatrix values='1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0.2'/></filter><rect width='600' height='300' filter='url(%23b)'/></svg>")`;69/** Isotropic fibre noise: matte paper tooth. */70const PAPER = `url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='p'><feTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' seed='9' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.35 0 0 0 0 0.33 0 0 0 0 0.3 0 0 0 0.22 0'/></filter><rect width='240' height='240' filter='url(%23p)'/></svg>")`;7172const MATERIALS = {73 dark: {74 bg: "#050508",75 stageLight: "rgba(255,255,255,0.05)",76 /** Strength of the rising disc, and of its tint on the faces. */77 glow: 1,78 glowTint: 0.32,79 /** How much the inside of the disc fills with violet. */80 disc: 1,81 /** The rim of the disc, inside → out. */82 ring: [GLOW[0], GLOW[1], GLOW[2]],83 fg: "#F3F2EF",84 muted: "#8B8A90",85 hair: "rgba(255,255,255,0.18)",86 faceBase:87 "linear-gradient(180deg, #C4C7CD 0%, #A9ADB4 30%, #8D9199 52%, #9FA3AA 74%, #6E727A 100%)",88 faceTexture: BRUSHED,89 faceTextureSize: "600px 300px",90 plate: "#7D8088",91 side: [92 [0x5c, 0x5e, 0x65],93 [0x26, 0x27, 0x2b],94 ],95 sideFloor: [0x0d, 0x0d, 0x0f],96 spec: 0.9,97 specSide: 0.35,98 bevel: "rgba(255,255,255,0.75)",99 shadow: "rgba(0,0,0,0.85)",100 grain: 0.07,101 },102 light: {103 bg: "#F5F4F0",104 stageLight: "rgba(255,255,255,0.9)",105 glow: 0.8,106 glowTint: 0.16,107 disc: 0,108 ring: [GLOW[1], GLOW[2], GLOW[1]],109 fg: "#121214",110 muted: "#6E6C67",111 hair: "rgba(18,18,20,0.16)",112 faceBase: "linear-gradient(180deg, #FFFFFF 0%, #F8F7F3 45%, #EDEBE5 100%)",113 faceTexture: PAPER,114 faceTextureSize: "240px 240px",115 plate: "#E4E1DA",116 side: [117 [0xd6, 0xd2, 0xc8],118 [0xb3, 0xae, 0xa2],119 ],120 sideFloor: [0x8f, 0x8a, 0x7f],121 spec: 0.55,122 specSide: 0.25,123 bevel: "rgba(255,255,255,1)",124 shadow: "rgba(60,52,40,0.32)",125 grain: 0.045,126 },127} as const;128129type Material = (typeof MATERIALS)[keyof typeof MATERIALS];130131function mix(a: readonly number[], b: readonly number[], t: number) {132 const c = a.map((v, i) => Math.round(v + (b[i] - v) * t));133 return `rgb(${c[0]},${c[1]},${c[2]})`;134}135136/** A soft diagonal band of light at horizontal position `x` (0..1). */137function specBand(x: number, strength: number) {138 const c = x * 100;139 const a = `rgba(255,255,255,${strength})`;140 const h = `rgba(255,255,255,${strength * 0.28})`;141 return `linear-gradient(104deg, transparent ${c - 22}%, ${h} ${c - 9}%, ${a} ${c}%, ${h} ${c + 5}%, transparent ${c + 14}%)`;142}143144function Grain({ opacity }: { opacity: number }) {145 const id = `g${useId().replace(/[^a-zA-Z0-9_-]/g, "")}`;146 return (147 <svg148 width="100%"149 height="100%"150 style={{ position: "absolute", inset: 0, opacity }}151 aria-hidden152 >153 <filter id={id}>154 <feTurbulence155 type="fractalNoise"156 baseFrequency="0.9"157 numOctaves={2}158 seed={5}159 stitchTiles="stitch"160 />161 <feColorMatrix values="0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 0.9 0" />162 </filter>163 <rect width="100%" height="100%" filter={`url(#${id})`} />164 </svg>165 );166}167168/** Placeholder wordmark, 100 units per em, baseline at y = 0. Pass your own logo. */169/** Ink box of the outlined logo, in its own units; the R is `rW` wide. */170const LOGO = { x: 0, y: -76, w: 250, h: 77.5, rW: 0 } as const;171172/** The whole logo in one fill (a colour or a `url(#gradient)`). */173function LogoPaths({ fill }: { fill: string }) {174 return (175 <text x={0} y={0} fill={fill} fontFamily="Manrope, Inter, sans-serif" fontWeight={600} fontSize={100} letterSpacing={-2.5}>176 Acme177 </text>178 );179}180181/** The logo at a font size, sitting on the label's baseline. */182function Logo({ size, color }: { size: number; color: string }) {183 const k = size / 100;184 return (185 <svg186 width={LOGO.w * k}187 height={LOGO.h * k}188 viewBox={`${LOGO.x} ${LOGO.y} ${LOGO.w} ${LOGO.h}`}189 style={{ display: "block", overflow: "visible" }}190 aria-hidden191 >192 <LogoPaths fill={color} />193 </svg>194 );195}196197/** The foreground at `scale`, around the frame's center; nothing extra at 1. */198function ScaleLayer({199 scale,200 children,201}: {202 scale: number;203 children: React.ReactNode;204}) {205 if (scale === 1) return children;206 return (207 <AbsoluteFill style={{ transform: `scale(${scale})` }}>208 {children}209 </AbsoluteFill>210 );211}212213export function VersionHero({214 version = "2.0",215 name = "acme",216 label = "Now available",217 logo,218 accent = "#3B5BFD",219 ink,220 background: backdrop,221 fontFamily = bricolage,222 depth: extrude = 0.2,223 stagger = 2.2,224 grain = true,225 scale = 1,226 delay = 0,227 speed = 1,228 theme = "dark",229}: VersionHeroProps) {230 const t = Math.max(0, useCurrentFrame() - delay) * speed;231 const { width, height } = useVideoConfig();232 const u = height / 720;233 const m: Material = MATERIALS[theme];234 const fg = ink ?? m.fg;235 const stage = backdrop === "transparent" ? "transparent" : (backdrop ?? m.bg);236237 const chars = Array.from(version).length;238 const fontSize = Math.min(height * 0.7, (width * 0.6) / (chars * 0.5));239 const depth = fontSize * extrude;240 const dz = depth / (SLICES * SUB);241 const spreadMax = fontSize * 0.42;242 const boxW = width;243 const boxH = fontSize * 1.2;244 const cy = height * 0.43;245246 // camera: a slow eased orbit plus a gentle dolly-in247 const orbit = interpolate(t, [0, 150], [0, 1], {248 ...CLAMP,249 easing: EASE_IO,250 });251 const rotY = -24 + orbit * 16;252 const rotX = 10 - orbit * 4;253 const dolly = interpolate(t, [0, 70], [-220 * u, 0], {254 ...CLAMP,255 easing: EASE_OUT,256 });257258 // specular sweep across the faces once the stack has docked259 const sweep = interpolate(t, [44, 92], [-0.3, 1.35], {260 ...CLAMP,261 easing: EASE_IO,262 });263 const restSheen = interpolate(t, [44, 92], [0, 1], CLAMP);264 // the disc of light rises behind the object as it docks265 const glowP = interpolate(t, [20, 96], [0, 1], {266 ...CLAMP,267 easing: EASE_IO,268 });269 const glowY = 136 - 16 * glowP;270271 const sliceP = (k: number) =>272 interpolate(t, [4 + k * stagger, 4 + k * stagger + 34], [0, 1], {273 ...CLAMP,274 easing: EASE_OUT,275 });276277 const textStyle: React.CSSProperties = {278 position: "absolute",279 left: -boxW / 2,280 top: -boxH / 2,281 width: boxW,282 height: boxH,283 display: "flex",284 alignItems: "center",285 justifyContent: "center",286 fontFamily,287 fontWeight: 500,288 fontSize,289 lineHeight: 1,290 letterSpacing: "-0.05em",291 whiteSpace: "nowrap",292 color: "transparent",293 WebkitBackgroundClip: "text",294 backgroundClip: "text",295 backfaceVisibility: "visible",296 };297298 const layers: React.ReactNode[] = [];299 for (let k = SLICES - 1; k >= 0; k--) {300 const p = sliceP(k);301 const zSlice = -k * SUB * dz - k * spreadMax * (1 - p);302 const appear = interpolate(t, [-6 + k * 1.6, 8 + k * 1.6], [0, 1], CLAMP);303 const blur = ((k * spreadMax * (1 - p)) / (spreadMax * SLICES)) * 7 * u;304 const subs: React.ReactNode[] = [];305 for (let s = SUB - 1; s >= 0; s--) {306 const j = k * SUB + s;307 const isFace = j === 0;308 const depthT = j / (SLICES * SUB - 1);309 const top = mix(m.side[0], m.sideFloor, depthT * 0.55);310 const bottom = mix(m.side[1], m.sideFloor, depthT * 0.8);311 const sideSpec = specBand(sweep - depthT * 0.05, m.specSide);312 let background: string;313 if (isFace) {314 background = [315 specBand(sweep, m.spec),316 `linear-gradient(104deg, transparent 0%, rgba(255,255,255,${0.12 * restSheen}) 40%, transparent 75%)`,317 // the disc rising behind bounces up into the lower half of the face318 `linear-gradient(180deg, transparent 38%, color-mix(in oklab, ${GLOW[1]} ${Math.round(m.glowTint * 100 * glowP)}%, transparent) 78%, color-mix(in oklab, ${GLOW[2]} ${Math.round(m.glowTint * 100 * glowP)}%, transparent) 100%)`,319 m.faceTexture,320 m.faceBase,321 ].join(", ");322 } else if (s === 0) {323 // the leading face of each slice reads as a plate while spread out324 const plate = 1 - p;325 background = `linear-gradient(180deg, ${m.plate}${Math.round(326 plate * 255,327 )328 .toString(16)329 .padStart(2, "0")}, ${m.plate}${Math.round(plate * 200)330 .toString(16)331 .padStart(332 2,333 "0",334 )}), ${sideSpec}, linear-gradient(180deg, ${top}, ${bottom})`;335 } else {336 background = `${sideSpec}, linear-gradient(180deg, ${top}, ${bottom})`;337 }338 if (isFace) {339 // chamfer: a hairline of light just behind the face, nudged up-left340 subs.push(341 <div342 key="bevel"343 style={{344 ...textStyle,345 color: m.bevel,346 transform: `translate3d(${-0.8 * u}px, ${-1 * u}px, ${-dz * 0.5}px)`,347 }}348 >349 {version}350 </div>,351 );352 }353 subs.push(354 <div355 key={j}356 style={{357 ...textStyle,358 transform: `translateZ(${-s * dz}px)`,359 backgroundImage: background,360 backgroundSize: isFace361 ? `100% 100%, 100% 100%, 100% 100%, ${m.faceTextureSize}, 100% 100%`362 : undefined,363 }}364 >365 {version}366 </div>,367 );368 }369 layers.push(370 <div371 key={k}372 style={{373 position: "absolute",374 left: 0,375 top: 0,376 transformStyle: blur > 0.15 ? undefined : "preserve-3d",377 transform: `translateZ(${zSlice}px)`,378 opacity: appear,379 filter: blur > 0.15 ? `blur(${blur}px)` : undefined,380 }}381 >382 {subs}383 </div>,384 );385 }386387 // label under the object388 const labelP = (d: number) =>389 interpolate(t, [62 + d, 86 + d], [0, 1], { ...CLAMP, easing: EASE_OUT });390 const labelTop = cy + fontSize * 0.4 + 44 * u;391392 const shadowO = interpolate(t, [10, 60], [0.35, 1], CLAMP);393394 return (395 <AbsoluteFill style={{ background: stage, overflow: "hidden" }}>396 {/* overhead key light on the stage */}397 <AbsoluteFill398 style={{399 background: `radial-gradient(ellipse 55% 60% at 50% 30%, ${m.stageLight}, transparent 72%)`,400 }}401 />402 {/* radial-glow: a disc of light rising behind the numeral */}403 <AbsoluteFill404 style={{405 opacity: m.glow * glowP,406 background: [407 `radial-gradient(82% 100% at 50% ${glowY}%, transparent 53%, color-mix(in oklab, ${m.ring[0]} 85%, transparent) 56.5%, color-mix(in oklab, ${m.ring[1]} 50%, transparent) 60%, color-mix(in oklab, ${m.ring[2]} 22%, transparent) 66%, transparent 78%)`,408 `radial-gradient(82% 100% at 50% ${glowY}%, color-mix(in oklab, ${GLOW[2]} ${Math.round(70 * m.disc)}%, transparent) 0%, color-mix(in oklab, ${GLOW[3]} ${Math.round(60 * m.disc)}%, transparent) 40%, transparent 56%)`,409 ].join(", "),410 }}411 />412 <ScaleLayer scale={scale}>413 {/* contact shadow */}414 <div415 style={{416 position: "absolute",417 left: width / 2 - fontSize * 0.95,418 top: cy + fontSize * 0.3,419 width: fontSize * 1.9,420 height: fontSize * 0.16,421 borderRadius: "50%",422 background: `radial-gradient(closest-side, ${m.shadow}, transparent)`,423 filter: `blur(${14 * u}px)`,424 opacity: shadowO,425 }}426 />427428 <div429 style={{430 position: "absolute",431 inset: 0,432 perspective: 2000 * u,433 perspectiveOrigin: `50% ${(cy / height) * 100}%`,434 }}435 >436 <div437 style={{438 position: "absolute",439 left: width / 2,440 top: cy,441 width: 0,442 height: 0,443 transformStyle: "preserve-3d",444 transform: `translateZ(${dolly}px) rotateX(${rotX}deg) rotateY(${rotY}deg)`,445 }}446 >447 {layers}448 </div>449 </div>450451 {/* label */}452 <div453 style={{454 position: "absolute",455 left: 0,456 right: 0,457 top: labelTop,458 display: "flex",459 justifyContent: "center",460 alignItems: "center",461 gap: 16 * u,462 fontFamily,463 fontSize: 22 * u,464 lineHeight: 1,465 }}466 >467 <div468 style={{469 display: "flex",470 alignItems: "center",471 gap: 9 * u,472 opacity: labelP(0),473 transform: `translateY(${(1 - labelP(0)) * 14 * u}px)`,474 }}475 >476 {logo ??477 (name.trim().toLowerCase() === "acme" ? (478 <Logo size={30 * u} color={fg} />479 ) : (480 <span481 style={{482 color: fg,483 fontWeight: 500,484 letterSpacing: "-0.03em",485 fontSize: 26 * u,486 }}487 >488 {name}489 </span>490 ))}491 </div>492 <div493 style={{494 width: Math.max(1, u),495 height: 22 * u,496 background: accent,497 transform: `scaleY(${labelP(3)})`,498 }}499 />500 <span501 style={{502 color: m.muted,503 fontWeight: 400,504 letterSpacing: "-0.01em",505 opacity: labelP(6),506 transform: `translateY(${(1 - labelP(6)) * 14 * u}px)`,507 }}508 >509 {label}510 </span>511 </div>512 </ScaleLayer>513514 {grain ? <Grain opacity={m.grain} /> : null}515 </AbsoluteFill>516 );517}









