Product Hero
Product launch hero scene for a SaaS launch video intro. Cinematic product-launch hero — two cards slide into formation as the headline reveals above.
Source
components/kuchi/hero-launch.tsx
1"use client";23import { loadFont as loadInter } from "@remotion/google-fonts/Inter";4import { type CSSProperties, useCallback, useState } from "react";5import {6 AbsoluteFill,7 continueRender,8 delayRender,9 Easing,10 getRemotionEnvironment,11 interpolate,12 OffthreadVideo,13 staticFile,14 useCurrentFrame,15 useVideoConfig,16} from "remotion";17import {18 Item,19 mixOklch,20 resolveFont,21 type KuchiTheme,22 useKuchiTheme,23 withAlpha,24} from "@/lib/kuchi-ui";2526const { fontFamily: SANS } = loadInter("normal", {27 weights: ["500", "600", "700"],28 subsets: ["latin"],29});3031export interface HeroLaunchProps {32 /** Reveal caption under the cards. */33 heading?: string;34 /**35 * Left card media. An image URL, a video URL (`.mp4`/`.webm`/`.mov` → plays36 * via <OffthreadVideo>), or a CSS `linear-gradient(...)`. The video editor37 * swaps this for the viewer's own image/clip.38 */39 image1?: string;40 /** Right card media (same rules as `image1`). */41 image2?: string;42 /** Design-system token overrides. */43 theme?: Partial<KuchiTheme>;44 /** Defaults to `"dark"` — the scene is a cinematic stage, lit for dark. */45 mode?: "light" | "dark";46 /**47 * The face this scene paints its words in — a label from `fonts.ts`48 * ("Inter", "Space Grotesk", "Instrument Serif") or a CSS family you have49 * loaded yourself. Unset, the scene keeps the face it was designed around.50 *51 * Overrides `theme.fontFamily`, which is how a brand kit re-skins a whole52 * timeline from one value.53 */54 fontFamily?: string;55}5657const PERSP = 1000;58// Pure rotateY about each card's INNER edge — no rotateX, so the inner edges59// stay vertical and the centre gap is a clean, even channel top-to-bottom.60const TILT = 17;61const GAP = 92;62/** Stand-in for missing media — the page lifted a shade, not a fixed grey. */63const placeholder = (t: KuchiTheme) =>64 `linear-gradient(135deg,${mixOklch(t.background, t.card, 0.55)},${mixOklch(65 t.background,66 t.card,67 0.2,68 )})`;6970// Sample product-reveal clips. Absolute, because these ship as *defaults* into a71// project that does not have them in its own `public/` — a root-relative default72// becomes `staticFile()` in a render and 404s the first time anyone renders the73// component they just installed. Swap them for your own media, root-relative or74// not; `resolveSrc` handles both.75const SHOWCASE = [76 "https://kuchi-media.kalarislabs.com/components/clips/clip-3.mp4",77 "https://kuchi-media.kalarislabs.com/components/clips/clip-5.mp4",78];7980const isVideo = (src: string) => /\.(mp4|webm|mov|m4v)(\?|$)/i.test(src);81const isGradient = (src: string) => src.startsWith("linear-gradient");8283// easeOutQuint — quick to move, silky to settle, lands exactly on target with84// no asymptotic "stuck" tail (the thing overdamped springs get wrong).85const OUT = Easing.bezier(0.22, 1, 0.36, 1);86// Gravity-ish accelerate for the drop-off.87const FALL = Easing.bezier(0.5, 0, 0.9, 0.4);8889/**90 * A root-relative asset ("/showcase-assets/..") is served at the origin root by91 * Next in the Player, but Remotion Studio and a render serve `public/` through92 * `staticFile()` alone — so rewrite local paths everywhere but the Player, and pass93 * http(s)/data/blob URLs straight through.94 */95function resolveSrc(src: string): string {96 const isLocal = src.startsWith("/") && !src.startsWith("//");97 if (!isLocal || getRemotionEnvironment().isPlayer) return src;98 // A value that already came out of staticFile() carries the static base99 // (`/static-<hash>/…`); running it through again would prefix it twice.100 const base = staticFile("_").slice(0, -2);101 if (base && src.startsWith(`${base}/`)) return src;102 try {103 return staticFile(src.replace(/^\/+/, ""));104 } catch {105 return src;106 }107}108109/**110 * Image that holds the server render until it has actually *loaded*, then111 * releases. Remotion's <Img> is avoided on purpose: it awaits `img.decode()`,112 * which the headless compositor rejects for some progressive JPEGs and hangs the113 * export. A plain <img> paints fine — we wait for `onload` ourselves and clear114 * on error too, so a bad source degrades gracefully. In the Player this is an115 * ordinary, instantly-shown image.116 */117function HeroImage({ src, style }: { src: string; style: CSSProperties }) {118 const [handle] = useState(() => delayRender(`hero image: ${src}`));119 const release = useCallback(() => continueRender(handle), [handle]);120 return (121 // biome-ignore lint/performance/noImgElement: Remotion frame, not a Next route.122 <img // eslint-disable-line @remotion/warn-native-media-tag -- onLoad releases the frame; <Img> hangs on some JPEGs123 src={resolveSrc(src)}124 alt=""125 style={style}126 onLoad={release}127 onError={release}128 />129 );130}131132/** Fills a card edge-to-edge with an image, a video, or a gradient. */133function CardMedia({ src, t }: { src: string; t: KuchiTheme }) {134 const media: CSSProperties = {135 position: "absolute",136 inset: 0,137 width: "100%",138 height: "100%",139 objectFit: "cover",140 };141 const effective = src || placeholder(t);142 if (isGradient(effective)) {143 return <div style={{ ...media, background: effective }} />;144 }145 if (isVideo(effective)) {146 return <OffthreadVideo src={resolveSrc(effective)} muted style={media} />;147 }148 return <HeroImage src={effective} style={media} />;149}150151/**152 * Cinematic product-launch hero — deterministic Remotion composition153 * (1280×720 @30fps). Two image cards, one continuous professionally-eased154 * motion, no bounce:155 *156 * f0–40 the left image HOLDS full-screen, flat and clear157 * f40 it recedes to its floating size and angles in about its inner edge158 * f60 the right image slides in from the right; the two sit SYMMETRIC159 * about the frame centre with an even, centred gap160 * f100 both breathe with a barely-there float (never dead-static)161 * f122 they fall off the lower edge together162 * f126 the headline reveals and eases forward ("comes to front")163 *164 * Left/right/bottom edges dissolve into black. `image1`/`image2` + `heading`165 * are the props the video editor drives.166 */167export function HeroLaunch({168 heading = "npx shadcn add @kuchi",169 image1 = SHOWCASE[0],170 image2 = SHOWCASE[1],171 theme,172 mode,173 fontFamily,174}: HeroLaunchProps) {175 const frame = useCurrentFrame();176 const { width, height } = useVideoConfig();177 const t = useKuchiTheme(theme, mode ?? "dark");178 const face = resolveFont(fontFamily ?? t.fontFamily) ?? SANS;179 const s = height / 720;180181 const cardW = 1000 * s;182 const cardH = 620 * s;183 const centerLeft = (width - cardW) / 2;184 const cardTop = 0.3 * height;185 // Symmetric about the centre → the gap sits exactly on the frame's midline.186 const restOffset = (cardW + GAP * s) / 2;187 const leftXFinal = -restOffset;188 const rightXFinal = restOffset;189 const rightXStart = 1.08 * width;190 const groupYFinal = 0.16 * height;191192 // A clamped, eased 0→1 segment — the single motion primitive for the whole193 // scene. Easing lands cleanly on the target, so nothing ever "sticks".194 const seg = (start: number, dur: number, easing = OUT) =>195 interpolate(frame, [start, start + dur], [0, 1], {196 easing,197 extrapolateLeft: "clamp",198 extrapolateRight: "clamp",199 });200201 const recede = seg(40, 30); // full-screen → floating202 const angle = seg(46, 36); // flat → angled (rotateY only)203 const slideL = seg(46, 36); // centre → left rest204 const slideR = seg(60, 40); // offscreen right → right rest205 const drop = seg(122, 34, FALL); // settle → fall off bottom206 const title = seg(126, 40); // headline reveal + forward207208 const leftScale = interpolate(recede, [0, 1], [1.5, 1]);209 const leftX = interpolate(slideL, [0, 1], [0, leftXFinal]);210 const leftDeg = interpolate(angle, [0, 1], [0, -TILT]);211 const leftOpacity = interpolate(frame, [2, 12], [0, 1], {212 extrapolateLeft: "clamp",213 extrapolateRight: "clamp",214 });215216 const rightX = interpolate(slideR, [0, 1], [rightXStart, rightXFinal]);217 const rightOpacity = interpolate(slideR, [0, 0.35], [0, 1], {218 extrapolateRight: "clamp",219 });220221 // Barely-there float once settled (fades out into the drop) so the held beat222 // reads as alive, not frozen — the classic "why does it feel stuck" fix.223 const floatEnv = seg(94, 22) * (1 - drop);224 const floatY = Math.sin(frame * 0.09) * 3.5 * s * floatEnv;225 const groupY = interpolate(drop, [0, 1], [0, groupYFinal]) + floatY;226227 const titleY = interpolate(title, [0, 1], [40 * s, 0]);228 const titleScale = interpolate(title, [0, 1], [0.82, 1]);229 const titleBlur = interpolate(title, [0, 1], [10, 0]);230231 const vignette = seg(50, 40, Easing.linear);232233 const cardBox = (x: number, opacity: number): CSSProperties => ({234 position: "absolute",235 left: centerLeft,236 top: cardTop,237 width: cardW,238 height: cardH,239 opacity,240 transform: `translateX(${x}px)`,241 });242243 // Opening zoom pivots on the centre; the tilt pivots on the inner edge.244 const zoom = (scale: number): CSSProperties => ({245 width: "100%",246 height: "100%",247 transform: `scale(${scale})`,248 transformOrigin: "center center",249 });250 const tilt = (deg: number, origin: string): CSSProperties => ({251 width: "100%",252 height: "100%",253 transform: `perspective(${PERSP * s}px) rotateY(${deg}deg)`,254 transformOrigin: origin,255 });256 const fade = (gradient: string): CSSProperties => ({257 position: "absolute",258 inset: 0,259 background: gradient,260 });261262 return (263 <AbsoluteFill style={{ backgroundColor: t.background, fontFamily: face }}>264 <AbsoluteFill style={{ transform: `translateY(${groupY}px)` }}>265 {/* Each card is its own object to Remotion Studio (see `Item`). */}266 <Item index={0}>267 <div style={cardBox(leftX, leftOpacity)}>268 <div style={zoom(leftScale)}>269 {/* inner edge = right edge → pivot at 100% 50% */}270 <div style={tilt(leftDeg, "100% 50%")}>271 <ImageCard s={s} src={image1} t={t} />272 </div>273 </div>274 </div>275 </Item>276 <Item index={1}>277 <div style={cardBox(rightX, rightOpacity)}>278 {/* inner edge = left edge → pivot at 0% 50% */}279 <div style={tilt(TILT, "0% 50%")}>280 <ImageCard s={s} src={image2} t={t} />281 </div>282 </div>283 </Item>284 </AbsoluteFill>285286 {/* Wide, clean edge dissolve — fades in after the full-screen opening. */}287 <AbsoluteFill style={{ opacity: vignette, pointerEvents: "none" }}>288 <div289 style={fade(290 `linear-gradient(to left, ${t.background} 0%, transparent 30%)`,291 )}292 />293 <div294 style={fade(295 `linear-gradient(to right, ${t.background} 0%, transparent 22%)`,296 )}297 />298 <div299 style={fade(300 `linear-gradient(to top, ${t.background} 0%, transparent 30%)`,301 )}302 />303 </AbsoluteFill>304305 <div306 style={{307 position: "absolute",308 left: 0,309 right: 0,310 top: 0.22 * height,311 padding: `0 ${40 * s}px`,312 textAlign: "center",313 color: t.foreground,314 fontWeight: 600,315 letterSpacing: "-0.02em",316 fontSize: 42 * s,317 opacity: title,318 filter: `blur(${titleBlur}px)`,319 transform: `translateY(${titleY}px) scale(${titleScale})`,320 }}321 >322 {heading}323 </div>324 </AbsoluteFill>325 );326}327328/** A single card: one image (or video/gradient) filling it edge-to-edge. */329function ImageCard({ s, src, t }: { s: number; src: string; t: KuchiTheme }) {330 return (331 <div332 style={{333 position: "relative",334 width: "100%",335 height: "100%",336 overflow: "hidden",337 borderRadius: 30 * s,338 background: mixOklch(t.background, t.card, 0.35),339 // Drop shadow + a subtle inset hairline ring so the edge reads on both340 // dark and bright media without dominating.341 boxShadow: `0 ${20 * s}px ${52 * s}px -${28 * s}px ${withAlpha(342 mixOklch(t.background, "#000", 0.75),343 0.9,344 )}, inset 0 0 0 1px ${withAlpha(t.foreground, 0.22)}`,345 }}346 >347 <CardMedia src={src} t={t} />348 {/* subtle depth: darken the lower edge + a hairline top sheen */}349 <div350 style={{351 position: "absolute",352 inset: 0,353 background: `linear-gradient(to top, ${withAlpha(354 mixOklch(t.background, "#000", 0.75),355 0.28,356 )} 0%, transparent 32%)`,357 }}358 />359 <div360 style={{361 position: "absolute",362 left: 26 * s,363 right: 26 * s,364 top: 0,365 height: 1,366 background: `linear-gradient(90deg,transparent,${withAlpha(367 t.foreground,368 0.5,369 )},transparent)`,370 }}371 />372 </div>373 );374}









