Phone Frame
iPhone mockup animation: phone device frame for app screenshots and screen recordings. iPhone-style device frame with a dynamic island and a screen slot — flat or lightly 3D-tilted, with rise, rotate-in, or float entrances and a subtle float loop.
Source
components/kuchi/phone-frame.tsx
1"use client";23import type { CSSProperties, ReactNode } from "react";4import {5 Easing,6 getRemotionEnvironment,7 Img,8 interpolate,9 OffthreadVideo,10 staticFile,11 useCurrentFrame,12 useVideoConfig,13} from "remotion";14import {15 resolveFont,16 type KuchiTheme,17 useKuchiTheme,18 withAlpha,19} from "@/lib/kuchi-ui";2021export type PhoneFrameVariant = "flat" | "tilt" | "showcase";22export type PhoneFrameEntrance = "rise" | "rotate-in" | "float";2324export interface PhoneFrameProps {25 /** Screen content. Falls back to `screenSrc`, then the ride-summary placeholder. */26 children?: ReactNode;27 /**28 * Image *or* video to fill the screen when `children` is omitted. Videos29 * (.mp4/.webm/.mov/.m4v) play via `<OffthreadVideo>`, images via `<Img>` —30 * both cover-fit the screen.31 */32 screenSrc?: string;33 /**34 * `flat` faces the camera; `tilt` adds a static 3D rotateY; `showcase` is a35 * cinematic crane move — the camera starts low at the bottom-left corner of36 * the laid-back device, sweeps up the screen while zooming in, then pulls37 * back and settles on a straight frontal view.38 */39 variant?: PhoneFrameVariant;40 /** How the device enters the frame. */41 entrance?: PhoneFrameEntrance;42 /** Device shell color. Defaults to the theme's `foreground`. */43 bezelColor?: string;44 /** Screen fill behind the children. Defaults to the theme's `card`. */45 screenColor?: string;46 /** Design-system token overrides. */47 theme?: Partial<KuchiTheme>;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 /** Outer body corner radius. Defaults to real-device curvature. */59 radius?: number;60 /** Screen corner radius. Defaults to `radius - bezel` (concentric corners). */61 screenRadius?: number;62 /** CSS box-shadow under the device. Empty string disables it. */63 shadow?: string;64 /** Uniform size multiplier for the whole device. */65 scale?: number;66 /** Render the dynamic-island cutout over the screen. */67 showDynamicIsland?: boolean;68 /** Gentle vertical bob after the entrance settles. */69 floatLoop?: boolean;70 /** Peak float displacement in pixels. */71 floatAmplitude?: number;72 /** rotateY angle (degrees) used by the `tilt` variant. */73 tiltAngle?: number;74 speed?: number;75 className?: string;76}7778const FONT_FAMILY =79 'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif';8081/** Device shell size — matches the ~0.488 width:height ratio of a real iPhone. */82export const DEVICE_WIDTH = 320;83export const DEVICE_HEIGHT = 656;8485/** Shell thickness between the body edge and the screen. */86export const BEZEL_WIDTH = 12;8788/** Outer body curvature: real devices sit near 16.5% of the body width. */89export const DEVICE_RADIUS_RATIO = 0.165;9091/** Frames the entrance takes before the device is fully settled. */92export const ENTRANCE_FRAMES = 30;9394/** Seconds per full float-loop cycle. */95export const FLOAT_PERIOD_SECONDS = 4.5;9697/** Default outer radius for a given device width (real-device curvature). */98export function deviceRadius(deviceWidth: number): number {99 return Math.round(deviceWidth * DEVICE_RADIUS_RATIO);100}101102/**103 * Concentric-corner rule: the screen radius is the body radius minus the104 * bezel thickness, floored so tiny radii never go negative.105 */106export function screenRadiusFor(107 radius: number,108 bezel: number = BEZEL_WIDTH,109): number {110 return Math.max(4, radius - bezel);111}112113export interface EntrancePose {114 opacity: number;115 translateY: number;116 rotateDeg: number;117 scale: number;118}119120/**121 * Pure entrance schedule. All three entrances settle to the identity pose by122 * `ENTRANCE_FRAMES`, so the float loop can take over without a seam.123 */124export function entrancePose(125 frame: number,126 entrance: PhoneFrameEntrance,127): EntrancePose {128 const clamp = {129 extrapolateLeft: "clamp",130 extrapolateRight: "clamp",131 } as const;132 const easeOut = Easing.out(Easing.cubic);133134 if (entrance === "rotate-in") {135 return {136 opacity: interpolate(frame, [0, 12], [0, 1], clamp),137 translateY: interpolate(frame, [0, 28], [60, 0], {138 ...clamp,139 easing: easeOut,140 }),141 rotateDeg: interpolate(frame, [0, 28], [-8, 0], {142 ...clamp,143 easing: easeOut,144 }),145 scale: interpolate(frame, [0, 28], [0.94, 1], {146 ...clamp,147 easing: easeOut,148 }),149 };150 }151152 if (entrance === "float") {153 return {154 opacity: interpolate(frame, [0, 16], [0, 1], clamp),155 translateY: 0,156 rotateDeg: 0,157 scale: interpolate(frame, [0, 24], [0.96, 1], {158 ...clamp,159 easing: easeOut,160 }),161 };162 }163164 // rise (default)165 return {166 opacity: interpolate(frame, [0, 12], [0, 1], clamp),167 translateY: interpolate(frame, [0, 26], [70, 0], {168 ...clamp,169 easing: easeOut,170 }),171 rotateDeg: 0,172 scale: 1,173 };174}175176/**177 * Deterministic float-loop offset in pixels. Starts at 0 with an upward178 * drift at `startFrame`, so it blends seamlessly out of any entrance.179 */180export function floatOffset(181 frame: number,182 fps: number,183 amplitude: number,184 startFrame = 0,185 periodSeconds: number = FLOAT_PERIOD_SECONDS,186): number {187 const local = Math.max(0, frame - startFrame);188 const value =189 Math.sin((local / (fps * periodSeconds)) * Math.PI * 2) * amplitude;190 // Negative = upward drift; the `=== 0` guard avoids returning -0.191 return value === 0 ? 0 : -value;192}193194/** Side-button spec (position along the edge, length) in body pixels. */195export const SIDE_BUTTONS: Array<{196 side: "left" | "right";197 top: number;198 length: number;199}> = [200 { side: "left", top: 118, length: 26 }, // action button201 { side: "left", top: 166, length: 46 }, // volume up202 { side: "left", top: 222, length: 46 }, // volume down203 { side: "right", top: 176, length: 68 }, // power204];205206// ─── Ride-summary demo screen ────────────────────────────────────────────────207// A glowing GPS route draws itself across a dark map while stat "insight" pills208// pop in along it — the default screen the phone shows off as it rotates.209210/** Screen interior (device minus bezel on both sides). */211const SCREEN_W = DEVICE_WIDTH - BEZEL_WIDTH * 2; // 296212const SCREEN_H = DEVICE_HEIGHT - BEZEL_WIDTH * 2; // 632213214/** Route waypoints in screen space; a closed loop drawn head-first from [0]. */215const ROUTE: ReadonlyArray<readonly [number, number]> = [216 [224, 450],217 [172, 462],218 [116, 460],219 [70, 450],220 [52, 412],221 [74, 382],222 [104, 388],223 [134, 372],224 [162, 380],225 [192, 364],226 [222, 372],227 [248, 396],228 [256, 424],229 [244, 448],230];231232/** Cumulative segment lengths of the closed polyline (last→first closes it). */233function routeCumLengths(pts: ReadonlyArray<readonly [number, number]>) {234 const cum = [0];235 let total = 0;236 for (let i = 0; i < pts.length; i++) {237 const a = pts[i];238 const b = pts[(i + 1) % pts.length];239 total += Math.hypot(b[0] - a[0], b[1] - a[1]);240 cum.push(total);241 }242 return { cum, total };243}244245const ROUTE_LEN = routeCumLengths(ROUTE);246247/** Point at fraction `f` (0..1) along the closed route — the draw head. */248export function pointAtFraction(249 f: number,250 pts: ReadonlyArray<readonly [number, number]> = ROUTE,251): { x: number; y: number } {252 const { cum, total } = pts === ROUTE ? ROUTE_LEN : routeCumLengths(pts);253 const target = Math.max(0, Math.min(1, f)) * total;254 for (let i = 0; i < pts.length; i++) {255 if (cum[i + 1] >= target) {256 const seg = cum[i + 1] - cum[i] || 1;257 const t = (target - cum[i]) / seg;258 const a = pts[i];259 const b = pts[(i + 1) % pts.length];260 return { x: a[0] + (b[0] - a[0]) * t, y: a[1] + (b[1] - a[1]) * t };261 }262 }263 const last = pts[pts.length - 1];264 return { x: last[0], y: last[1] };265}266267/** Catmull-Rom → cubic-bezier smoothing of a closed point loop into an SVG `d`. */268export function smoothClosedPath(269 pts: ReadonlyArray<readonly [number, number]>,270): string {271 const n = pts.length;272 const p = (i: number) => pts[((i % n) + n) % n];273 let d = `M ${p(0)[0]} ${p(0)[1]}`;274 for (let i = 0; i < n; i++) {275 const p0 = p(i - 1);276 const p1 = p(i);277 const p2 = p(i + 1);278 const p3 = p(i + 2);279 const c1x = p1[0] + (p2[0] - p0[0]) / 6;280 const c1y = p1[1] + (p2[1] - p0[1]) / 6;281 const c2x = p2[0] - (p3[0] - p1[0]) / 6;282 const c2y = p2[1] - (p3[1] - p1[1]) / 6;283 d += ` C ${c1x} ${c1y} ${c2x} ${c2y} ${p2[0]} ${p2[1]}`;284 }285 return `${d} Z`;286}287288const ROUTE_PATH = smoothClosedPath(ROUTE);289290/** An "insight" pill anchored to a point on the route. */291interface Pill {292 title: string;293 sub: string;294 icon: "climb" | "heart" | "trophy" | "bolt" | "flame";295 tint: string;296 x: number;297 y: number;298 anchor: readonly [number, number];299 appear: number;300}301302const PILLS: Pill[] = [303 {304 title: "BIG CLIMB",305 sub: "+993 ft",306 icon: "climb",307 tint: "#D2925F",308 x: 100,309 y: 196,310 anchor: [148, 372],311 appear: 74,312 },313 {314 title: "SETTLED",315 sub: "HR steady at 116",316 icon: "heart",317 tint: "#84B27C",318 x: 80,319 y: 234,320 anchor: [132, 374],321 appear: 60,322 },323 {324 title: "NEW PR",325 sub: "Fastest 5 mi",326 icon: "trophy",327 tint: "#ADA69E",328 x: 44,329 y: 292,330 anchor: [64, 398],331 appear: 40,332 },333 {334 title: "FASTEST SPLIT",335 sub: "23 mph avg",336 icon: "bolt",337 tint: "#ADA69E",338 x: 168,339 y: 300,340 anchor: [242, 378],341 appear: 52,342 },343 {344 title: "SPRINT",345 sub: "Hit 32 mph",346 icon: "flame",347 tint: "#CC6D5C",348 x: 158,349 y: 402,350 anchor: [232, 448],351 appear: 22,352 },353];354355/** Small monochrome pill glyphs, tinted per pill. */356function PillIcon({ kind, color }: { kind: Pill["icon"]; color: string }) {357 const stroke = {358 width: 11,359 height: 11,360 viewBox: "0 0 24 24",361 fill: "none",362 stroke: color,363 strokeWidth: 2.4,364 strokeLinecap: "round" as const,365 strokeLinejoin: "round" as const,366 };367 if (kind === "climb") {368 return (369 <svg aria-hidden {...stroke}>370 <title>climb</title>371 <path d="M7 17 17 7" />372 <path d="M8 7h9v9" />373 </svg>374 );375 }376 if (kind === "trophy") {377 return (378 <svg aria-hidden {...stroke}>379 <title>trophy</title>380 <path d="M7 4h10v5a5 5 0 0 1-10 0z" />381 <path d="M7 6H4v1a3 3 0 0 0 3 3" />382 <path d="M17 6h3v1a3 3 0 0 1-3 3" />383 <path d="M9 20h6M12 14v6" />384 </svg>385 );386 }387 if (kind === "heart") {388 return (389 <svg aria-hidden width={11} height={11} viewBox="0 0 24 24" fill={color}>390 <title>heart</title>391 <path d="M12 21S3.5 15.4 3.5 9.4C3.5 6.4 5.6 4.5 8 4.5c1.8 0 3.2 1.1 4 2.4.8-1.3 2.2-2.4 4-2.4 2.4 0 4.5 1.9 4.5 4.9 0 6-8.5 11.6-8.5 11.6z" />392 </svg>393 );394 }395 if (kind === "bolt") {396 return (397 <svg aria-hidden width={11} height={11} viewBox="0 0 24 24" fill={color}>398 <title>bolt</title>399 <path d="M13 2 4 14h6l-1 8 9-12h-6z" />400 </svg>401 );402 }403 return (404 <svg aria-hidden width={11} height={11} viewBox="0 0 24 24" fill={color}>405 <title>flame</title>406 <path d="M12 2c1 4 5 5 5 10a5 5 0 0 1-10 0c0-1.6.7-2.8 1.6-3.7.2 1.7 1.2 2.7 2.6 2.7-1-3 1-4 .8-9z" />407 </svg>408 );409}410411/** iOS-style status-bar right cluster: signal, wifi, battery. */412function StatusIcons() {413 return (414 <div style={{ display: "flex", alignItems: "center", gap: 5 }}>415 <svg aria-hidden width={16} height={11} viewBox="0 0 18 12" fill="#fff">416 <title>signal</title>417 <rect x="0" y="8" width="3" height="4" rx="1" />418 <rect x="5" y="5" width="3" height="7" rx="1" />419 <rect x="10" y="2.5" width="3" height="9.5" rx="1" />420 <rect x="15" y="0" width="3" height="12" rx="1" opacity="0.4" />421 </svg>422 <svg aria-hidden width={15} height={11} viewBox="0 0 16 12" fill="#fff">423 <title>wifi</title>424 <path d="M8 2.2c2.7 0 5.2 1 7 2.8l-1.5 1.6A7.8 7.8 0 0 0 8 4.4 7.8 7.8 0 0 0 2.5 6.6L1 5C2.8 3.2 5.3 2.2 8 2.2Z" />425 <path d="M8 6c1.5 0 2.9.6 4 1.6l-1.6 1.6A3.4 3.4 0 0 0 8 8.2c-.9 0-1.7.4-2.4 1L4 7.6A5.7 5.7 0 0 1 8 6Z" />426 <circle cx="8" cy="10.4" r="1.4" />427 </svg>428 <div429 style={{430 display: "flex",431 alignItems: "center",432 gap: 1.5,433 }}434 >435 <div436 style={{437 width: 20,438 height: 10,439 borderRadius: 3,440 border: "1px solid rgba(255,255,255,0.5)",441 padding: 1.5,442 }}443 >444 <div445 style={{446 width: "42%",447 height: "100%",448 borderRadius: 1,449 background: "#fff",450 }}451 />452 </div>453 <div454 style={{455 width: 1.5,456 height: 4,457 borderRadius: 1,458 background: "rgba(255,255,255,0.5)",459 }}460 />461 </div>462 </div>463 );464}465466/** One stat column in the header. */467function Stat({468 value,469 unit,470 label,471 accent,472}: {473 value: string;474 unit: string;475 label: string;476 accent?: boolean;477}) {478 const color = accent ? "#F0842E" : "#FFFFFF";479 const dim = accent ? "rgba(240,132,46,0.85)" : "rgba(255,255,255,0.42)";480 return (481 <div style={{ display: "flex", flexDirection: "column", gap: 3 }}>482 <div style={{ display: "flex", alignItems: "baseline", gap: 2 }}>483 <span484 style={{485 fontSize: 15,486 fontWeight: 700,487 color,488 letterSpacing: "-0.02em",489 }}490 >491 {value}492 </span>493 <span style={{ fontSize: 8, fontWeight: 600, color: dim }}>{unit}</span>494 </div>495 <span496 style={{497 fontSize: 7,498 fontWeight: 700,499 letterSpacing: "0.06em",500 color: dim,501 }}502 >503 {label}504 </span>505 </div>506 );507}508509export interface ShowcasePose {510 /** Device orientation (deg), applied inside the perspective. */511 rotateX: number;512 rotateY: number;513 rotateZ: number;514 /** Camera zoom + pan (screen px), applied outside the perspective. */515 zoom: number;516 x: number;517 y: number;518}519520/**521 * Keyframes of the `showcase` crane move, on normalized progress 0..1:522 * hold low at the bottom-left of the laid-back device → sweep up the screen523 * while zooming in → linger near the top → pull back to a straight frontal524 * view. Ends exactly at the identity pose, so a float loop can take over.525 */526const SHOWCASE_STOPS = [0, 0.1, 0.42, 0.62, 0.9, 1];527const SHOWCASE_KEYS: Record<keyof ShowcasePose, number[]> = {528 rotateX: [52, 36, 26, 12, 1.5, 0],529 rotateY: [28, 20, 10, 6, 1, 0],530 rotateZ: [30, 14, 2, 0, 0, 0],531 zoom: [2.6, 1.35, 2.75, 2.3, 1.04, 1],532 x: [60, 30, 0, -10, 0, 0],533 y: [-195, -40, 430, 380, 15, 0],534};535536/**537 * Cinematic "showcase" pose at `frame`, normalized to the composition length538 * so the move always completes regardless of duration. Each keyframe is a539 * natural rest point, so per-segment ease-in-out reads as one continuous move.540 */541export function showcasePose(542 frame: number,543 durationInFrames: number,544): ShowcasePose {545 const p = Math.max(0, Math.min(1, frame / Math.max(1, durationInFrames - 1)));546 const easing = Easing.inOut(Easing.cubic);547 const at = (values: number[]) =>548 interpolate(p, SHOWCASE_STOPS, values, { easing });549 return {550 rotateX: at(SHOWCASE_KEYS.rotateX),551 rotateY: at(SHOWCASE_KEYS.rotateY),552 rotateZ: at(SHOWCASE_KEYS.rotateZ),553 zoom: at(SHOWCASE_KEYS.zoom),554 x: at(SHOWCASE_KEYS.x),555 y: at(SHOWCASE_KEYS.y),556 };557}558559const CLAMP = { extrapolateLeft: "clamp", extrapolateRight: "clamp" } as const;560561/** Default screen: a glowing ride-summary map that draws itself with insight pills. */562function RideSummaryDemo({ frame, face }: { frame: number; face: string }) {563 const ease = Easing.bezier(0.2, 0.6, 0.35, 1);564 const draw = interpolate(frame, [12, 128], [0, 1], {565 ...CLAMP,566 easing: ease,567 });568 const fillIn = interpolate(frame, [70, 150], [0, 1], CLAMP);569 const head = pointAtFraction(draw);570 const hint = interpolate(frame, [0, 8, 70, 88], [0, 1, 1, 0], CLAMP);571572 return (573 <div574 style={{575 position: "absolute",576 inset: 0,577 overflow: "hidden",578 backgroundColor: "#0A0A0B",579 fontFamily: face,580 textRendering: "geometricPrecision",581 color: "#fff",582 }}583 >584 {/* Ambient terrain bleed under the route */}585 <div586 style={{587 position: "absolute",588 inset: 0,589 opacity: fillIn,590 background:591 "radial-gradient(120% 55% at 54% 90%, rgba(214,124,54,0.32), transparent 60%), radial-gradient(70% 40% at 46% 62%, rgba(104,158,92,0.24), transparent 62%)",592 }}593 />594595 {/* Route + glow + draw head */}596 <svg597 width={SCREEN_W}598 height={SCREEN_H}599 viewBox={`0 0 ${SCREEN_W} ${SCREEN_H}`}600 style={{ position: "absolute", inset: 0 }}601 >602 <title>ride route</title>603 <defs>604 <linearGradient605 id="pf-elev"606 x1="0"607 y1="340"608 x2="0"609 y2="470"610 gradientUnits="userSpaceOnUse"611 >612 <stop offset="0" stopColor="#7FA85E" stopOpacity="0.32" />613 <stop offset="0.55" stopColor="#BE9150" stopOpacity="0.28" />614 <stop offset="1" stopColor="#DE8138" stopOpacity="0.42" />615 </linearGradient>616 <filter id="pf-glow" x="-40%" y="-40%" width="180%" height="180%">617 <feGaussianBlur stdDeviation="4.5" />618 </filter>619 </defs>620621 <path d={ROUTE_PATH} fill="url(#pf-elev)" opacity={fillIn} />622623 {/* connectors from pills down to the route */}624 {PILLS.map((p) => (625 <line626 key={`c-${p.title}`}627 x1={p.anchor[0]}628 y1={p.anchor[1]}629 x2={p.x + 22}630 y2={p.y + 30}631 stroke="rgba(255,255,255,0.28)"632 strokeWidth={1}633 opacity={interpolate(634 frame,635 [p.appear, p.appear + 10],636 [0, 1],637 CLAMP,638 )}639 />640 ))}641642 {/* glow underlay + crisp stroke, both revealed by the draw */}643 <path644 d={ROUTE_PATH}645 fill="none"646 stroke="#FFEBD6"647 strokeWidth={7}648 strokeLinecap="round"649 opacity={0.55}650 pathLength={1}651 strokeDasharray={1}652 strokeDashoffset={1 - draw}653 filter="url(#pf-glow)"654 />655 <path656 d={ROUTE_PATH}657 fill="none"658 stroke="#FFFFFF"659 strokeWidth={2.4}660 strokeLinecap="round"661 pathLength={1}662 strokeDasharray={1}663 strokeDashoffset={1 - draw}664 />665666 {/* anchor dots where pills attach */}667 {PILLS.map((p) => (668 <circle669 key={`a-${p.title}`}670 cx={p.anchor[0]}671 cy={p.anchor[1]}672 r={2.4}673 fill="#EE8348"674 opacity={interpolate(675 frame,676 [p.appear, p.appear + 8],677 [0, 0.95],678 CLAMP,679 )}680 />681 ))}682683 {/* draw head */}684 {draw > 0 && (685 <>686 <circle687 cx={head.x}688 cy={head.y}689 r={7}690 fill="#FFFFFF"691 filter="url(#pf-glow)"692 />693 <circle cx={head.x} cy={head.y} r={3.4} fill="#FFFFFF" />694 </>695 )}696 </svg>697698 {/* Insight pills */}699 {PILLS.map((p) => {700 const t = interpolate(frame, [p.appear, p.appear + 12], [0, 1], {701 ...CLAMP,702 easing: ease,703 });704 return (705 <div706 key={p.title}707 style={{708 position: "absolute",709 left: p.x,710 top: p.y,711 display: "flex",712 alignItems: "center",713 gap: 6,714 padding: "4px 9px 4px 4px",715 borderRadius: 999,716 background: "rgba(26,24,23,0.82)",717 border: "1px solid rgba(255,255,255,0.07)",718 opacity: t,719 transform: `translateY(${(1 - t) * 6}px)`,720 }}721 >722 <div723 style={{724 width: 18,725 height: 18,726 borderRadius: 999,727 background: "rgba(255,255,255,0.08)",728 display: "flex",729 alignItems: "center",730 justifyContent: "center",731 }}732 >733 <PillIcon kind={p.icon} color={p.tint} />734 </div>735 <div736 style={{737 display: "flex",738 flexDirection: "column",739 lineHeight: 1.15,740 }}741 >742 <span743 style={{744 fontSize: 8.5,745 fontWeight: 700,746 letterSpacing: "0.04em",747 color: "#F4F1EC",748 }}749 >750 {p.title}751 </span>752 <span style={{ fontSize: 8, color: "rgba(232,227,220,0.6)" }}>753 {p.sub}754 </span>755 </div>756 </div>757 );758 })}759760 {/* Status bar (split around the dynamic island) */}761 <div762 style={{763 position: "absolute",764 top: 14,765 left: 18,766 right: 16,767 display: "flex",768 justifyContent: "space-between",769 alignItems: "center",770 }}771 >772 <div style={{ display: "flex", alignItems: "center", gap: 5 }}>773 <span style={{ fontSize: 13, fontWeight: 700 }}>9:41</span>774 <svg775 aria-hidden776 width={12}777 height={12}778 viewBox="0 0 24 24"779 fill="none"780 stroke="#fff"781 strokeWidth={2}782 strokeLinecap="round"783 >784 <title>alerts off</title>785 <path d="M6 8a6 6 0 0 1 9-5" />786 <path d="M18 8v5l2 3H8" />787 <path d="M10.5 19a2 2 0 0 0 3 0" />788 <path d="M3 3l18 18" />789 </svg>790 </div>791 <StatusIcons />792 </div>793794 {/* Nav row */}795 <div796 style={{797 position: "absolute",798 top: 40,799 left: 18,800 right: 16,801 display: "flex",802 justifyContent: "space-between",803 alignItems: "center",804 }}805 >806 <span style={{ fontSize: 10, color: "rgba(255,255,255,0.5)" }}>807 System voice808 </span>809 <span style={{ fontSize: 11, fontWeight: 600, color: "#fff" }}>810 Save811 </span>812 </div>813814 {/* Athlete selector */}815 <div816 style={{817 position: "absolute",818 top: 60,819 right: 16,820 display: "flex",821 alignItems: "center",822 gap: 3,823 fontSize: 12,824 fontWeight: 600,825 }}826 >827 Eddy828 <svg829 aria-hidden830 width={9}831 height={9}832 viewBox="0 0 24 24"833 fill="none"834 stroke="#fff"835 strokeWidth={3}836 strokeLinecap="round"837 strokeLinejoin="round"838 >839 <title>expand</title>840 <path d="M6 9l6 6 6-6" />841 </svg>842 </div>843844 {/* Stats row + reset */}845 <div846 style={{847 position: "absolute",848 top: 86,849 left: 18,850 right: 16,851 display: "flex",852 alignItems: "flex-start",853 justifyContent: "space-between",854 }}855 >856 <div style={{ display: "flex", gap: 14 }}>857 <Stat value="16.5" unit="mph" label="AVG" />858 <Stat value="147" unit="bpm" label="AVG HR •" accent />859 <Stat value="26.0" unit="mph" label="MAX" />860 <Stat value="606" unit="ft" label="ASCENT" />861 </div>862 <div863 style={{864 width: 26,865 height: 26,866 borderRadius: 999,867 background: "rgba(255,255,255,0.1)",868 display: "flex",869 alignItems: "center",870 justifyContent: "center",871 }}872 >873 <svg874 aria-hidden875 width={13}876 height={13}877 viewBox="0 0 24 24"878 fill="none"879 stroke="#fff"880 strokeWidth={2}881 strokeLinecap="round"882 strokeLinejoin="round"883 >884 <title>reset</title>885 <path d="M3 12a9 9 0 1 0 3-6.7L3 8" />886 <path d="M3 3v5h5" />887 </svg>888 </div>889 </div>890891 {/* Scrub hint */}892 <div893 style={{894 position: "absolute",895 bottom: 54,896 left: 0,897 right: 0,898 textAlign: "center",899 fontSize: 9,900 color: "rgba(255,255,255,0.34)",901 opacity: hint,902 }}903 >904 Scrub along the bottom · Drag to explore905 </div>906 </div>907 );908}909910const isVideo = (src: string) => /\.(mp4|webm|mov|m4v)(\?|$)/i.test(src);911912/**913 * A root-relative asset (`/showcase-mobile-videos/x.mp4`) is served at the914 * origin root by Next in the Player, but Remotion Studio and a render serve `public/` through915 * `staticFile()` alone — so rewrite local paths everywhere but the Player, and916 * pass http(s)/data/blob URLs straight through.917 */918function resolveSrc(src: string): string {919 const isLocal = src.startsWith("/") && !src.startsWith("//");920 if (!isLocal || getRemotionEnvironment().isPlayer) return src;921 // A value that already came out of staticFile() carries the static base922 // (`/static-<hash>/…`); running it through again would prefix it twice.923 const base = staticFile("_").slice(0, -2);924 if (base && src.startsWith(`${base}/`)) return src;925 try {926 return staticFile(src.replace(/^\/+/, ""));927 } catch {928 return src;929 }930}931932/** Fills the screen with an image or a video, fading and un-blurring it in. */933function ScreenMedia({ src, frame }: { src: string; frame: number }) {934 const t = interpolate(frame, [4, 22], [0, 1], CLAMP);935 const style: CSSProperties = {936 position: "absolute",937 inset: 0,938 width: "100%",939 height: "100%",940 // Tailwind's preflight sets `img { max-width: 100% }`, which can collapse a941 // media element we size ourselves to 0px wide. Opt out. (motion-quality skill.)942 maxWidth: "none",943 objectFit: "cover",944 opacity: t,945 filter: `blur(${(1 - t) * 8}px)`,946 };947 const resolved = resolveSrc(src);948 return isVideo(src) ? (949 <OffthreadVideo src={resolved} muted style={style} />950 ) : (951 <Img src={resolved} style={style} />952 );953}954955export function PhoneFrame({956 children,957 screenSrc,958 variant = "flat",959 entrance = "rise",960 bezelColor,961 screenColor,962 theme,963 mode,964 fontFamily,965 radius,966 screenRadius,967 shadow,968 scale = 1,969 showDynamicIsland = true,970 floatLoop = true,971 floatAmplitude = 6,972 tiltAngle = -12,973 speed = 1,974 className,975}: PhoneFrameProps) {976 const frame = useCurrentFrame() * speed;977 const { fps, durationInFrames } = useVideoConfig();978 // The screen carries the app, so it follows the app theme. The body and the979 // Dynamic Island are a physical object: they take the dark end of the system980 // whatever mode the screen is in.981 const t = useKuchiTheme(theme, mode);982 const face = resolveFont(fontFamily ?? t.fontFamily) ?? FONT_FAMILY;983 const island = useKuchiTheme(theme, "dark");984 const body = bezelColor ?? t.foreground;985 const glass = screenColor ?? t.card;986 const drop = shadow ?? `0 24px 60px ${withAlpha(t.foreground, 0.18)}`;987988 const bodyRadius = radius ?? deviceRadius(DEVICE_WIDTH);989 const innerRadius = screenRadius ?? screenRadiusFor(bodyRadius);990991 const pose = entrancePose(frame, entrance);992 const floatStart = entrance === "float" ? 0 : ENTRANCE_FRAMES;993 const bob = floatLoop994 ? floatOffset(frame, fps, floatAmplitude, floatStart)995 : 0;996997 const crane =998 variant === "showcase" ? showcasePose(frame, durationInFrames) : null;9991000 return (1001 <div1002 className={className}1003 style={{1004 position: "absolute",1005 inset: 0,1006 display: "flex",1007 alignItems: "center",1008 justifyContent: "center",1009 fontFamily: face,1010 }}1011 >1012 {/* Entrance + float rig */}1013 <div1014 style={{1015 opacity: pose.opacity,1016 translate: `0px ${pose.translateY + bob}px`,1017 rotate: `${pose.rotateDeg}deg`,1018 scale: `${pose.scale * scale}`,1019 }}1020 >1021 {/* Camera: pan + zoom in screen space, outside the perspective (showcase only) */}1022 <div1023 style={{1024 transform: crane1025 ? `translate(${crane.x}px, ${crane.y}px) scale(${crane.zoom})`1026 : undefined,1027 }}1028 >1029 {/* Device orientation: crane pose (showcase), static rotateY (tilt), or flat */}1030 <div1031 style={{1032 transform: `perspective(1400px) rotateX(${1033 crane ? crane.rotateX : 01034 }deg) rotateY(${1035 crane ? crane.rotateY : variant === "tilt" ? tiltAngle : 01036 }deg) rotateZ(${crane ? crane.rotateZ : 0}deg)`,1037 }}1038 >1039 {/* Device body */}1040 <div1041 style={{1042 position: "relative",1043 width: DEVICE_WIDTH,1044 height: DEVICE_HEIGHT,1045 borderRadius: bodyRadius,1046 backgroundColor: body,1047 padding: BEZEL_WIDTH,1048 ...(shadow === "" ? {} : { boxShadow: drop }),1049 }}1050 >1051 {/* Side buttons */}1052 {SIDE_BUTTONS.map((button) => (1053 <div1054 key={`${button.side}-${button.top}`}1055 style={{1056 position: "absolute",1057 top: button.top,1058 [button.side]: -3,1059 width: 3,1060 height: button.length,1061 borderRadius: 2,1062 backgroundColor: body,1063 }}1064 />1065 ))}10661067 {/* Screen */}1068 <div1069 style={{1070 position: "relative",1071 width: "100%",1072 height: "100%",1073 borderRadius: innerRadius,1074 backgroundColor: glass,1075 overflow: "hidden",1076 }}1077 >1078 {children ??1079 (screenSrc ? (1080 <ScreenMedia src={screenSrc} frame={frame} />1081 ) : (1082 <RideSummaryDemo frame={frame} face={face} />1083 ))}10841085 {/* Dynamic island */}1086 {showDynamicIsland && (1087 <div1088 style={{1089 position: "absolute",1090 top: 10,1091 left: "50%",1092 translate: "-50% 0px",1093 width: 90,1094 height: 26,1095 borderRadius: 999,1096 backgroundColor: island.background,1097 zIndex: 10,1098 display: "flex",1099 alignItems: "center",1100 justifyContent: "flex-end",1101 paddingRight: 9,1102 }}1103 >1104 {/* Camera lens */}1105 <div1106 style={{1107 width: 9,1108 height: 9,1109 borderRadius: 999,1110 backgroundColor: island.card,1111 border: `1px solid ${island.border}`,1112 }}1113 />1114 </div>1115 )}1116 </div>1117 </div>1118 </div>1119 </div>1120 </div>1121 </div>1122 );1123}









