Launch Days
Vertical day tabs expand one into a big card, '03 Templates', under a Launch Week header.
Source
components/kuchi/launch-days.tsx
1"use client";23import { loadFont as loadHanken } from "@remotion/google-fonts/HankenGrotesk";4import { loadFont as loadMono } from "@remotion/google-fonts/JetBrainsMono";5import { loadFont as loadManrope } from "@remotion/google-fonts/Manrope";6import type React from "react";7import { Fragment } from "react";8import {9 AbsoluteFill,10 Easing,11 interpolate,12 spring,13 useCurrentFrame,14 useVideoConfig,15} from "remotion";16import type { GradientParams } from "@/lib/kuchi/gsh/gradient-engine";17import { GshGround } from "@/lib/kuchi/gsh/gsh-ground";18import type { GshPresetId } from "@/lib/kuchi/gsh/presets";1920const hanken = loadHanken("normal", {21 weights: ["300", "400"],22 subsets: ["latin"],23});24const mono = loadMono("normal", { weights: ["400"], subsets: ["latin"] });25const manrope = loadManrope("normal", {26 weights: ["600"],27 subsets: ["latin"],28});2930export interface LaunchDay {31 day: string;32 title: string;33 description?: string;34}3536export interface LaunchDaysProps {37 week?: string;38 label?: string;39 days?: LaunchDay[];40 active?: number;41 from?: number;42 revealUpcoming?: boolean;43 logo?: React.ReactNode;44 accent?: string;45 background?: string;46 /** Text color; overrides the theme ink. */47 ink?: string;48 /** Typeface for the titles and copy. Load it yourself; Hanken Grotesk by default. */49 fontFamily?: string;50 /** Frames between title words as the active day writes in. */51 stagger?: number;52 /** Corner radius of the day cards, in px at 720p. */53 radius?: number;54 /** Size of the header and strip, around the frame's center. */55 scale?: number;56 /** Frames to hold the first frame before anything moves. */57 delay?: number;58 speed?: number;59 theme?: "dark" | "light";60 ground?: GshPresetId;61 groundParams?: Partial<GradientParams>;62}6364const DEFAULT_DAYS: LaunchDay[] = [65 {66 day: "Mon",67 title: "Captions",68 description: "31 transcript-driven caption styles.",69 },70 {71 day: "Tue",72 title: "Transitions",73 description: "Cuts that land on the beat.",74 },75 {76 day: "Wed",77 title: "Templates",78 description:79 "Whole launch films, installed into your project and yours to edit.",80 },81 {82 day: "Thu",83 title: "Agent skill",84 description: "Your agent reads the docs and picks the beat.",85 },86 {87 day: "Fri",88 title: "Studio",89 description: "Preview every scene before it renders.",90 },91];9293const PALETTES = {94 dark: {95 bg: "#0A0A0B",96 scrim: "rgba(10,10,11,0.84)",97 fg: "#F4F3F0",98 muted: "#8E8D94",99 faint: "#55555C",100 panel: "rgba(255,255,255,0.03)",101 line: "rgba(255,255,255,0.08)",102 litLine: "rgba(255,255,255,0.14)",103 activeFg: "#F7F8FF",104 activeMuted: "rgba(236,240,255,0.74)",105 shade:106 "linear-gradient(180deg, rgba(4,6,20,0) 35%, rgba(4,6,20,0.55) 100%)",107 ground: "film-blue" as GshPresetId,108 groundParams: undefined as Partial<GradientParams> | undefined,109 },110 light: {111 bg: "#F5F4F0",112 scrim: "rgba(245,244,240,0.84)",113 fg: "#111113",114 muted: "#6E6C67",115 faint: "#A9A69E",116 panel: "rgba(255,255,255,0.5)",117 line: "rgba(17,17,19,0.08)",118 litLine: "rgba(17,17,19,0.1)",119 activeFg: "#0B0D1E",120 activeMuted: "rgba(11,13,30,0.68)",121 shade:122 "linear-gradient(180deg, rgba(245,246,252,0) 35%, rgba(245,246,252,0.6) 100%)",123 ground: "glasswork" as GshPresetId,124 groundParams: {125 colors: ["#a9bcff", "#3552ff", "#1a2a9e", "#7f9bff"],126 } as Partial<GradientParams> | undefined,127 },128} as const;129130const EASE_OUT = Easing.bezier(0.22, 1, 0.36, 1);131const EASE_IN = Easing.bezier(0.55, 0, 1, 0.45);132const SPRING_CARD = { mass: 0.8, damping: 18, stiffness: 160 };133const SPRING_MORPH = { damping: 200 };134const CLAMP = {135 extrapolateLeft: "clamp",136 extrapolateRight: "clamp",137} as const;138139140function KuchiLogo({ fontSize, color }: { fontSize: number; color: string }) {141 return (142 <div143 style={{144 display: "flex",145 alignItems: "baseline",146 color,147 fontFamily: manrope.fontFamily,148 fontWeight: 600,149 fontSize,150 letterSpacing: "-0.025em",151 lineHeight: 1,152 }}153 >154 <span>Acme</span>155 </div>156 );157}158159function estimateEm(text: string) {160 let w = 0;161 for (const ch of text) {162 if (ch === " ") w += 0.24;163 else if (/[ilIj.,'’!|]/.test(ch)) w += 0.25;164 else if (/[mwMW]/.test(ch)) w += 0.82;165 else if (/[A-Z]/.test(ch)) w += 0.64;166 else if (/[0-9]/.test(ch)) w += 0.55;167 else w += 0.52;168 }169 return w;170}171172const pad2 = (n: number) => String(n).padStart(2, "0");173174/** The foreground at `scale`, around the frame's center; nothing extra at 1. */175function ScaleLayer({176 scale,177 children,178}: {179 scale: number;180 children: React.ReactNode;181}) {182 if (scale === 1) return children;183 return (184 <AbsoluteFill style={{ transform: `scale(${scale})` }}>185 {children}186 </AbsoluteFill>187 );188}189190export function LaunchDays({191 week = "Launch Week 01",192 label = "New today",193 days = DEFAULT_DAYS,194 active = 2,195 from,196 revealUpcoming = false,197 logo,198 accent = "#3B5BFD",199 background,200 ink,201 fontFamily = hanken.fontFamily,202 stagger = 3,203 radius: corner = 16,204 scale = 1,205 delay = 0,206 speed = 1,207 theme = "dark",208 ground,209 groundParams,210}: LaunchDaysProps) {211 const raw = Math.max(0, useCurrentFrame() - delay);212 const frame = raw * speed;213 const { width, height, fps } = useVideoConfig();214 const p = PALETTES[theme];215 const fg = ink ?? p.fg;216 const activeFg = ink ?? p.activeFg;217218 const list = days.length >= 2 ? days.slice(0, 7) : DEFAULT_DAYS;219 const n = list.length;220 const act = Math.min(Math.max(0, Math.round(active)), n - 1);221 const swap =222 from !== undefined && Math.round(from) !== act223 ? Math.min(Math.max(0, Math.round(from)), n - 1)224 : null;225226 const portrait = height > width * 1.1;227 const u = Math.min(width, height) / 720;228 const margin = 40 * u;229 const marginX = portrait ? width * 0.07 : width * 0.1;230 const headerH = week || logo !== null ? 64 * u : 0;231 const gap = 8 * u;232 const radius = corner * u;233234 const stripW = width - marginX * 2;235 const stripH = height - margin - headerH - margin * (headerH ? 0 : 1);236 const main = portrait ? stripH : stripW;237 const cross = portrait ? stripW : stripH;238 const sliver = Math.max(239 44 * u,240 Math.min((portrait ? 92 : 76) * u, main * 0.075),241 );242 const free = main - gap * (n - 1);243 const equal = free / n;244 const wide = free - sliver * (n - 1);245246 const rise = (i: number) =>247 swap === null248 ? spring({ frame: frame - i * 2, fps, config: SPRING_CARD })249 : 1;250 const open = spring({251 frame: frame - 14,252 fps,253 config: SPRING_MORPH,254 durationInFrames: 28,255 });256 const sizeOf = (i: number) => {257 if (swap === null) {258 return interpolate(open, [0, 1], [equal, i === act ? wide : sliver]);259 }260 const a = i === swap ? wide : sliver;261 const b = i === act ? wide : sliver;262 return interpolate(open, [0, 1], [a, b]);263 };264265 const eyebrowT = interpolate(frame, [26, 42], [0, 1], {266 ...CLAMP,267 easing: EASE_OUT,268 });269 const wordT = (i: number) =>270 interpolate(frame, [30 + i * stagger, 48 + i * stagger], [0, 1], {271 ...CLAMP,272 easing: EASE_OUT,273 });274 const outT = (i: number) =>275 interpolate(frame, [6 + i * 2, 16 + i * 2], [0, 1], {276 ...CLAMP,277 easing: EASE_IN,278 });279280 const panelPad = (portrait ? 44 : 36) * u;281 const avail = (portrait ? cross : wide) - panelPad * 2;282 const base = (portrait ? 150 : 136) * u;283 const numFs = (portrait ? 150 : 112) * u;284 const titleFs = (title: string) => {285 const em = estimateEm(title);286 const one = avail / Math.max(em, 0.5);287 if (one >= base * 0.78) return Math.min(base, one);288 return Math.max(base * 0.5, Math.min(base * 0.86, (avail * 1.9) / em));289 };290291 const transparent = background === "transparent";292 const showHeader = headerH > 0;293 const labelFs = 16 * u;294 const preset = ground ?? (groundParams ? undefined : p.ground);295 const litO = (i: number) =>296 i === act297 ? interpolate(frame, [16, 40], [0, 1], { ...CLAMP, easing: EASE_OUT })298 : i === swap299 ? 1 -300 interpolate(frame, [14, 36], [0, 1], { ...CLAMP, easing: EASE_IN })301 : 0;302 const stripX = marginX;303 const stripY = showHeader ? headerH + margin * 0.15 : margin;304 const sizes = list.map((_, i) => sizeOf(i));305 const rectOf = (i: number) => {306 let at = 0;307 for (let k = 0; k < i; k++) at += (sizes[k] as number) + gap;308 const lift = (1 - rise(i)) * 30 * u;309 const sz = sizes[i] as number;310 return portrait311 ? { x: stripX, y: stripY + at + lift, w: stripW, h: sz }312 : { x: stripX + at, y: stripY + lift, w: sz, h: stripH - margin * 0.15 };313 };314 const rr = (x: number, y: number, w: number, h: number, r: number) =>315 `M${x + r} ${y}H${x + w - r}A${r} ${r} 0 0 1 ${x + w} ${y + r}V${y + h - r}A${r} ${r} 0 0 1 ${x + w - r} ${y + h}H${x + r}A${r} ${r} 0 0 1 ${x} ${y + h - r}V${y + r}A${r} ${r} 0 0 1 ${x + r} ${y}Z`;316 const holes = list317 .map((_, i) => i)318 .filter((i) => litO(i) > 0.001)319 .map((i) => {320 const q = rectOf(i);321 if (scale === 1) return rr(q.x, q.y, q.w, q.h, radius);322 // The cards sit in the ScaleLayer; the scrim doesn't, so map its holes.323 const sx = width / 2 + (q.x - width / 2) * scale;324 const sy = height / 2 + (q.y - height / 2) * scale;325 return rr(sx, sy, q.w * scale, q.h * scale, radius * scale);326 });327 const scrimD = `M0 0H${width}V${height}H0Z${holes.join("")}`;328329 const headerT = interpolate(frame, [0, 18], [0, 1], {330 ...CLAMP,331 easing: EASE_OUT,332 });333334 const renderOpen = (335 d: LaunchDay,336 i: number,337 mode: "in" | "out",338 size: number,339 ) => {340 const fs = titleFs(d.title);341 const words = d.title.split(/\s+/).filter(Boolean);342 const shown = mode === "in";343 const eb = shown ? eyebrowT : 1 - outT(0);344 const numT = shown345 ? interpolate(frame, [24, 44], [0, 1], { ...CLAMP, easing: EASE_OUT })346 : 1 - outT(0);347 const descT = shown348 ? interpolate(349 frame,350 [40 + words.length * 3, 60 + words.length * 3],351 [0, 1],352 {353 ...CLAMP,354 easing: EASE_OUT,355 },356 )357 : 1 - outT(1);358 const box = portrait ? cross : wide;359 const contentOpacity = interpolate(360 size,361 [sliver * 1.2, sliver * 2.4],362 [0, 1],363 CLAMP,364 );365 return (366 <div367 style={{368 position: "absolute",369 left: 0,370 top: 0,371 width: portrait ? box : wide,372 height: portrait ? wide : cross,373 padding: panelPad,374 display: "flex",375 flexDirection: "column",376 justifyContent: "space-between",377 opacity: contentOpacity,378 }}379 >380 <div381 style={{382 display: "flex",383 alignItems: "flex-start",384 justifyContent: "space-between",385 }}386 >387 <div388 style={{389 display: "flex",390 alignItems: "center",391 gap: 12 * u,392 marginTop: 6 * u,393 fontFamily: mono.fontFamily,394 fontWeight: 400,395 fontSize: labelFs * 1.1,396 letterSpacing: "0.08em",397 textTransform: "uppercase",398 color: activeFg,399 opacity: eb,400 transform: `translateX(${(1 - eb) * -16 * u}px)`,401 }}402 >403 <span>{d.day}</span>404 {label ? (405 <>406 <span407 style={{408 width: 22 * u,409 height: 1,410 background: p.activeMuted,411 opacity: 0.6,412 }}413 />414 <span style={{ color: p.activeMuted }}>{label}</span>415 </>416 ) : null}417 </div>418 <span419 style={{420 display: "inline-block",421 overflow: "hidden",422 paddingRight: "0.04em",423 marginTop: -numFs * 0.12,424 marginRight: -numFs * 0.02,425 }}426 >427 <span428 style={{429 display: "inline-block",430 fontFamily,431 fontWeight: 400,432 fontSize: numFs,433 lineHeight: 1,434 letterSpacing: "-0.05em",435 fontVariantNumeric: "tabular-nums",436 color: activeFg,437 transform: `translateY(${(1 - numT) * 100}%)`,438 }}439 >440 {pad2(i + 1)}441 </span>442 </span>443 </div>444 <div>445 <div446 style={{447 fontFamily,448 fontWeight: 400,449 fontSize: fs,450 lineHeight: 0.98,451 letterSpacing: "-0.045em",452 color: activeFg,453 textWrap: "balance",454 marginLeft: -fs * 0.04,455 }}456 >457 {words.map((w, k) => {458 const t = shown ? wordT(k) : 1;459 const o = shown ? 0 : outT(k);460 return (461 <Fragment key={`${w}-${k}`}>462 {k > 0 ? " " : null}463 <span464 style={{465 display: "inline-block",466 overflow: "hidden",467 verticalAlign: "top",468 paddingBottom: "0.12em",469 marginBottom: "-0.12em",470 paddingRight: "0.05em",471 marginRight: "-0.05em",472 }}473 >474 <span475 style={{476 display: "inline-block",477 transform: `translateY(${(1 - t) * 105 - o * 105}%)`,478 }}479 >480 {w}481 </span>482 </span>483 </Fragment>484 );485 })}486 </div>487 {d.description ? (488 <div489 style={{490 marginTop: fs * 0.26,491 maxWidth: Math.min(avail, 620 * u),492 fontFamily,493 fontWeight: 400,494 fontSize: (portrait ? 30 : 24) * u,495 lineHeight: 1.35,496 letterSpacing: "-0.01em",497 color: p.activeMuted,498 textWrap: "balance",499 opacity: descT,500 transform: `translateY(${(1 - descT) * 12 * u}px)`,501 filter: `blur(${(1 - descT) * 5 * u}px)`,502 }}503 >504 {d.description}505 </div>506 ) : null}507 </div>508 </div>509 );510 };511512 return (513 <AbsoluteFill514 style={{515 background: transparent ? "transparent" : (background ?? p.bg),516 overflow: "hidden",517 }}518 >519 {transparent || background ? null : (520 <>521 <GshGround522 preset={preset}523 params={groundParams ?? (ground ? undefined : p.groundParams)}524 timeOffset={theme === "light" ? 4 : 2}525 timeScale={0.5}526 />527 <svg528 width={width}529 height={height}530 viewBox={`0 0 ${width} ${height}`}531 style={{ position: "absolute", inset: 0 }}532 aria-hidden533 >534 <path d={scrimD} fill={p.scrim} fillRule="evenodd" />535 </svg>536 </>537 )}538 <ScaleLayer scale={scale}>539 {showHeader ? (540 <div541 style={{542 position: "absolute",543 left: marginX,544 right: marginX,545 top: 0,546 height: headerH + margin * 0.15,547 display: "flex",548 alignItems: "center",549 justifyContent: "space-between",550 opacity: headerT,551 transform: `translateY(${(1 - headerT) * -8 * u}px)`,552 }}553 >554 <span555 style={{556 fontFamily: mono.fontFamily,557 fontWeight: 400,558 fontSize: labelFs * 1.1,559 letterSpacing: "0.08em",560 textTransform: "uppercase",561 color: fg,562 }}563 >564 {week}565 </span>566 {logo === null ? null : (567 <div style={{ display: "flex", alignItems: "center" }}>568 {logo ?? <KuchiLogo fontSize={24 * u} color={fg} />}569 </div>570 )}571 </div>572 ) : null}573574 <div575 style={{576 position: "absolute",577 left: stripX,578 top: stripY,579 width: stripW,580 height: stripH - margin * 0.15,581 display: "flex",582 flexDirection: portrait ? "column" : "row",583 gap,584 }}585 >586 {list.map((d, i) => {587 const size = sizeOf(i);588 const r = rise(i);589 const isAct = i === act;590 const isFrom = i === swap;591 const groundO = litO(i);592 const past = i < act;593 const upcoming = i > act;594 const sliverTitle = upcoming && !revealUpcoming ? "" : d.title;595 const labelO = interpolate(596 size,597 [equal * 1.05, equal * 1.6],598 [1, 0],599 CLAMP,600 );601 const numColor = isAct ? activeFg : past ? fg : p.muted;602 return (603 <div604 key={`${d.day}-${i}`}605 style={{606 position: "relative",607 flex: "none",608 [portrait ? "height" : "width"]: size,609 [portrait ? "width" : "height"]: "100%",610 borderRadius: radius,611 overflow: "hidden",612 background: groundO > 0.001 ? undefined : p.panel,613 boxShadow: `inset 0 0 0 1px ${groundO > 0.5 ? p.litLine : p.line}`,614 clipPath: `inset(${Math.max(0, 1 - r) * 100}% 0 0 0 round ${radius}px)`,615 transform: `translateY(${(1 - r) * 30 * u}px)`,616 }}617 >618 {groundO > 0 ? (619 <>620 <div621 style={{622 position: "absolute",623 inset: 0,624 background: p.scrim,625 opacity: 1 - groundO,626 }}627 />628 <div629 style={{630 position: "absolute",631 inset: 0,632 background: p.shade,633 opacity: groundO,634 }}635 />636 </>637 ) : null}638639 <div640 style={{641 position: "absolute",642 inset: 0,643 padding: `${18 * u}px ${portrait ? 24 * u : 0}px`,644 display: "flex",645 flexDirection: portrait ? "row" : "column",646 alignItems: portrait ? "center" : "center",647 justifyContent: "space-between",648 opacity: labelO * interpolate(r, [0.4, 1], [0, 1], CLAMP),649 }}650 >651 <div652 style={{653 display: "flex",654 flexDirection: portrait ? "row" : "column",655 alignItems: "center",656 gap: 10 * u,657 }}658 >659 <span660 style={{661 fontFamily: mono.fontFamily,662 fontWeight: 400,663 fontSize: labelFs * 1.15,664 letterSpacing: "0.04em",665 color: numColor,666 }}667 >668 {pad2(i + 1)}669 </span>670 {past ? (671 <span672 style={{673 width: 6 * u,674 height: 6 * u,675 borderRadius: 99,676 background: accent,677 }}678 />679 ) : null}680 </div>681 <div682 style={{683 display: "flex",684 alignItems: "center",685 gap: 12 * u,686 writingMode: portrait ? undefined : "vertical-rl",687 transform: portrait ? undefined : "rotate(180deg)",688 whiteSpace: "nowrap",689 }}690 >691 <span692 style={{693 fontFamily: mono.fontFamily,694 fontWeight: 400,695 fontSize: labelFs,696 letterSpacing: "0.1em",697 textTransform: "uppercase",698 color: past ? p.muted : p.faint,699 }}700 >701 {d.day}702 </span>703 {sliverTitle ? (704 <span705 style={{706 fontFamily,707 fontWeight: 400,708 fontSize: labelFs * 1.6,709 letterSpacing: "-0.02em",710 color: past ? fg : p.muted,711 }}712 >713 {sliverTitle}714 </span>715 ) : null}716 </div>717 </div>718719 {isAct ? renderOpen(d, i, "in", size) : null}720 {isFrom ? renderOpen(d, i, "out", size) : null}721 </div>722 );723 })}724 </div>725 </ScaleLayer>726 </AbsoluteFill>727 );728}







