Year in Review
A bold story card with 2026 stats is presented with a Share this story button.
Source
components/kuchi/year-in-review.tsx
1"use client";23import { loadFont as loadDisplay } from "@remotion/google-fonts/BricolageGrotesque";4import { loadFont } from "@remotion/google-fonts/HankenGrotesk";5import type React from "react";6import {7 AbsoluteFill,8 Easing,9 interpolate,10 spring,11 useCurrentFrame,12 useVideoConfig,13} from "remotion";14import type { GradientParams } from "@/lib/kuchi/gsh/gradient-engine";15import { GshGround } from "@/lib/kuchi/gsh/gsh-ground";16import type { GshPresetId } from "@/lib/kuchi/gsh/presets";1718const { fontFamily: hanken } = loadFont("normal", {19 weights: ["300", "400"],20 subsets: ["latin"],21});22const { fontFamily: display } = loadDisplay("normal", {23 weights: ["300", "400"],24 subsets: ["latin"],25});2627export interface CrewMember {28 name: string;29 color: string;30}3132export interface YearInReviewStats {33 year: string;34 product: string;35 videos: number;36 topComponent: string;37 runnersUp: string[];38 percentile: number;39 minutes: string;40 crew: CrewMember[];41 url: string;42}4344export interface YearInReviewProps {45 stats?: Partial<YearInReviewStats>;46 accent?: string;47 speed?: number;48 device?: "phone" | "card";49 chapters?: string[];50 /** Chapter list beside the device; false leaves the device alone. */51 rail?: boolean;52 /** Color of the chapter titles and progress; overrides the default cream. */53 ink?: string;54 /** Solid fill in place of the gradient ground; "transparent" drops it. */55 background?: string;56 /** Typeface for the body copy. Load it yourself; Hanken Grotesk by default. */57 fontFamily?: string;58 /** Size of the device and chapter list, around the frame's center. */59 scale?: number;60 /** Frames to hold the first frame before anything moves. */61 delay?: number;62 ground?: GshPresetId;63 groundParams?: Partial<GradientParams>;64}6566const DEFAULT_STATS: YearInReviewStats = {67 year: "2026",68 product: "acme",69 videos: 42,70 topComponent: "Kinetic captions",71 runnersUp: ["Zoom blur", "Bento build", "Logo wall"],72 percentile: 3,73 minutes: "1,284",74 crew: [75 { name: "Maya Chen", color: "#F2994A" },76 { name: "Leo Park", color: "#5B8DEF" },77 { name: "Priya Raman", color: "#E05A7A" },78 { name: "Sam Okafor", color: "#2BB3A3" },79 { name: "Noor Haddad", color: "#9B6CF0" },80 { name: "Iris Vale", color: "#D4A72C" },81 ],82 url: "acme.dev/wrapped",83};8485const SW = 393;86const SH = 852;87const BEZEL = 11;88const STARTS = [0, 78, 156, 252, 360];89const TR = 18;90const INK = "#121212";91const CREAM = "#F6F1E7";92const LIME = "#CDF564";93const PINK = "#FF9BDB";94const ORANGE = "#FF6B35";9596const CL = {97 extrapolateLeft: "clamp",98 extrapolateRight: "clamp",99} as const;100const clamp = (v: number, lo = 0, hi = 1) => Math.min(hi, Math.max(lo, v));101const outCubic = Easing.bezier(0.22, 1, 0.36, 1);102const ENTER = Easing.bezier(0.32, 0.72, 0, 1);103const HEAVY = { mass: 1, damping: 26, stiffness: 120 };104const CARD = { mass: 0.8, damping: 18, stiffness: 160 };105const CHIP = { mass: 0.5, damping: 12, stiffness: 200 };106107function rgb(c: string): [number, number, number] {108 const hex = c.replace("#", "");109 const full = hex.length === 3 ? hex.replace(/(.)/g, "$1$1") : hex;110 if (!/^[0-9a-fA-F]{6}$/.test(full)) return [128, 128, 128];111 const n = Number.parseInt(full, 16);112 return [(n >> 16) & 255, (n >> 8) & 255, n & 255];113}114function mix(a: string, b: string, t: number) {115 const x = rgb(a);116 const y = rgb(b);117 const m = (i: number) => Math.round(x[i] + (y[i] - x[i]) * t);118 return `rgb(${m(0)}, ${m(1)}, ${m(2)})`;119}120const hash = (n: number) => {121 const s = Math.sin(n * 127.1 + 311.7) * 43758.5453;122 return s - Math.floor(s);123};124125interface Ctx {126 lf: number;127 fps: number;128 s: YearInReviewStats;129 accent: string;130 top: number;131}132133const pop = (c: Ctx, at: number, config: typeof CARD = CARD) =>134 spring({ frame: c.lf - at, fps: c.fps, config });135136function Display({137 children,138 size,139 color,140 style,141}: {142 children: React.ReactNode;143 size: number;144 color: string;145 style?: React.CSSProperties;146}) {147 return (148 <div149 style={{150 fontFamily: display,151 fontWeight: 400,152 fontSize: size,153 lineHeight: 0.92,154 letterSpacing: -size * 0.045,155 color,156 ...style,157 }}158 >159 {children}160 </div>161 );162}163164function Rise({165 t,166 children,167 style,168}: {169 t: number;170 children: React.ReactNode;171 style?: React.CSSProperties;172}) {173 return (174 <div style={{ overflow: "hidden", paddingBottom: 6, ...style }}>175 <div style={{ transform: `translateY(${(1 - t) * 110}%)` }}>176 {children}177 </div>178 </div>179 );180}181182function starPoints(n: number, r1: number, r2: number, rot: number) {183 return Array.from({ length: n * 2 }, (_, i) => {184 const r = i % 2 ? r2 : r1;185 const a = (i / (n * 2)) * Math.PI * 2 + rot;186 return `${50 + Math.cos(a) * r},${50 + Math.sin(a) * r}`;187 }).join(" ");188}189190function Shape({191 kind,192 color,193 size,194}: {195 kind: "circle" | "half" | "square" | "star" | "ring" | "pill";196 color: string;197 size: number;198}) {199 return (200 <svg201 width={size}202 height={size}203 viewBox="0 0 100 100"204 style={{ display: "block", overflow: "visible" }}205 >206 {kind === "circle" ? (207 <circle cx={50} cy={50} r={50} fill={color} />208 ) : null}209 {kind === "half" ? (210 <path d="M0 50 A50 50 0 0 1 100 50 Z" fill={color} />211 ) : null}212 {kind === "square" ? (213 <rect x={6} y={6} width={88} height={88} rx={14} fill={color} />214 ) : null}215 {kind === "star" ? (216 <polygon points={starPoints(8, 50, 30, 0)} fill={color} />217 ) : null}218 {kind === "ring" ? (219 <circle220 cx={50}221 cy={50}222 r={42}223 fill="none"224 stroke={color}225 strokeWidth={14}226 />227 ) : null}228 {kind === "pill" ? (229 <rect x={0} y={30} width={100} height={40} rx={20} fill={color} />230 ) : null}231 </svg>232 );233}234235function Portrait({236 color,237 size,238 name,239}: {240 color: string;241 size: number;242 name: string;243}) {244 const initials = name245 .split(" ")246 .map((w) => w[0])247 .join("")248 .slice(0, 2);249 return (250 <div251 style={{252 width: size,253 height: size,254 background: mix(color, "#1B1B1B", 0.15),255 display: "flex",256 alignItems: "flex-end",257 padding: 8,258 boxSizing: "border-box",259 fontFamily: display,260 fontWeight: 300,261 fontSize: size * 0.42,262 letterSpacing: "-0.04em",263 lineHeight: 0.9,264 color: mix(color, "#FFFFFF", 0.75),265 }}266 >267 {initials}268 </div>269 );270}271272const SHAPES = [273 {274 kind: "circle",275 color: LIME,276 x: -30,277 y: 120,278 size: 170,279 from: [-300, -200],280 spin: 0,281 },282 {283 kind: "half",284 color: PINK,285 x: 250,286 y: 150,287 size: 170,288 from: [300, -160],289 spin: 180,290 },291 {292 kind: "square",293 color: ORANGE,294 x: -20,295 y: 600,296 size: 150,297 from: [-260, 300],298 spin: -120,299 },300 {301 kind: "star",302 color: "accent",303 x: 230,304 y: 610,305 size: 200,306 from: [260, 300],307 spin: 200,308 },309 {310 kind: "ring",311 color: CREAM,312 x: 300,313 y: 262,314 size: 64,315 from: [200, 0],316 spin: 0,317 },318 {319 kind: "pill",320 color: LIME,321 x: 124,322 y: 530,323 size: 104,324 from: [-200, 80],325 spin: -90,326 },327] as const;328329function Intro(c: Ctx) {330 const t1 = pop(c, 14, CARD);331 const t2 = pop(c, 20, CARD);332 return (333 <>334 {SHAPES.map((sh, i) => {335 const p = pop(c, 2 + i * 3, CHIP);336 const float = Math.sin((c.lf + i * 20) * 0.06) * 6;337 return (338 <div339 key={sh.kind + i}340 style={{341 position: "absolute",342 left: sh.x + sh.from[0] * (1 - p),343 top: sh.y + sh.from[1] * (1 - p) + float,344 transform: `rotate(${sh.spin * (1 - p) + c.lf * (i % 2 ? 0.4 : -0.3)}deg) scale(${0.4 + 0.6 * p})`,345 }}346 >347 <Shape348 kind={sh.kind}349 color={sh.color === "accent" ? c.accent : sh.color}350 size={sh.size}351 />352 </div>353 );354 })}355 <div style={{ position: "absolute", left: 28, right: 28, top: 330 }}>356 <Rise t={t1}>357 <Display size={136} color={CREAM}>358 {c.s.year}359 </Display>360 </Rise>361 <Rise t={t2}>362 <Display size={62} color={CREAM} style={{ marginTop: 4 }}>363 in {c.s.product}364 </Display>365 </Rise>366 </div>367 <div368 style={{369 position: "absolute",370 left: 28,371 bottom: 44,372 fontSize: 17,373 fontWeight: 400,374 color: CREAM,375 opacity: interpolate(c.lf, [34, 44], [0, 1], CL),376 }}377 >378 Let’s see what you shipped →379 </div>380 </>381 );382}383384function Shipped(c: Ctx) {385 const slam = interpolate(c.lf, [4, 11], [0, 1], {386 ...CL,387 easing: Easing.bezier(0.55, 0, 1, 0.45),388 });389 const settle = pop(c, 11, CHIP);390 const scale = c.lf < 11 ? 3.2 - 2.2 * slam : 1 + (1 - settle) * -0.06;391 const shake =392 c.lf >= 11393 ? Math.sin((c.lf - 11) * 2.6) * 7 * Math.exp(-(c.lf - 11) * 0.4)394 : 0;395 const tiles = Math.min(c.s.videos, 42);396 return (397 <div398 style={{399 position: "absolute",400 inset: 0,401 transform: `translate(${shake}px, ${shake * 0.6}px)`,402 }}403 >404 <div style={{ position: "absolute", left: 28, top: c.top + 70 }}>405 <Rise t={pop(c, 0, CARD)}>406 <Display size={40} color={INK}>407 You shipped408 </Display>409 </Rise>410 </div>411 <div412 style={{413 position: "absolute",414 left: 0,415 right: 0,416 top: c.top + 120,417 display: "flex",418 justifyContent: "center",419 transform: `scale(${scale})`,420 opacity: clamp(slam * 3),421 filter: `blur(${(1 - slam) * 6}px)`,422 }}423 >424 <Display size={250} color={INK}>425 {c.s.videos}426 </Display>427 </div>428 <div429 style={{430 position: "absolute",431 left: 28,432 right: 28,433 top: c.top + 360,434 display: "flex",435 justifyContent: "space-between",436 alignItems: "baseline",437 }}438 >439 <Rise t={pop(c, 14, CARD)}>440 <Display size={60} color={INK}>441 videos442 </Display>443 </Rise>444 <div445 style={{446 fontSize: 17,447 fontWeight: 400,448 color: INK,449 opacity: interpolate(c.lf, [20, 28], [0, 1], CL),450 }}451 >452 one every 8.7 days453 </div>454 </div>455 <div456 style={{457 position: "absolute",458 left: 28,459 top: c.top + 448,460 width: 337,461 display: "grid",462 gridTemplateColumns: "repeat(7, 1fr)",463 gap: 6,464 }}465 >466 {Array.from({ length: tiles }, (_, i) => {467 const p = pop(c, 18 + i * 0.6, CARD);468 const tone = [INK, c.accent, ORANGE, INK, PINK, INK][469 Math.floor(hash(i) * 6)470 ];471 return (472 <div473 key={`t${i}`}474 style={{475 height: 32,476 borderRadius: i % 5 === 2 ? 16 : 7,477 background: tone,478 opacity: clamp(p * 2),479 transform: `scale(${0.5 + 0.5 * p}) rotate(${(1 - p) * 30}deg)`,480 }}481 />482 );483 })}484 </div>485 </div>486 );487}488489function TopComponent(c: Ctx) {490 const words = ["ship", "it", "today."];491 const stack = [492 { rot: -7, dx: -12, col: PINK, at: 10 },493 { rot: 5, dx: 14, col: LIME, at: 15 },494 { rot: -1.5, dx: 0, col: INK, at: 20 },495 ];496 return (497 <>498 <div499 style={{ position: "absolute", left: 28, right: 28, top: c.top + 64 }}500 >501 <div502 style={{503 fontSize: 15,504 fontWeight: 400,505 color: PINK,506 letterSpacing: 0.4,507 textTransform: "uppercase",508 opacity: interpolate(c.lf, [2, 8], [0, 1], CL),509 }}510 >511 Your top component512 </div>513 <Rise t={pop(c, 4, CARD)} style={{ marginTop: 10 }}>514 <Display size={58} color="#fff">515 {c.s.topComponent}516 </Display>517 </Rise>518 </div>519 <div520 style={{521 position: "absolute",522 left: 46,523 top: c.top + 230,524 width: 300,525 height: 190,526 }}527 >528 {stack.map((k, i) => {529 const p = pop(c, k.at, CARD);530 return (531 <div532 key={k.col}533 style={{534 position: "absolute",535 inset: 0,536 borderRadius: 22,537 background: k.col,538 transform: `translate(${k.dx}px, ${(1 - p) * -420}px) rotate(${k.rot + (1 - p) * 18}deg) scale(${1 + (1 - p) * 0.3})`,539 boxShadow: "0 18px 40px rgba(0,0,0,0.25)",540 display: "flex",541 alignItems: "center",542 justifyContent: "center",543 gap: 10,544 }}545 >546 {i === 2547 ? words.map((w, j) => {548 const on = pop(c, 30 + j * 7, CHIP);549 const hot =550 c.lf >= 30 && Math.floor((c.lf - 30) / 7) % 3 === j;551 return (552 <div553 key={w}554 style={{555 fontFamily: display,556 fontWeight: 400,557 fontSize: 42,558 letterSpacing: -1.5,559 color: hot ? INK : "#fff",560 background: hot ? LIME : "transparent",561 borderRadius: 10,562 padding: "0 6px",563 transform: `scale(${on}) translateY(${(1 - on) * 20}px)`,564 }}565 >566 {w}567 </div>568 );569 })570 : null}571 </div>572 );573 })}574 </div>575 <div576 style={{ position: "absolute", left: 28, right: 28, top: c.top + 470 }}577 >578 {c.s.runnersUp.slice(0, 3).map((name, i) => {579 const p = pop(c, 40 + i * 6, CARD);580 return (581 <div582 key={name}583 style={{584 display: "flex",585 alignItems: "center",586 gap: 16,587 height: 64,588 borderTop: "1.5px solid rgba(255,255,255,0.25)",589 transform: `translateX(${(1 - p) * 360}px)`,590 }}591 >592 <Display size={34} color={PINK} style={{ width: 30 }}>593 {i + 2}594 </Display>595 <div596 style={{597 width: 44,598 height: 44,599 borderRadius: 10,600 background: [LIME, ORANGE, CREAM][i],601 display: "flex",602 alignItems: "center",603 justifyContent: "center",604 }}605 >606 <Shape607 kind={(["star", "ring", "square"] as const)[i]}608 color={INK}609 size={22}610 />611 </div>612 <div style={{ flex: 1 }}>613 <div style={{ fontSize: 18, fontWeight: 400, color: "#fff" }}>614 {name}615 </div>616 <div617 style={{618 fontSize: 13,619 color: "rgba(255,255,255,0.7)",620 marginTop: 2,621 }}622 >623 in {[14, 9, 6][i]} videos624 </div>625 </div>626 </div>627 );628 })}629 </div>630 </>631 );632}633634function Percentile(c: Ctx) {635 const big = pop(c, 3, CHIP);636 const draw = interpolate(c.lf, [14, 64], [0, 1], { ...CL, easing: outCubic });637 const strip = interpolate(c.lf, [2, 28], [1, 0], { ...CL, easing: outCubic });638 return (639 <>640 <div641 style={{642 position: "absolute",643 right: 0,644 top: c.top + 336,645 width: 44,646 bottom: 0,647 transform: `translateY(${strip * 600}px)`,648 }}649 >650 {Array.from({ length: 22 }, (_, i) =>651 (i + Math.floor(i / 2)) % 2 === 0 ? (652 <div653 key={`c${i}`}654 style={{655 position: "absolute",656 left: (i % 2) * 22,657 top: Math.floor(i / 2) * 44,658 width: 22,659 height: 44,660 background: CREAM,661 }}662 />663 ) : null,664 )}665 </div>666 <div667 style={{668 position: "absolute",669 left: 0,670 right: 0,671 top: c.top + 60,672 textAlign: "center",673 }}674 >675 <Rise t={pop(c, 0, CARD)}>676 <Display size={30} color={CREAM}>677 You’re in great company.678 </Display>679 </Rise>680 <div681 style={{682 display: "flex",683 justifyContent: "center",684 marginTop: 14,685 opacity: clamp(big * 2),686 transform: `scale(${0.6 + 0.4 * big}) rotate(${(1 - big) * -8}deg)`,687 }}688 >689 <Display690 size={170}691 color="#8FB4FF"692 style={{693 WebkitTextStroke: `4px ${CREAM}`,694 textShadow: `6px 6px 0 ${c.accent}`,695 }}696 >697 {c.s.percentile}%698 </Display>699 </div>700 <div701 style={{702 fontSize: 16,703 color: CREAM,704 marginTop: 10,705 opacity: interpolate(c.lf, [14, 22], [0, 1], CL),706 }}707 >708 Top {c.s.percentile}% of {c.s.product} builders this year.709 </div>710 </div>711 <div712 style={{713 position: "absolute",714 left: 24,715 top: c.top + 352,716 opacity: interpolate(c.lf, [18, 26], [0, 1], CL),717 }}718 >719 <Display size={24} color={CREAM}>720 Your crew721 </Display>722 </div>723 <div724 style={{725 position: "absolute",726 left: 24,727 top: c.top + 392,728 width: 290,729 display: "grid",730 gridTemplateColumns: "repeat(3, 1fr)",731 gap: 12,732 }}733 >734 {c.s.crew.slice(0, 6).map((m, i) => {735 const p = pop(c, 22 + i * 3, CARD);736 return (737 <div738 key={m.name}739 style={{740 background: CREAM,741 padding: 4,742 opacity: clamp(p * 2),743 transform: `scale(${0.7 + 0.3 * p}) rotate(${(1 - p) * (i % 2 ? 14 : -14) + (i % 3 === 1 ? 2 : -1.5)}deg)`,744 boxShadow: "0 6px 16px rgba(0,0,0,0.35)",745 }}746 >747 <Portrait color={m.color} size={80} name={m.name} />748 <div749 style={{750 fontSize: 10.5,751 fontWeight: 400,752 color: INK,753 padding: "5px 2px 2px",754 whiteSpace: "nowrap",755 overflow: "hidden",756 }}757 >758 {m.name}759 </div>760 </div>761 );762 })}763 </div>764 <svg765 width={SW}766 height={200}767 viewBox="0 0 393 200"768 style={{ position: "absolute", left: 0, bottom: -40 }}769 >770 <path771 d="M-10 150 C 40 60, 90 200, 120 130 S 70 40, 40 120 S 180 210, 230 150 S 330 60, 410 120"772 fill="none"773 stroke={CREAM}774 strokeWidth={3}775 strokeLinecap="round"776 pathLength={1}777 strokeDasharray={1}778 strokeDashoffset={1 - draw}779 />780 </svg>781 </>782 );783}784785function Share(c: Ctx) {786 const card = pop(c, 12, CARD);787 const tapAt = 66;788 const press = interpolate(789 c.lf,790 [tapAt - 2, tapAt, tapAt + 4, tapAt + 8],791 [0, 1, 1, 0],792 CL,793 );794 const burst = clamp((c.lf - tapAt) / 22);795 const rows = [796 ["Videos shipped", String(c.s.videos)],797 ["Top component", c.s.topComponent],798 ["Minutes rendered", c.s.minutes],799 ["Builder rank", `Top ${c.s.percentile}%`],800 ];801 return (802 <>803 <div804 style={{805 position: "absolute",806 left: 0,807 right: 0,808 top: c.top + 52,809 textAlign: "center",810 opacity: interpolate(c.lf, [6, 14], [0, 1], CL),811 }}812 >813 <Display size={30} color={INK}>814 That’s a wrap.815 </Display>816 </div>817 <div818 style={{819 position: "absolute",820 left: 46,821 top: c.top + 110,822 width: 300,823 height: 476,824 borderRadius: 26,825 background: INK,826 overflow: "hidden",827 transform: `translateY(${(1 - card) * 500}px) rotate(${(1 - card) * 16 - 2 + (c.lf > tapAt ? Math.sin((c.lf - tapAt) * 0.5) * 1.5 * (1 - burst) : 0)}deg)`,828 boxShadow: "0 30px 60px rgba(0,0,0,0.35)",829 }}830 >831 <div832 style={{833 position: "relative",834 height: 170,835 background: c.accent,836 overflow: "hidden",837 }}838 >839 <div840 style={{841 position: "absolute",842 left: -30,843 top: -40,844 transform: `rotate(${c.lf * 0.6}deg)`,845 }}846 >847 <Shape kind="star" color={LIME} size={150} />848 </div>849 <div style={{ position: "absolute", right: -40, bottom: -60 }}>850 <Shape kind="circle" color={PINK} size={150} />851 </div>852 <div style={{ position: "absolute", left: 22, bottom: 18 }}>853 <Display size={22} color="#fff">854 My855 </Display>856 <Display size={54} color="#fff">857 {c.s.year}858 </Display>859 </div>860 </div>861 <div style={{ padding: "16px 22px 0" }}>862 {rows.map(([k, v], i) => (863 <div864 key={k}865 style={{866 padding: "9px 0",867 borderBottom:868 i < 3 ? "1px solid rgba(255,255,255,0.12)" : "none",869 opacity: interpolate(870 c.lf,871 [14 + i * 3, 20 + i * 3],872 [0, 1],873 CL,874 ),875 }}876 >877 <div878 style={{879 fontSize: 11.5,880 fontWeight: 400,881 color: "rgba(255,255,255,0.6)",882 }}883 >884 {k}885 </div>886 <div887 style={{888 fontFamily: display,889 fontWeight: 400,890 fontSize: 22,891 color: [LIME, PINK, CREAM, "#8FB4FF"][i],892 letterSpacing: -0.6,893 marginTop: 1,894 }}895 >896 {v}897 </div>898 </div>899 ))}900 <div901 style={{902 fontSize: 12,903 fontWeight: 400,904 color: "rgba(255,255,255,0.55)",905 marginTop: 10,906 }}907 >908 {c.s.url}909 </div>910 </div>911 </div>912 {burst > 0 && burst < 1913 ? Array.from({ length: 14 }, (_, i) => {914 const a = (i / 14) * Math.PI * 2 + hash(i) * 0.4;915 const d = 150 + hash(i + 7) * 130;916 return (917 <div918 key={`b${i}`}919 style={{920 position: "absolute",921 left: 196 + Math.cos(a) * d * outCubic(burst) - 9,922 top:923 c.top +924 330 +925 Math.sin(a) * d * outCubic(burst) -926 9 +927 burst * burst * 60,928 opacity: 1 - burst,929 transform: `rotate(${burst * 300 * (i % 2 ? 1 : -1)}deg)`,930 }}931 >932 <Shape933 kind={(["star", "circle", "square", "pill"] as const)[i % 4]}934 color={[LIME, c.accent, ORANGE, CREAM][i % 4]}935 size={18}936 />937 </div>938 );939 })940 : null}941 <div942 style={{943 position: "absolute",944 left: 96,945 right: 96,946 bottom: 48,947 height: 52,948 borderRadius: 999,949 background: INK,950 color: "#fff",951 display: "flex",952 alignItems: "center",953 justifyContent: "center",954 gap: 10,955 fontSize: 17,956 fontWeight: 400,957 transform: `translateY(${(1 - pop(c, 30, CARD)) * 120}px) scale(${1 - press * 0.06})`,958 }}959 >960 <svg961 width={18}962 height={18}963 viewBox="0 0 24 24"964 fill="none"965 stroke="#fff"966 strokeWidth={2.2}967 strokeLinecap="round"968 strokeLinejoin="round"969 >970 <path d="M12 15V4M8 7.5 12 4l4 3.5M6 11v8.5h12V11" />971 </svg>972 Share this story973 </div>974 </>975 );976}977978const SLIDES = [979 { bg: INK, body: Intro, ui: CREAM },980 { bg: LIME, body: Shipped, ui: INK },981 { bg: "accent", body: TopComponent, ui: "#FFFFFF" },982 { bg: "#1B1B1B", body: Percentile, ui: CREAM },983 { bg: PINK, body: Share, ui: INK },984];985986function enterClip(i: number, e: number): React.CSSProperties {987 if (i === 1) return { clipPath: `circle(${e * 980}px at 50% 88%)` };988 if (i === 2) {989 const x = -40 + e * 180;990 return { clipPath: `polygon(0 0, ${x}% 0, ${x - 40}% 100%, 0 100%)` };991 }992 if (i === 3) return { opacity: clamp(e * 2.4) };993 return {};994}995996function Screen({997 frame,998 fps,999 s,1000 accent,1001 top,1002}: {1003 frame: number;1004 fps: number;1005 s: YearInReviewStats;1006 accent: string;1007 top: number;1008}) {1009 let cur = 0;1010 for (let i = 0; i < STARTS.length; i++) if (frame >= STARTS[i]) cur = i;1011 const ui =1012 SLIDES[cur > 0 && frame < STARTS[cur] + TR * 0.45 ? cur - 1 : cur].ui;1013 const visible = SLIDES.map((_, i) => i).filter(1014 (i) => i === cur || (i === cur - 1 && frame < STARTS[cur] + TR),1015 );1016 return (1017 <div1018 style={{1019 position: "absolute",1020 inset: 0,1021 overflow: "hidden",1022 background: INK,1023 }}1024 >1025 {visible.map((i) => {1026 const lf = frame - STARTS[i];1027 const sl = SLIDES[i];1028 const bg = sl.bg === "accent" ? accent : sl.bg;1029 const e = spring({1030 frame: lf,1031 fps,1032 config: HEAVY,1033 durationInFrames: TR,1034 });1035 const leaving = i < cur ? clamp((frame - STARTS[cur]) / TR) : 0;1036 const Body = sl.body;1037 const circles = i === 4 && lf < TR + 6;1038 return (1039 <div1040 key={`s${i}`}1041 style={{1042 position: "absolute",1043 inset: 0,1044 background: circles ? "transparent" : bg,1045 overflow: "hidden",1046 ...(i === cur && i > 0 ? enterClip(i, e) : {}),1047 transform:1048 i === cur && i === 31049 ? `scale(${1.05 - 0.05 * e})`1050 : `scale(${1 - leaving * 0.08}) rotate(${leaving * (i % 2 ? 3 : -3)}deg)`,1051 }}1052 >1053 {circles1054 ? Array.from({ length: 30 }, (_, k) => {1055 const col = k % 5;1056 const row = Math.floor(k / 5);1057 const p = spring({1058 frame: lf - (5 - row) * 1.6 - col * 0.6,1059 fps,1060 config: CHIP,1061 });1062 return (1063 <div1064 key={`c${k}`}1065 style={{1066 position: "absolute",1067 left: col * 80 - 40 + 39,1068 top: row * 150 - 80 + 75,1069 width: 160,1070 height: 160,1071 marginLeft: -80,1072 marginTop: -80,1073 borderRadius: "50%",1074 background: bg,1075 border: `3px solid ${CREAM}`,1076 transform: `scale(${p * 1.3})`,1077 }}1078 />1079 );1080 })1081 : null}1082 <Body lf={lf} fps={fps} s={s} accent={accent} top={top} />1083 </div>1084 );1085 })}1086 <div1087 style={{1088 position: "absolute",1089 left: 14,1090 right: 14,1091 top: top - 40,1092 display: "flex",1093 gap: 4,1094 zIndex: 5,1095 }}1096 >1097 {SLIDES.map((_, i) => {1098 const len = (STARTS[i + 1] ?? STARTS[i] + 110) - STARTS[i];1099 const fill = clamp((frame - STARTS[i]) / len);1100 return (1101 <div1102 key={`p${i}`}1103 style={{1104 flex: 1,1105 height: 3,1106 borderRadius: 2,1107 background:1108 ui === INK ? "rgba(18,18,18,0.22)" : "rgba(255,255,255,0.3)",1109 overflow: "hidden",1110 }}1111 >1112 <div1113 style={{1114 width: `${fill * 100}%`,1115 height: "100%",1116 background: ui,1117 }}1118 />1119 </div>1120 );1121 })}1122 </div>1123 <div1124 style={{1125 position: "absolute",1126 left: 18,1127 right: 18,1128 top: top - 26,1129 height: 30,1130 display: "flex",1131 alignItems: "center",1132 justifyContent: "space-between",1133 zIndex: 5,1134 }}1135 >1136 <div1137 style={{1138 fontFamily: display,1139 fontWeight: 400,1140 fontSize: 18,1141 letterSpacing: -0.6,1142 color: ui,1143 }}1144 >1145 {s.product}1146 </div>1147 <div style={{ display: "flex", gap: 16 }}>1148 <svg1149 width={20}1150 height={20}1151 viewBox="0 0 24 24"1152 fill="none"1153 stroke={ui}1154 strokeWidth={2}1155 strokeLinecap="round"1156 strokeLinejoin="round"1157 >1158 <path d="M4.5 9.5h3l4-3.5v12l-4-3.5h-3zM15 9a4 4 0 0 1 0 6M17.5 6.5a7.5 7.5 0 0 1 0 11" />1159 </svg>1160 <svg1161 width={20}1162 height={20}1163 viewBox="0 0 24 24"1164 fill="none"1165 stroke={ui}1166 strokeWidth={2.2}1167 strokeLinecap="round"1168 >1169 <path d="M6 6l12 12M18 6 6 18" />1170 </svg>1171 </div>1172 </div>1173 </div>1174 );1175}11761177function StatusBar({ color }: { color: string }) {1178 return (1179 <div1180 style={{1181 position: "absolute",1182 top: 0,1183 left: 0,1184 right: 0,1185 height: 54,1186 display: "flex",1187 alignItems: "center",1188 justifyContent: "space-between",1189 padding: "6px 34px 0 50px",1190 zIndex: 8,1191 }}1192 >1193 <span style={{ fontSize: 17, fontWeight: 400, color }}>9:41</span>1194 <div style={{ display: "flex", gap: 6, alignItems: "center" }}>1195 <svg width="18" height="12" viewBox="0 0 18 12">1196 {[0, 1, 2, 3].map((i) => (1197 <rect1198 key={i}1199 x={i * 4.6}1200 y={9 - i * 3}1201 width={3.2}1202 height={3 + i * 3}1203 rx={0.8}1204 fill={color}1205 />1206 ))}1207 </svg>1208 <div1209 style={{1210 width: 25,1211 height: 12,1212 borderRadius: 3.5,1213 border: `1px solid ${color}`,1214 padding: 1.5,1215 boxSizing: "border-box",1216 }}1217 >1218 <div1219 style={{1220 width: "78%",1221 height: "100%",1222 borderRadius: 2,1223 background: color,1224 }}1225 />1226 </div>1227 </div>1228 </div>1229 );1230}12311232/** The foreground at `scale`, around the frame's center; nothing extra at 1. */1233function ScaleLayer({1234 scale,1235 children,1236}: {1237 scale: number;1238 children: React.ReactNode;1239}) {1240 if (scale === 1) return children;1241 return (1242 <AbsoluteFill style={{ transform: `scale(${scale})` }}>1243 {children}1244 </AbsoluteFill>1245 );1246}12471248export function YearInReview({1249 stats,1250 accent = "#3B5BFD",1251 speed = 1,1252 device = "phone",1253 chapters = ["Your year", "Shipped", "Top component", "Your rank", "Share"],1254 rail: showRail = true,1255 ink,1256 background,1257 fontFamily = hanken,1258 scale = 1,1259 delay = 0,1260 ground,1261 groundParams,1262}: YearInReviewProps) {1263 const frame = Math.max(0, useCurrentFrame() - delay) * speed;1264 const fg = ink ?? "#F4F1EA";1265 const { width, height, fps } = useVideoConfig();1266 const tall = height > width;1267 const s = { ...DEFAULT_STATS, ...stats };1268 const phone = device === "phone";1269 let cur = 0;1270 for (let i = 0; i < STARTS.length; i++) if (frame >= STARTS[i]) cur = i;1271 const enter = spring({ frame, fps, config: HEAVY });1272 const fw = phone ? SW + BEZEL * 2 : SW;1273 const fh = phone ? SH + BEZEL * 2 : SH;1274 const k = tall ? (height * 0.62) / fh : (height * 0.9) / fh;1275 const center = tall1276 ? { x: width / 2, y: height * 0.37 }1277 : { x: width * 0.66, y: height / 2 };1278 const u = width / (tall ? 1080 : 1280);1279 const push = 1 + 0.02 * (frame / 480);1280 const ui =1281 SLIDES[cur > 0 && frame < STARTS[cur] + TR * 0.45 ? cur - 1 : cur].ui;1282 const act = (i: number) =>1283 interpolate(1284 frame,1285 [1286 STARTS[i],1287 STARTS[i] + 12,1288 STARTS[i + 1] ?? 1e9,1289 (STARTS[i + 1] ?? 1e9) + 8,1290 ],1291 [0, 1, 1, 0],1292 { ...CL, easing: ENTER },1293 );1294 const railIn = interpolate(frame, [6, 22], [0, 1], { ...CL, easing: ENTER });1295 const rail = tall ? (1296 <div1297 style={{1298 position: "absolute",1299 left: 80 * u,1300 right: 80 * u,1301 top: height * 0.735,1302 }}1303 >1304 <div1305 style={{1306 display: "flex",1307 gap: 8 * u,1308 marginBottom: 28 * u,1309 opacity: railIn,1310 }}1311 >1312 {chapters.map((ch, i) => (1313 <div1314 key={ch}1315 style={{1316 flex: 1,1317 height: 3 * u,1318 borderRadius: 2,1319 background: "rgba(255,255,255,0.18)",1320 overflow: "hidden",1321 }}1322 >1323 <div1324 style={{1325 width: `${clamp((frame - STARTS[i]) / ((STARTS[i + 1] ?? STARTS[i] + 120) - STARTS[i])) * 100}%`,1326 height: "100%",1327 background: fg,1328 }}1329 />1330 </div>1331 ))}1332 </div>1333 {chapters.map((ch, i) => {1334 const a = act(i);1335 if (a <= 0) return null;1336 return (1337 <div1338 key={ch}1339 style={{ position: "absolute", left: 0, right: 0, top: 40 * u }}1340 >1341 <div1342 style={{1343 fontSize: 28 * u,1344 color: "rgba(244,241,234,0.55)",1345 fontVariantNumeric: "tabular-nums",1346 opacity: a,1347 }}1348 >1349 0{i + 1} / 0{chapters.length}1350 </div>1351 <div style={{ overflow: "hidden", paddingBottom: 10 * u }}>1352 <div1353 style={{1354 marginTop: 10 * u,1355 fontFamily: display,1356 fontSize: 104 * u,1357 fontWeight: 300,1358 lineHeight: 1,1359 letterSpacing: "-0.045em",1360 color: fg,1361 transform: `translateY(${(1 - a) * 105}%)`,1362 }}1363 >1364 {ch}1365 </div>1366 </div>1367 </div>1368 );1369 })}1370 </div>1371 ) : (1372 <div1373 style={{1374 position: "absolute",1375 left: 96 * u,1376 top: height / 2 - 170 * u,1377 width: 420 * u,1378 }}1379 >1380 <div1381 style={{1382 fontSize: 20 * u,1383 color: "rgba(244,241,234,0.55)",1384 marginBottom: 22 * u,1385 opacity: railIn,1386 transform: `translateY(${(1 - railIn) * 10}px)`,1387 }}1388 >1389 {s.year} in {s.product}1390 </div>1391 {chapters.map((ch, i) => {1392 const a = act(i);1393 const shown = interpolate(frame, [8 + i * 3, 22 + i * 3], [0, 1], {1394 ...CL,1395 easing: ENTER,1396 });1397 return (1398 <div1399 key={ch}1400 style={{1401 display: "flex",1402 alignItems: "baseline",1403 gap: 18 * u,1404 height: 62 * u,1405 opacity: shown * (0.32 + 0.68 * a),1406 transform: `translateX(${a * 14 * u + (1 - shown) * 20}px)`,1407 }}1408 >1409 <span1410 style={{1411 width: 34 * u,1412 fontSize: 18 * u,1413 color: "rgba(244,241,234,0.6)",1414 fontVariantNumeric: "tabular-nums",1415 }}1416 >1417 0{i + 1}1418 </span>1419 <span1420 style={{1421 fontFamily: display,1422 fontSize: 44 * u,1423 fontWeight: 300,1424 letterSpacing: "-0.04em",1425 color: fg,1426 }}1427 >1428 {ch}1429 </span>1430 </div>1431 );1432 })}1433 </div>1434 );1435 return (1436 <AbsoluteFill style={{ fontFamily, overflow: "hidden" }}>1437 {background === undefined ? (1438 <>1439 <GshGround1440 preset={ground ?? "charcoal-satin"}1441 params={groundParams}1442 timeOffset={3}1443 timeScale={0.3}1444 />1445 <AbsoluteFill1446 style={{1447 background: tall1448 ? "linear-gradient(180deg, rgba(6,6,8,0.15) 40%, rgba(6,6,8,0.7) 100%)"1449 : "linear-gradient(90deg, rgba(6,6,8,0.72) 0%, rgba(6,6,8,0.25) 50%, rgba(6,6,8,0.1) 100%)",1450 }}1451 />1452 </>1453 ) : (1454 <AbsoluteFill1455 style={{1456 background: background === "transparent" ? undefined : background,1457 }}1458 />1459 )}1460 <ScaleLayer scale={scale}>1461 {showRail ? rail : null}1462 <div1463 style={{1464 position: "absolute",1465 left: center.x - fw / 2,1466 top: center.y - fh / 2,1467 width: fw,1468 height: fh,1469 transform: `translateY(${(1 - enter) * height * 0.7}px) scale(${k * push})`,1470 }}1471 >1472 {phone ? (1473 <div1474 style={{1475 position: "absolute",1476 inset: 0,1477 borderRadius: 66,1478 background: "#0B0B0C",1479 boxShadow:1480 "inset 0 0 0 1.5px #6E6E73, inset 0 0 0 3px #1C1C1E, 0 50px 100px -20px rgba(0,0,0,0.75)",1481 }}1482 />1483 ) : null}1484 <div1485 style={{1486 position: "absolute",1487 left: phone ? BEZEL : 0,1488 top: phone ? BEZEL : 0,1489 width: SW,1490 height: SH,1491 borderRadius: phone ? 55 : 30,1492 overflow: "hidden",1493 boxShadow: phone1494 ? "none"1495 : "0 0 0 1px rgba(255,255,255,0.08), 0 50px 100px -20px rgba(0,0,0,0.75)",1496 }}1497 >1498 <Screen1499 frame={frame}1500 fps={fps}1501 s={s}1502 accent={accent}1503 top={phone ? 104 : 64}1504 />1505 {phone ? (1506 <>1507 <StatusBar color={ui} />1508 <div1509 style={{1510 position: "absolute",1511 top: 11,1512 left: (SW - 126) / 2,1513 width: 126,1514 height: 37,1515 borderRadius: 19,1516 background: "#000",1517 zIndex: 20,1518 }}1519 />1520 <div1521 style={{1522 position: "absolute",1523 bottom: 8,1524 left: (SW - 140) / 2,1525 width: 140,1526 height: 5,1527 borderRadius: 3,1528 background: ui,1529 opacity: 0.85,1530 zIndex: 20,1531 }}1532 />1533 </>1534 ) : null}1535 </div>1536 </div>1537 </ScaleLayer>1538 </AbsoluteFill>1539 );1540}









