Phone Scroll
A phone app screen flicks through stops while a headline sits beside it.
Source
components/kuchi/phone-scroll.tsx
1"use client";23import { loadFont } from "@remotion/google-fonts/Figtree";4import { loadFont as loadSerif } from "@remotion/google-fonts/InstrumentSerif";5import type React from "react";6import { useId } from "react";7import {8 AbsoluteFill,9 Easing,10 Img,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 figtree = loadFont("normal", {21 weights: ["300", "400"],22 subsets: ["latin"],23});24const { fontFamily: serifFamily } = loadSerif("italic", {25 weights: ["400"],26 subsets: ["latin"],27});2829export interface PhoneScrollProps {30 /** Tall screenshot, rendered 393pt wide and scrolled. */31 src?: string;32 /** Scroll offsets (screen points) to flick to, one flick per stop. */33 stops?: number[];34 /** Headline that slides in beside the phone. Pass "" to hide. */35 label?: string;36 /** Part of `label` set in the italic serif. */37 labelAccent?: string;38 eyebrow?: string;39 /** Custom screen content (393pt wide), scrolled like the screenshot. */40 children?: React.ReactNode;41 /** Search field text in the built-in feed's header. */42 searchLabel?: string;43 /** Frames from one flick to the next when there are several stops. */44 flickGap?: number;45 /** Blur the screen along the scroll while it moves fast. */46 motionBlur?: boolean;47 accent?: string;48 /** Text color of the headline; overrides the theme ink. */49 ink?: string;50 /** Solid fill in place of the gradient ground; "transparent" drops it. */51 background?: string;52 /** Typeface for the copy. Load it yourself; Figtree by default. */53 fontFamily?: string;54 /** Size of the phone and headline, 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?: "light" | "dark";60 ground?: GshPresetId;61 groundParams?: Partial<GradientParams>;62}6364const SW = 393;65const SH = 852;66const BEZEL = 11;67const BW = SW + BEZEL * 2;68const BH = SH + BEZEL * 2;69const HEADER_H = 196;7071const FLICK_START = 40;72const PRESS = 5;73const DRAG = 6;74const TAU = 10;75const SEG = 46;7677const clamp = { extrapolateLeft: "clamp", extrapolateRight: "clamp" } as const;78const ENTER = Easing.bezier(0.32, 0.72, 0, 1);79const LIGHT = Easing.bezier(0.22, 1, 0.36, 1);80const HEAVY = { mass: 1, damping: 26, stiffness: 120 };81const CARD = { mass: 0.8, damping: 18, stiffness: 160 };8283function scrollAt(f: number, stops: number[], fps: number, seg = SEG): number {84 let base = 0;85 for (let i = 0; i < stops.length; i++) {86 const local = f - (FLICK_START + i * seg) - PRESS;87 if (local <= 0) return base;88 const dist = stops[i] - base;89 const over = Math.sign(dist) * Math.min(26, Math.abs(dist) * 0.035);90 const v0 = (dist + over) / (TAU + DRAG / 2);91 const d0 = (v0 * DRAG) / 2;92 let y: number;93 if (local < DRAG) {94 y = base + d0 * (local / DRAG) ** 2;95 } else {96 const t = local - DRAG;97 const momentum =98 base + d0 + (dist + over - d0) * (1 - Math.exp(-t / TAU));99 const back = spring({100 frame: Math.max(0, t - TAU * 1.9),101 fps,102 config: CARD,103 });104 y = momentum - over * back;105 }106 if (i === stops.length - 1 || local < seg - PRESS) return y;107 base = stops[i];108 }109 return base;110}111112type Scene = "coast" | "alpine" | "desert" | "lake" | "aurora";113type Look = {114 sky: [string, string, string];115 sun: string;116 haze: string;117 far: string;118 mid: string;119 near: string;120 fg: "trees" | "dunes" | "cliff";121 sunY: number;122 water?: string;123 snow?: boolean;124 lights?: boolean;125};126const SCENES: Record<Scene, Look> = {127 coast: {128 sky: ["#5F82B6", "#E2AE90", "#FBD6A8"],129 sun: "#FFF1D6",130 haze: "#F4C9A2",131 far: "#9C7A8C",132 mid: "#5A465A",133 near: "#1E1820",134 fg: "cliff",135 sunY: 0.5,136 water: "#46607F",137 },138 alpine: {139 sky: ["#2F66AE", "#86B1E0", "#DAE7F3"],140 sun: "#FFFFFF",141 haze: "#D3E1EF",142 far: "#8DA4C2",143 mid: "#465D7B",144 near: "#111C26",145 fg: "trees",146 sunY: 0.06,147 snow: true,148 lights: true,149 },150 desert: {151 sky: ["#4F7DB2", "#E3B489", "#F5D4A2"],152 sun: "#FFF2D8",153 haze: "#EFC38D",154 far: "#D29E70",155 mid: "#B26A40",156 near: "#6A3720",157 fg: "dunes",158 sunY: 0.45,159 },160 lake: {161 sky: ["#527FA6", "#B2CDD2", "#ECEFE4"],162 sun: "#FFFBEA",163 haze: "#DBE5DE",164 far: "#7B9995",165 mid: "#3A5A51",166 near: "#0F1E1A",167 fg: "trees",168 sunY: 0.28,169 water: "#557F88",170 lights: true,171 },172 aurora: {173 sky: ["#040914", "#0D1F3A", "#223F63"],174 sun: "#E8F7FF",175 haze: "#2A4A6C",176 far: "#28405F",177 mid: "#132238",178 near: "#050A13",179 fg: "trees",180 sunY: -1,181 lights: true,182 },183};184185function hash(n: number) {186 const s = Math.sin(n * 127.1 + 311.7) * 43758.5453;187 return s - Math.floor(s);188}189190function ridge(191 seed: number,192 base: number,193 amp: number,194 sharp: boolean,195 w: number,196 h: number,197) {198 const pts: string[] = [];199 for (let x = -8; x <= w + 8; x += 3) {200 let v = 0;201 for (let o = 0, a = 1, fq = 0.011; o < 5; o++, a *= 0.47, fq *= 2.2) {202 const sn = Math.sin(x * fq + seed * (3.1 + o * 1.7));203 v += (sharp && o < 2 ? 1 - Math.abs(sn) * 1.7 : sn) * a;204 }205 pts.push(`${x},${(base - v * amp).toFixed(1)}`);206 }207 return `M-8,${h} L${pts.join(" L")} L${w + 8},${h} Z`;208}209210function treeline(211 seed: number,212 base: number,213 tall: number,214 w: number,215 h: number,216) {217 let d = `M-8,${h} L-8,${base} L${w + 8},${base} L${w + 8},${h} Z`;218 for (let x = -6, i = 0; x < w + 8; i++) {219 const edge = Math.abs(x / w - 0.5) * 2;220 const ht = tall * (0.12 + edge ** 1.5 * 0.7 + hash(seed + i * 1.37) * 0.3);221 const tw = ht * (0.26 + hash(seed + i * 2.11) * 0.12);222 for (let k = 0; k < 4; k++) {223 const yb = base - ht * (0.06 + k * 0.19);224 const wk = tw * (1 - k * 0.22);225 d += ` M${(x - wk / 2).toFixed(1)},${yb.toFixed(1)} L${x.toFixed(1)},${(yb - ht * 0.5).toFixed(1)} L${(x + wk / 2).toFixed(1)},${yb.toFixed(1)} Z`;226 }227 x += 2 + hash(seed + i * 3.7) * tw * 0.8;228 }229 return d;230}231232function headland(seed: number, w: number, h: number) {233 const pts: string[] = [];234 for (let x = -8; x <= w * 0.55; x += 3) {235 const t = Math.max(0, x) / (w * 0.55);236 const n =237 Math.sin(x * 0.09 + seed) * 0.5 + Math.sin(x * 0.23 + seed * 2.3) * 0.3;238 pts.push(239 `${x},${(h * 0.66 + t ** 1.8 * h * 0.36 + n * h * 0.02).toFixed(1)}`,240 );241 }242 return `M-8,${h} L${pts.join(" L")} L${w * 0.55},${h} Z`;243}244245function Scenery({246 scene,247 seed,248 w,249 h,250}: {251 scene: Scene;252 seed: number;253 w: number;254 h: number;255}) {256 const id = useId().replace(/[^a-zA-Z0-9_-]/g, "");257 const p = SCENES[scene];258 const night = p.sunY < 0;259 const hz = h * (p.water ? 0.6 : 0.66);260 const sunX = w * (0.28 + hash(seed) * 0.44);261 const sunY = h * p.sunY;262 const ns = Math.round(seed * 10);263 const u = (k: string) => `url(#${id}${k})`;264 const lit = (265 k: string,266 c: string,267 top: number,268 bottom: number,269 snow = false,270 ) => (271 <linearGradient272 id={`${id}${k}`}273 gradientUnits="userSpaceOnUse"274 x1="0"275 y1={top}276 x2="0"277 y2={bottom}278 >279 {snow ? (280 <stop offset="0" stopColor="#F4F7FB" />281 ) : (282 <stop283 offset="0"284 stopColor={`color-mix(in srgb, ${c} 70%, ${p.haze})`}285 />286 )}287 {snow ? <stop offset="0.3" stopColor="#D9E2EC" /> : null}288 <stop offset={snow ? "0.42" : "0.55"} stopColor={c} />289 <stop offset="1" stopColor={`color-mix(in srgb, ${c} 80%, #000)`} />290 </linearGradient>291 );292 const peaks = scene === "alpine" || scene === "aurora";293 const farD = ridge(294 seed + 9,295 hz - 26,296 h * (scene === "alpine" ? 0.2 : peaks ? 0.13 : 0.07),297 peaks,298 w,299 h,300 );301 const midD = ridge(302 seed,303 hz - 2,304 h * (scene === "alpine" ? 0.16 : peaks ? 0.1 : 0.06),305 peaks,306 w,307 h,308 );309 const scenery = (310 <>311 <path d={farD} fill={u("lf")} filter={u("t")} opacity={0.92} />312 <rect y={hz - 60} width={w} height={70} fill={u("hz")} />313 <path d={midD} fill={u("lm")} filter={u("t")} />314 <rect y={hz - 18} width={w} height={34} fill={u("hz")} opacity={0.6} />315 </>316 );317 return (318 <svg319 width={w}320 height={h}321 viewBox={`0 0 ${w} ${h}`}322 style={{ display: "block" }}323 >324 <defs>325 <linearGradient id={`${id}s`} x1="0" y1="0" x2="0" y2="1">326 <stop offset="0" stopColor={p.sky[0]} />327 <stop offset="0.45" stopColor={p.sky[1]} />328 <stop offset={p.water ? "0.6" : "0.66"} stopColor={p.sky[2]} />329 </linearGradient>330 <radialGradient id={`${id}b`}>331 <stop offset="0" stopColor={p.sun} stopOpacity="0.9" />332 <stop offset="0.12" stopColor={p.sun} stopOpacity="0.5" />333 <stop offset="0.45" stopColor={p.haze} stopOpacity="0.18" />334 <stop offset="1" stopColor={p.haze} stopOpacity="0" />335 </radialGradient>336 <linearGradient id={`${id}hz`} x1="0" y1="0" x2="0" y2="1">337 <stop offset="0" stopColor={p.haze} stopOpacity="0" />338 <stop339 offset="0.65"340 stopColor={p.haze}341 stopOpacity={night ? 0.25 : 0.6}342 />343 <stop offset="1" stopColor={p.haze} stopOpacity="0" />344 </linearGradient>345 {lit("lf", p.far, hz - 26 - h * 0.15, hz + 10, p.snow)}346 {lit("lm", p.mid, hz - 2 - h * 0.17, hz + 40, p.snow)}347 <linearGradient id={`${id}fg`} x1="0" y1="0" x2="1" y2="0">348 <stop349 offset="0"350 stopColor={351 scene === "desert"352 ? `color-mix(in srgb, ${p.near} 55%, ${p.haze})`353 : p.near354 }355 />356 <stop offset="1" stopColor={p.near} />357 </linearGradient>358 <radialGradient id={`${id}v`} cx="0.5" cy="0.45" r="0.75">359 <stop offset="0.55" stopColor="#000" stopOpacity="0" />360 <stop offset="1" stopColor="#000" stopOpacity="0.38" />361 </radialGradient>362 <filter id={`${id}t`} x="-2%" y="-6%" width="104%" height="112%">363 <feTurbulence364 type="fractalNoise"365 baseFrequency="0.035 0.1"366 numOctaves="4"367 seed={ns}368 result="n"369 />370 <feDisplacementMap371 in="SourceGraphic"372 in2="n"373 scale="6"374 xChannelSelector="R"375 yChannelSelector="G"376 result="d"377 />378 <feColorMatrix379 in="n"380 type="matrix"381 values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1.5 0.85"382 result="s"383 />384 <feComposite in="s" in2="d" operator="in" result="sd" />385 <feComposite in="sd" in2="d" operator="over" />386 </filter>387 <filter id={`${id}r`} x="0" y="0" width="100%" height="100%">388 <feTurbulence389 type="fractalNoise"390 baseFrequency="0.006 0.12"391 numOctaves="2"392 seed={ns + 3}393 result="n"394 />395 <feDisplacementMap396 in="SourceGraphic"397 in2="n"398 scale="10"399 xChannelSelector="R"400 yChannelSelector="G"401 />402 <feGaussianBlur stdDeviation="0.6" />403 </filter>404 <filter id={`${id}g`} x="0" y="0" width="100%" height="100%">405 <feTurbulence406 type="fractalNoise"407 baseFrequency="0.9"408 numOctaves="2"409 seed={ns + 7}410 />411 <feColorMatrix type="saturate" values="0" />412 </filter>413 <filter id={`${id}f`}>414 <feGaussianBlur stdDeviation="0.8" />415 </filter>416 <filter id={`${id}glow`} x="-50%" y="-50%" width="200%" height="200%">417 <feGaussianBlur stdDeviation="2.4" />418 </filter>419 <linearGradient id={`${id}wd`} x1="0" y1="0" x2="0" y2="1">420 <stop offset="0" stopColor={p.water} stopOpacity="0.1" />421 <stop422 offset="1"423 stopColor={`color-mix(in srgb, ${p.water} 60%, #000)`}424 stopOpacity="0.75"425 />426 </linearGradient>427 <clipPath id={`${id}wc`}>428 <rect y={hz} width={w} height={h - hz} />429 </clipPath>430 </defs>431 <rect width={w} height={h} fill={u("s")} />432 {night433 ? Array.from({ length: 70 }, (_, i) => (434 <circle435 key={i}436 cx={hash(seed + i * 1.3) * w}437 cy={hash(seed + i * 2.9) * hz * 0.85}438 r={0.35 + hash(seed + i * 5.1) * 0.75}439 fill="#fff"440 opacity={0.35 + hash(seed + i * 7.3) * 0.6}441 />442 ))443 : null}444 {night ? (445 <g style={{ filter: "blur(10px)" }} opacity={0.75}>446 <path447 d={`M-30,${h * 0.36} C${w * 0.25},${h * 0.12} ${w * 0.55},${h * 0.46} ${w + 30},${h * 0.2}`}448 stroke="#4FF0B0"449 strokeWidth={26}450 fill="none"451 opacity={0.7}452 />453 <path454 d={`M-30,${h * 0.28} C${w * 0.3},${h * 0.06} ${w * 0.6},${h * 0.36} ${w + 30},${h * 0.1}`}455 stroke="#3BC8B8"456 strokeWidth={46}457 fill="none"458 opacity={0.35}459 />460 <path461 d={`M${w * 0.2},${h * 0.1} C${w * 0.45},${h * 0.02} ${w * 0.7},${h * 0.2} ${w + 30},${h * 0.04}`}462 stroke="#B07CF0"463 strokeWidth={30}464 fill="none"465 opacity={0.25}466 />467 </g>468 ) : (469 <>470 <circle471 cx={sunX}472 cy={sunY}473 r={h * (0.2 + p.sunY * 0.7)}474 fill={u("b")}475 />476 <circle477 cx={sunX}478 cy={sunY}479 r={h * 0.032}480 fill={p.sun}481 style={{ filter: "blur(1.2px)" }}482 />483 </>484 )}485 {scenery}486 {p.water ? (487 <g clipPath={u("wc")}>488 <rect y={hz} width={w} height={h - hz} fill={p.water} />489 <g490 transform={`translate(0 ${2 * hz}) scale(1 -1)`}491 opacity={0.85}492 filter={u("r")}493 >494 <rect width={w} height={hz} fill={u("s")} />495 {night ? null : (496 <circle cx={sunX} cy={sunY} r={h * 0.3} fill={u("b")} />497 )}498 {scenery}499 </g>500 <rect y={hz} width={w} height={h - hz} fill={u("wd")} />501 {night502 ? null503 : Array.from({ length: 14 }, (_, i) => (504 <rect505 key={i}506 x={sunX - (6 + i * 1.6) * hash(seed + i * 4.1) - 4}507 y={hz + 3 + i * i * 0.55}508 width={(8 + i * 2.2) * (0.5 + hash(seed + i * 6.7))}509 height={1 + i * 0.08}510 rx={0.6}511 fill={p.sun}512 opacity={0.75 - i * 0.045}513 />514 ))}515 </g>516 ) : null}517 <g filter={u("f")}>518 {p.fg === "trees" ? (519 <path520 d={treeline(seed + 4, h * 0.97, h * 0.3, w, h)}521 fill={p.near}522 filter={u("t")}523 />524 ) : p.fg === "dunes" ? (525 <path526 d={ridge(seed + 5, h * 0.9, h * 0.07, false, w, h)}527 fill={u("fg")}528 filter={u("t")}529 />530 ) : (531 <path d={headland(seed + 5, w, h)} fill={p.near} filter={u("t")} />532 )}533 </g>534 {p.lights535 ? [0, 1, 2].map((i) => {536 const lx = w * (0.58 + hash(seed + 11) * 0.2) + i * 6;537 const ly = h * 0.9 - (i % 2) * 3;538 return (539 <g key={i}>540 <rect541 x={lx - 3}542 y={ly - 3}543 width={8}544 height={7}545 fill="#FFB35C"546 opacity={0.7}547 filter={u("glow")}548 />549 <rect x={lx} y={ly} width={2.2} height={2.6} fill="#FFD9A0" />550 </g>551 );552 })553 : null}554 <rect width={w} height={h} fill={u("v")} />555 <rect556 width={w}557 height={h}558 filter={u("g")}559 opacity={0.22}560 style={{ mixBlendMode: "overlay" }}561 />562 </svg>563 );564}565566const LISTINGS: {567 title: string;568 meta: string;569 dates: string;570 price: number;571 rating: string;572 scene: Scene;573}[] = [574 {575 title: "Halcyon Cove, Portugal",576 meta: "Ocean views · 2 beds",577 dates: "Nov 12 – 17",578 price: 218,579 rating: "4.96",580 scene: "coast",581 },582 {583 title: "Fernway Lodge, Norway",584 meta: "Mountain views · 3 beds",585 dates: "Dec 2 – 7",586 price: 304,587 rating: "4.92",588 scene: "alpine",589 },590 {591 title: "Quarry House, Morocco",592 meta: "Desert stay · 1 bed",593 dates: "Jan 8 – 13",594 price: 142,595 rating: "4.88",596 scene: "desert",597 },598 {599 title: "Tessel Cabin, Canada",600 meta: "Lakefront · 2 beds",601 dates: "Nov 20 – 25",602 price: 189,603 rating: "4.97",604 scene: "lake",605 },606 {607 title: "Lumen Dome, Iceland",608 meta: "Northern lights · 1 bed",609 dates: "Feb 3 – 8",610 price: 276,611 rating: "4.99",612 scene: "aurora",613 },614];615616interface AppColors {617 bg: string;618 ink: string;619 muted: string;620 hair: string;621 pill: string;622 pillShadow: string;623 bar: string;624 dark: boolean;625}626627function appColors(dark: boolean): AppColors {628 return dark629 ? {630 bg: "#121214",631 ink: "#F2F2F3",632 muted: "#9C9CA3",633 hair: "rgba(255,255,255,0.1)",634 pill: "#1D1D20",635 pillShadow:636 "0 0 0 0.5px rgba(255,255,255,0.12), 0 4px 14px rgba(0,0,0,0.4)",637 bar: "rgba(18,18,20,0.96)",638 dark,639 }640 : {641 bg: "#FFFFFF",642 ink: "#222222",643 muted: "#6A6A6A",644 hair: "#EBEBEB",645 pill: "#FFFFFF",646 pillShadow: "0 0 0 0.5px rgba(0,0,0,0.08), 0 3px 12px rgba(0,0,0,0.1)",647 bar: "rgba(255,255,255,0.97)",648 dark,649 };650}651652function Icon({653 d,654 size = 24,655 color,656}: {657 d: string;658 size?: number;659 color: string;660}) {661 return (662 <svg663 width={size}664 height={size}665 viewBox="0 0 24 24"666 fill="none"667 stroke={color}668 strokeWidth={1.5}669 strokeLinecap="round"670 strokeLinejoin="round"671 >672 <path d={d} />673 </svg>674 );675}676677const ICONS = {678 search: "M11 18a7 7 0 1 0 0-14 7 7 0 0 0 0 14zM20 20l-4-4",679 heart: "M12 20s-7-4.4-7-10a4 4 0 0 1 7-2.6A4 4 0 0 1 19 10c0 5.6-7 10-7 10z",680 trips: "M4 8h16v11H4zM9 8V5h6v3",681 inbox: "M4 5h16v11H9l-5 4z",682 user: "M12 12a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM4 21c1-4 4.5-6 8-6s7 2 8 6",683 filter: "M4 7h10M18 7h2M4 17h4M12 17h8M16 5v4M10 15v4",684 cabin: "M3 20h18M5 20V11l7-6 7 6v9M10 20v-5h4v5",685 wave: "M3 15c2-2 4-2 6 0s4 2 6 0 4-2 6 0M3 10c2-2 4-2 6 0s4 2 6 0 4-2 6 0",686 peak: "M3 20l6-11 4 6 2-3 6 8z",687 sun: "M12 16a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM12 2v2M12 20v2M2 12h2M20 12h2M5 5l1.5 1.5M17.5 17.5L19 19M5 19l1.5-1.5M17.5 6.5L19 5",688 lake: "M3 17c3 2 15 2 18 0M6 13l3-5 3 5M12 13l3-6 3 6",689 tag: "M3.5 12.5V4.5h8l9 9-8 8zM8 8.5h.01",690};691692function StatusBar({ color }: { color: string }) {693 return (694 <div695 style={{696 height: 54,697 display: "flex",698 alignItems: "center",699 justifyContent: "space-between",700 padding: "6px 34px 0 50px",701 }}702 >703 <span704 style={{705 fontSize: 17,706 fontWeight: 400,707 color,708 letterSpacing: -0.2,709 fontVariantNumeric: "tabular-nums",710 }}711 >712 9:41713 </span>714 <div style={{ display: "flex", gap: 6, alignItems: "center" }}>715 <svg width="18" height="12" viewBox="0 0 18 12">716 {[0, 1, 2, 3].map((i) => (717 <rect718 key={i}719 x={i * 4.6}720 y={9 - i * 3}721 width={3.2}722 height={3 + i * 3}723 rx={0.8}724 fill={color}725 />726 ))}727 </svg>728 <div729 style={{730 width: 25,731 height: 12,732 borderRadius: 3.5,733 boxShadow: `inset 0 0 0 1px ${color}`,734 padding: 1.5,735 boxSizing: "border-box",736 opacity: 0.9,737 }}738 >739 <div740 style={{741 width: "78%",742 height: "100%",743 borderRadius: 2,744 background: color,745 }}746 />747 </div>748 </div>749 </div>750 );751}752753function ListingCard({754 l,755 i,756 c,757}: {758 l: (typeof LISTINGS)[number];759 i: number;760 c: AppColors;761}) {762 return (763 <div style={{ marginBottom: 30 }}>764 <div765 style={{766 position: "relative",767 borderRadius: 14,768 overflow: "hidden",769 height: 322,770 outline: `1px solid ${c.dark ? "rgba(255,255,255,0.1)" : "rgba(0,0,0,0.1)"}`,771 outlineOffset: -1,772 }}773 >774 <Scenery scene={l.scene} seed={i * 1.7 + 0.4} w={345} h={322} />775 {i === 0 ? (776 <div777 style={{778 position: "absolute",779 top: 14,780 left: 14,781 background: "rgba(255,255,255,0.95)",782 borderRadius: 999,783 padding: "6px 11px",784 fontSize: 13,785 fontWeight: 400,786 color: "#222",787 }}788 >789 Guest favourite790 </div>791 ) : null}792 <div style={{ position: "absolute", top: 14, right: 14 }}>793 <svg width="26" height="26" viewBox="0 0 24 24">794 <path795 d={ICONS.heart}796 fill="rgba(0,0,0,0.3)"797 stroke="#fff"798 strokeWidth={1.5}799 />800 </svg>801 </div>802 <div803 style={{804 position: "absolute",805 bottom: 12,806 left: 0,807 right: 0,808 display: "flex",809 justifyContent: "center",810 gap: 5,811 }}812 >813 {[0, 1, 2, 3, 4].map((d) => (814 <div815 key={d}816 style={{817 width: 6,818 height: 6,819 borderRadius: 3,820 background: "#fff",821 opacity: d === 0 ? 1 : 0.55,822 }}823 />824 ))}825 </div>826 </div>827 <div828 style={{829 display: "flex",830 justifyContent: "space-between",831 marginTop: 12,832 fontSize: 15.5,833 color: c.ink,834 }}835 >836 <span style={{ fontWeight: 400 }}>{l.title}</span>837 <span838 style={{839 display: "flex",840 alignItems: "center",841 gap: 4,842 fontVariantNumeric: "tabular-nums",843 }}844 >845 <svg width="12" height="12" viewBox="0 0 24 24" aria-hidden>846 <path847 d="M12 2.5l2.9 6.1 6.6.8-4.9 4.6 1.3 6.6L12 17.3l-5.9 3.3 1.3-6.6-4.9-4.6 6.6-.8z"848 fill={c.ink}849 />850 </svg>851 {l.rating}852 </span>853 </div>854 <div style={{ fontSize: 15, color: c.muted, marginTop: 2 }}>{l.meta}</div>855 <div style={{ fontSize: 15, color: c.muted, marginTop: 2 }}>856 {l.dates}857 </div>858 <div859 style={{860 fontSize: 15,861 color: c.muted,862 marginTop: 6,863 fontVariantNumeric: "tabular-nums",864 }}865 >866 <span style={{ color: c.ink, textDecoration: "underline" }}>867 ${l.price}868 </span>{" "}869 night870 </div>871 </div>872 );873}874875function FeesNotice({ c }: { c: AppColors }) {876 return (877 <div878 style={{879 marginBottom: 30,880 padding: "14px 0",881 borderTop: `1px solid ${c.hair}`,882 borderBottom: `1px solid ${c.hair}`,883 display: "flex",884 gap: 12,885 alignItems: "center",886 fontSize: 15,887 color: c.ink,888 }}889 >890 <Icon d={ICONS.tag} size={22} color={c.ink} />891 <span>892 Prices include all fees893 <span style={{ color: c.muted }}> · 1,240 stays this week</span>894 </span>895 </div>896 );897}898899function AppHeader({900 scrolled,901 c,902 searchLabel,903}: {904 scrolled: number;905 c: AppColors;906 searchLabel: string;907}) {908 const cats: [keyof typeof ICONS, string][] = [909 ["cabin", "Cabins"],910 ["wave", "Beachfront"],911 ["peak", "Peaks"],912 ["sun", "Desert"],913 ["lake", "Lakes"],914 ];915 return (916 <div917 style={{918 position: "absolute",919 top: 0,920 left: 0,921 right: 0,922 height: HEADER_H,923 background: c.bg,924 zIndex: 2,925 boxShadow: `0 1px 0 ${c.hair}, 0 6px 14px rgba(0,0,0,${scrolled * (c.dark ? 0.3 : 0.06)})`,926 }}927 >928 <StatusBar color={c.ink} />929 <div930 style={{931 margin: "8px 24px 0",932 height: 58,933 borderRadius: 29,934 background: c.pill,935 boxShadow: c.pillShadow,936 display: "flex",937 alignItems: "center",938 padding: "0 10px 0 20px",939 gap: 14,940 }}941 >942 <Icon d={ICONS.search} size={20} color={c.ink} />943 <div style={{ flex: 1 }}>944 <div style={{ fontSize: 15, fontWeight: 400, color: c.ink }}>945 {searchLabel}946 </div>947 <div style={{ fontSize: 12.5, color: c.muted, marginTop: 1 }}>948 Anywhere · Any week · Add guests949 </div>950 </div>951 <div952 style={{953 width: 38,954 height: 38,955 borderRadius: 19,956 boxShadow: `inset 0 0 0 1px ${c.hair}`,957 display: "flex",958 alignItems: "center",959 justifyContent: "center",960 }}961 >962 <Icon d={ICONS.filter} size={17} color={c.ink} />963 </div>964 </div>965 <div966 style={{967 display: "flex",968 justifyContent: "space-between",969 padding: "16px 26px 0",970 }}971 >972 {cats.map(([ic, name], i) => (973 <div974 key={name}975 style={{976 display: "flex",977 flexDirection: "column",978 alignItems: "center",979 gap: 5,980 opacity: i === 0 ? 1 : 0.6,981 paddingBottom: 9,982 borderBottom: `2px solid ${i === 0 ? c.ink : "transparent"}`,983 }}984 >985 <Icon d={ICONS[ic]} size={24} color={c.ink} />986 <span style={{ fontSize: 12, fontWeight: 400, color: c.ink }}>987 {name}988 </span>989 </div>990 ))}991 </div>992 </div>993 );994}995996function TabBar({ accent, c }: { accent: string; c: AppColors }) {997 const tabs: [keyof typeof ICONS, string][] = [998 ["search", "Explore"],999 ["heart", "Wishlists"],1000 ["trips", "Trips"],1001 ["inbox", "Inbox"],1002 ["user", "Profile"],1003 ];1004 return (1005 <div1006 style={{1007 position: "absolute",1008 bottom: 0,1009 left: 0,1010 right: 0,1011 height: 86,1012 background: c.bar,1013 borderTop: `1px solid ${c.hair}`,1014 zIndex: 2,1015 display: "flex",1016 justifyContent: "space-around",1017 paddingTop: 9,1018 }}1019 >1020 {tabs.map(([ic, name], i) => (1021 <div1022 key={name}1023 style={{1024 display: "flex",1025 flexDirection: "column",1026 alignItems: "center",1027 gap: 4,1028 width: 64,1029 }}1030 >1031 <Icon d={ICONS[ic]} size={24} color={i === 0 ? accent : c.muted} />1032 <span1033 style={{1034 fontSize: 11,1035 fontWeight: 400,1036 color: i === 0 ? c.ink : c.muted,1037 }}1038 >1039 {name}1040 </span>1041 </div>1042 ))}1043 </div>1044 );1045}10461047function BuiltInFeed({ c }: { c: AppColors }) {1048 return (1049 <div style={{ padding: `${HEADER_H + 22}px 24px 120px`, background: c.bg }}>1050 {LISTINGS.map((l, i) => (1051 <div key={l.title}>1052 <ListingCard l={l} i={i} c={c} />1053 {i === 1 ? <FeesNotice c={c} /> : null}1054 </div>1055 ))}1056 </div>1057 );1058}10591060function PhoneBody({1061 children,1062 c,1063}: {1064 children: React.ReactNode;1065 c: AppColors;1066}) {1067 const btn = (side: "left" | "right", top: number, h: number) => (1068 <div1069 style={{1070 position: "absolute",1071 [side]: -3,1072 top,1073 width: 4,1074 height: h,1075 borderRadius: 2,1076 background: c.dark ? "#2C2C30" : "#B8B8BE",1077 }}1078 />1079 );1080 return (1081 <div style={{ position: "relative", width: BW, height: BH }}>1082 {btn("left", 150, 32)}1083 {btn("left", 210, 62)}1084 {btn("left", 284, 62)}1085 {btn("right", 236, 98)}1086 <div1087 style={{1088 position: "absolute",1089 inset: 0,1090 borderRadius: 68,1091 background: c.dark ? "#0B0B0C" : "#E6E6EA",1092 boxShadow: c.dark1093 ? "inset 0 0 0 2px #3A3A3E, inset 0 0 0 3.5px #18181A"1094 : "inset 0 0 0 2px #C9C9CE, inset 0 0 0 3.5px #F6F6F8",1095 }}1096 />1097 <div1098 style={{1099 position: "absolute",1100 left: BEZEL,1101 top: BEZEL,1102 width: SW,1103 height: SH,1104 borderRadius: 56,1105 overflow: "hidden",1106 background: c.bg,1107 }}1108 >1109 {children}1110 <div1111 style={{1112 position: "absolute",1113 top: 11,1114 left: (SW - 126) / 2,1115 width: 126,1116 height: 37,1117 borderRadius: 19,1118 background: "#000",1119 zIndex: 5,1120 }}1121 />1122 <div1123 style={{1124 position: "absolute",1125 bottom: 8,1126 left: (SW - 136) / 2,1127 width: 136,1128 height: 5,1129 borderRadius: 3,1130 background: c.ink,1131 zIndex: 5,1132 }}1133 />1134 </div>1135 </div>1136 );1137}11381139/** The foreground at `scale`, around the frame's center; nothing extra at 1. */1140function ScaleLayer({1141 scale,1142 children,1143}: {1144 scale: number;1145 children: React.ReactNode;1146}) {1147 if (scale === 1) return children;1148 return (1149 <AbsoluteFill style={{ transform: `scale(${scale})` }}>1150 {children}1151 </AbsoluteFill>1152 );1153}11541155export function PhoneScroll({1156 src,1157 stops = [930],1158 label = "Find your next stay in two taps.",1159 labelAccent = "two taps.",1160 eyebrow = "acme for iOS",1161 children,1162 searchLabel = "Where to?",1163 flickGap = SEG,1164 motionBlur = true,1165 accent = "#3B5BFD",1166 ink,1167 background,1168 fontFamily = figtree.fontFamily,1169 scale = 1,1170 delay = 0,1171 speed = 1,1172 theme = "light",1173 ground,1174 groundParams,1175}: PhoneScrollProps) {1176 const frame = Math.max(0, useCurrentFrame() - delay);1177 const { fps, width, height } = useVideoConfig();1178 const f = frame * speed;1179 const blurId = `${useId().replace(/[^a-zA-Z0-9_-]/g, "")}mb`;1180 const dark = theme === "dark";1181 const c = appColors(dark);1182 const tall = height > width;11831184 const hasLabel = Boolean(label);1185 const k = tall ? (height * 0.6) / BH : (height * 0.9) / BH;1186 const phoneCx = tall || !hasLabel ? width / 2 : width * 0.33;1187 const phoneCy = tall && hasLabel ? height * 0.63 : height / 2;11881189 const rise = spring({ frame: f, fps, config: HEAVY });1190 const level = spring({ frame: f - 6, fps, config: HEAVY });1191 const ty = (1 - rise) * height * 0.95;1192 const rot = -8 * (1 - level);11931194 const y = scrollAt(f, stops, fps, flickGap);1195 const v = Math.abs(y - scrollAt(f - speed, stops, fps, flickGap));1196 const blur = Math.min(9, v * 0.09);11971198 const flick = Math.max(1199 0,1200 Math.min(stops.length - 1, Math.floor((f - FLICK_START + 4) / flickGap)),1201 );1202 const fl = f - (FLICK_START + flick * flickGap);1203 const prev = flick === 0 ? 0 : stops[flick - 1];1204 const dist = stops[flick] - prev;1205 const d0 =1206 (((dist + Math.sign(dist) * Math.min(26, Math.abs(dist) * 0.035)) /1207 (TAU + DRAG / 2)) *1208 DRAG) /1209 2;1210 const dragT = interpolate(fl, [PRESS, PRESS + DRAG], [0, 1], clamp);1211 const dotY = SH * 0.74 - d0 * 0.55 * dragT * dragT;1212 const dotIn = interpolate(fl, [0, 4], [0, 1], clamp);1213 const dotOut = interpolate(1214 fl,1215 [PRESS + DRAG, PRESS + DRAG + 6],1216 [1, 0],1217 clamp,1218 );1219 const press = spring({ frame: fl, fps, config: CARD });1220 const dotScale =1221 interpolate(press, [0, 1], [1.3, 0.96]) *1222 interpolate(fl, [PRESS + DRAG, PRESS + DRAG + 6], [1, 1.25], clamp);12231224 const typeIn = (d: number) =>1225 interpolate(f, [16 + d, 32 + d], [0, 1], { ...clamp, easing: ENTER });1226 const eyeIn = interpolate(f, [12, 26], [0, 1], { ...clamp, easing: LIGHT });1227 const push = interpolate(f, [0, 120], [1, 1.03], clamp);12281229 const content = children ? (1230 <div style={{ width: SW }}>{children}</div>1231 ) : src ? (1232 <Img src={src} style={{ width: SW, display: "block" }} />1233 ) : (1234 <BuiltInFeed c={c} />1235 );12361237 const split =1238 labelAccent && label.endsWith(labelAccent)1239 ? [label.slice(0, label.length - labelAccent.length), labelAccent]1240 : [label, ""];1241 const fg = ink ?? (dark ? "#F4F2EE" : "#16161A");1242 const sub = dark ? "rgba(244,242,238,0.58)" : "rgba(22,22,26,0.55)";1243 const headSize = tall ? width * 0.105 : height * 0.088;12441245 return (1246 <AbsoluteFill1247 style={{1248 fontFamily,1249 overflow: "hidden",1250 WebkitFontSmoothing: "antialiased",1251 }}1252 >1253 {background === undefined ? (1254 <>1255 <GshGround1256 preset={ground ?? (dark ? "hearth" : "paper-crease")}1257 params={groundParams}1258 timeOffset={dark ? 2 : 4}1259 timeScale={0.3}1260 />1261 <AbsoluteFill1262 style={{1263 background: dark ? "rgba(4,3,3,0.34)" : "rgba(246,244,240,0.28)",1264 }}1265 />1266 </>1267 ) : (1268 <AbsoluteFill1269 style={{1270 background: background === "transparent" ? undefined : background,1271 }}1272 />1273 )}1274 <svg width="0" height="0" style={{ position: "absolute" }}>1275 <filter id={blurId} x="0" y="-10%" width="100%" height="120%">1276 <feGaussianBlur stdDeviation={`0 ${blur.toFixed(2)}`} />1277 </filter>1278 </svg>1279 <ScaleLayer scale={scale}>1280 <AbsoluteFill1281 style={{ transform: `scale(${push})`, transformOrigin: "50% 50%" }}1282 >1283 <div1284 style={{1285 position: "absolute",1286 left: phoneCx - BW / 2,1287 top: phoneCy - BH / 2,1288 width: BW,1289 height: BH,1290 transform: `translateY(${ty}px) scale(${k}) rotate(${rot}deg)`,1291 transformOrigin: "50% 50%",1292 }}1293 >1294 <div1295 style={{1296 position: "absolute",1297 inset: 0,1298 borderRadius: 68,1299 boxShadow: dark1300 ? "0 2px 6px rgba(0,0,0,0.5), 0 30px 80px -20px rgba(0,0,0,0.7)"1301 : "0 2px 6px rgba(40,32,24,0.12), 0 30px 80px -20px rgba(40,32,24,0.3)",1302 }}1303 />1304 <PhoneBody c={c}>1305 <div1306 style={{1307 position: "absolute",1308 left: 0,1309 top: 0,1310 width: SW,1311 transform: `translateY(${-y}px)`,1312 filter:1313 motionBlur && blur > 0.4 ? `url(#${blurId})` : undefined,1314 }}1315 >1316 {content}1317 </div>1318 {!children && !src ? (1319 <>1320 <AppHeader1321 scrolled={interpolate(y, [0, 60], [0, 1], clamp)}1322 c={c}1323 searchLabel={searchLabel}1324 />1325 <TabBar accent={accent} c={c} />1326 </>1327 ) : null}1328 <div1329 style={{1330 position: "absolute",1331 left: SW * 0.56 - 21,1332 top: dotY - 21,1333 width: 42,1334 height: 42,1335 borderRadius: 21,1336 background: "rgba(30,30,36,0.22)",1337 boxShadow:1338 "inset 0 0 0 1.5px rgba(255,255,255,0.9), 0 2px 8px rgba(0,0,0,0.2)",1339 opacity: f >= FLICK_START ? dotIn * dotOut : 0,1340 transform: `scale(${dotScale})`,1341 zIndex: 6,1342 }}1343 />1344 </PhoneBody>1345 </div>1346 {hasLabel ? (1347 <div1348 style={{1349 position: "absolute",1350 ...(tall1351 ? {1352 left: width * 0.08,1353 right: width * 0.08,1354 top: height * 0.07,1355 textAlign: "center",1356 }1357 : {1358 left: width * 0.56,1359 width: width * 0.37,1360 top: 0,1361 bottom: 0,1362 }),1363 display: "flex",1364 flexDirection: "column",1365 justifyContent: "center",1366 }}1367 >1368 {eyebrow ? (1369 <div1370 style={{1371 fontSize: Math.max(height * 0.026, headSize * 0.26),1372 fontWeight: 400,1373 color: sub,1374 marginBottom: headSize * 0.32,1375 opacity: eyeIn,1376 transform: `translateY(${(1 - eyeIn) * 10}px)`,1377 }}1378 >1379 {eyebrow}1380 </div>1381 ) : null}1382 <div1383 style={{ overflow: "hidden", paddingBottom: headSize * 0.12 }}1384 >1385 <div1386 style={{1387 fontSize: headSize,1388 lineHeight: 1.04,1389 fontWeight: 300,1390 letterSpacing: "-0.035em",1391 color: fg,1392 textWrap: "balance",1393 transform: `translateY(${(1 - typeIn(0)) * 105}%)`,1394 }}1395 >1396 {split[0]}1397 {split[1] ? (1398 <span1399 style={{1400 fontFamily: serifFamily,1401 fontStyle: "italic",1402 fontWeight: 400,1403 letterSpacing: "-0.01em",1404 fontSize: headSize * 1.08,1405 display: "inline-block",1406 opacity: typeIn(6),1407 transform: `translateY(${(1 - typeIn(6)) * 30}%)`,1408 }}1409 >1410 {split[1]}1411 </span>1412 ) : null}1413 </div>1414 </div>1415 </div>1416 ) : null}1417 </AbsoluteFill>1418 </ScaleLayer>1419 </AbsoluteFill>1420 );1421}









