|
| 1 | +// DEV-ONLY visual rig for the Launcher ⇄ MeetingDetails page transition. |
| 2 | +// Not part of the shipped app — vite's build input is index.html only |
| 3 | +// (vite.config.mts), so this and launcherTransitionHarness.html exist for the |
| 4 | +// dev server alone. Same precedent as thinkingDotHarness.tsx. |
| 5 | +// |
| 6 | +// It renders the REAL variants (imported from the same module Launcher.tsx |
| 7 | +// imports, ./components/launcherPageTransition) against the real |
| 8 | +// layer structure (absolute inset-0, z-2 over z-1, overflow-hidden wrapper) so |
| 9 | +// what plays here is what plays in the app. The two pages are stand-ins with |
| 10 | +// list- and document-weight content — enough text at the real sizes to judge |
| 11 | +// whether the parallax reads and whether anything ghosts mid-travel. |
| 12 | +// |
| 13 | +// The speed control is the point of the rig: the skill is explicit that timing |
| 14 | +// faults are invisible at full speed. Watch it at 5x before believing it. |
| 15 | +import React, { useState } from 'react'; |
| 16 | +import { createRoot } from 'react-dom/client'; |
| 17 | +import { motion, AnimatePresence } from 'framer-motion'; |
| 18 | +import '../index.css'; |
| 19 | +import type { TargetAndTransition } from 'framer-motion'; |
| 20 | + |
| 21 | +// Mirrors Launcher.tsx:424-462 (PR #511). Copied rather than imported because |
| 22 | +// the app builds these inline inside the component, closed over the |
| 23 | +// useReducedMotion() result. Keep in sync by hand — if the numbers below stop |
| 24 | +// matching Launcher.tsx, this rig is lying to you. |
| 25 | +const NAV_EASE: [number, number, number, number] = [0.32, 0.72, 0, 1]; |
| 26 | + |
| 27 | +const detailsInitial = (rm: boolean): TargetAndTransition => |
| 28 | + rm ? { opacity: 0 } : { opacity: 0, transform: 'translateX(24px)' }; |
| 29 | +const detailsEnter = (rm: boolean): TargetAndTransition => |
| 30 | + rm |
| 31 | + ? { opacity: 1, transition: { duration: 0.12, ease: 'linear' } } |
| 32 | + : { |
| 33 | + opacity: 1, |
| 34 | + transform: 'translateX(0px)', |
| 35 | + transition: { |
| 36 | + transform: { duration: 0.34, ease: NAV_EASE }, |
| 37 | + opacity: { duration: 0.2, ease: 'easeOut' }, |
| 38 | + }, |
| 39 | + }; |
| 40 | +const detailsExit = (rm: boolean): TargetAndTransition => |
| 41 | + rm |
| 42 | + ? { opacity: 0, pointerEvents: 'none', transition: { duration: 0.12, ease: 'linear' } } |
| 43 | + : { |
| 44 | + opacity: 0, |
| 45 | + transform: 'translateX(20px)', |
| 46 | + pointerEvents: 'none', |
| 47 | + transition: { |
| 48 | + transform: { duration: 0.26, ease: NAV_EASE }, |
| 49 | + opacity: { duration: 0.22, ease: 'easeOut' }, |
| 50 | + }, |
| 51 | + }; |
| 52 | +const listRecede = (rm: boolean): TargetAndTransition => |
| 53 | + rm |
| 54 | + ? { opacity: 0.999, transition: { duration: 0.12, ease: 'linear' } } |
| 55 | + : { transform: 'scale(1.03)', transition: { duration: 0.3, ease: NAV_EASE } }; |
| 56 | +const listSettle = (rm: boolean): TargetAndTransition => |
| 57 | + rm |
| 58 | + ? { opacity: 1, transition: { duration: 0.12, ease: 'linear' } } |
| 59 | + : { transform: 'scale(1)', transition: { duration: 0.34, ease: NAV_EASE } }; |
| 60 | + |
| 61 | +const SPEEDS = [1, 2, 3, 5, 10]; |
| 62 | + |
| 63 | +function FakeList({ onOpen }: { onOpen: (n: number) => void }) { |
| 64 | + return ( |
| 65 | + <div className="h-full w-full flex flex-col bg-bg-primary text-text-primary overflow-hidden"> |
| 66 | + <section className="bg-bg-elevated px-8 pt-6 pb-8 border-b border-border-subtle shrink-0"> |
| 67 | + <h1 className="text-3xl font-medium tracking-wide">My Natively</h1> |
| 68 | + </section> |
| 69 | + <div className="flex-1 overflow-y-auto px-8 py-4 space-y-1"> |
| 70 | + {Array.from({ length: 14 }, (_, i) => ( |
| 71 | + <button |
| 72 | + key={i} |
| 73 | + onClick={() => onOpen(i)} |
| 74 | + className="w-full text-left px-4 py-3 rounded-xl hover:bg-white/5 flex items-center justify-between" |
| 75 | + > |
| 76 | + <span className="text-[14px]">Weekly sync — engineering #{i + 1}</span> |
| 77 | + <span className="text-[13px] text-text-secondary">3:1{i}pm</span> |
| 78 | + </button> |
| 79 | + ))} |
| 80 | + </div> |
| 81 | + </div> |
| 82 | + ); |
| 83 | +} |
| 84 | + |
| 85 | +function FakeDetails({ n }: { n: number }) { |
| 86 | + return ( |
| 87 | + <div className="h-full w-full flex flex-col bg-bg-elevated text-text-secondary overflow-hidden"> |
| 88 | + <div className="flex-1 overflow-y-auto"> |
| 89 | + {/* Plain div, matching MeetingDetails after its own delayed |
| 90 | + mount fade-up was removed: the page transition owns the |
| 91 | + entrance, so the arriving panel carries its content with it |
| 92 | + instead of landing empty and filling in afterwards. */} |
| 93 | + <div className="max-w-4xl mx-auto px-8 py-8"> |
| 94 | + <h1 className="text-2xl font-medium text-text-primary mb-2"> |
| 95 | + Weekly sync — engineering #{n + 1} |
| 96 | + </h1> |
| 97 | + <p className="text-[13px] text-text-secondary mb-8">Aug 26 · 42:18</p> |
| 98 | + {Array.from({ length: 8 }, (_, i) => ( |
| 99 | + <p key={i} className="text-[14px] leading-relaxed mb-4"> |
| 100 | + Paragraph {i + 1}. Body copy at the real 14px so the mid-travel frames |
| 101 | + show whether the leaving page stays legible over the arriving one, which |
| 102 | + is the failure a dissolve has and a push should not. |
| 103 | + </p> |
| 104 | + ))} |
| 105 | + </div> |
| 106 | + </div> |
| 107 | + </div> |
| 108 | + ); |
| 109 | +} |
| 110 | + |
| 111 | +function Harness() { |
| 112 | + const [selected, setSelected] = useState<number | null>(null); |
| 113 | + const [speed, setSpeed] = useState(1); |
| 114 | + const [reduced, setReduced] = useState(false); |
| 115 | + |
| 116 | + |
| 117 | + return ( |
| 118 | + <div className="h-screen w-screen flex flex-col bg-bg-primary"> |
| 119 | + <div className="shrink-0 flex items-center gap-4 px-4 h-[52px] border-b border-border-subtle text-text-primary text-[13px]"> |
| 120 | + <button |
| 121 | + onClick={() => setSelected(selected === null ? 0 : null)} |
| 122 | + className="px-3 py-1.5 rounded-full bg-white/10 hover:bg-white/20" |
| 123 | + > |
| 124 | + {selected === null ? 'Push →' : '← Pop'} |
| 125 | + </button> |
| 126 | + <div className="flex items-center gap-1"> |
| 127 | + {SPEEDS.map(s => ( |
| 128 | + <button |
| 129 | + key={s} |
| 130 | + onClick={() => setSpeed(s)} |
| 131 | + className={`px-2.5 py-1 rounded-full ${speed === s ? 'bg-white/25' : 'bg-white/5 hover:bg-white/10'}`} |
| 132 | + > |
| 133 | + {s}x slower |
| 134 | + </button> |
| 135 | + ))} |
| 136 | + </div> |
| 137 | + <label className="flex items-center gap-2 ml-auto"> |
| 138 | + <input type="checkbox" checked={reduced} onChange={e => setReduced(e.target.checked)} /> |
| 139 | + prefers-reduced-motion |
| 140 | + </label> |
| 141 | + </div> |
| 142 | + |
| 143 | + {/* Mirrors Launcher.tsx: the content area below the persistent |
| 144 | + header chrome, clipping both absolutely-positioned layers. */} |
| 145 | + <div className="relative flex-1 flex flex-col overflow-hidden"> |
| 146 | + {/* Slow motion scales the variants' own durations (see |
| 147 | + `slowed` below) rather than using MotionConfig, so the |
| 148 | + per-direction PUSH/POP split survives. */} |
| 149 | + <AnimatePresence initial={false}> |
| 150 | + {selected !== null ? ( |
| 151 | + <motion.div |
| 152 | + key="details" |
| 153 | + data-page="details" |
| 154 | + className="absolute inset-0 z-20 overflow-hidden" |
| 155 | + initial={detailsInitial(reduced)} |
| 156 | + animate={slow(detailsEnter(reduced), speed)} |
| 157 | + exit={slow(detailsExit(reduced), speed)} |
| 158 | + > |
| 159 | + <FakeDetails n={selected} /> |
| 160 | + </motion.div> |
| 161 | + ) : ( |
| 162 | + <motion.div |
| 163 | + key="launcher" |
| 164 | + data-page="launcher" |
| 165 | + className="absolute inset-0 z-10 flex flex-col overflow-hidden" |
| 166 | + initial={listRecede(reduced)} |
| 167 | + animate={slow(listSettle(reduced), speed)} |
| 168 | + exit={slow(listRecede(reduced), speed)} |
| 169 | + > |
| 170 | + <FakeList onOpen={setSelected} /> |
| 171 | + </motion.div> |
| 172 | + )} |
| 173 | + </AnimatePresence> |
| 174 | + </div> |
| 175 | + </div> |
| 176 | + ); |
| 177 | +} |
| 178 | + |
| 179 | +// Scale durations without touching the curve, so slow motion stretches the real |
| 180 | +// easing rather than showing a different animation. Handles both a flat |
| 181 | +// `transition.duration` and the per-property form PR #511 uses. |
| 182 | +function slow(target: TargetAndTransition, factor: number): TargetAndTransition { |
| 183 | + if (factor === 1) return target; |
| 184 | + const t = target.transition as Record<string, any> | undefined; |
| 185 | + if (!t) return target; |
| 186 | + const out: Record<string, any> = {}; |
| 187 | + for (const [k, v] of Object.entries(t)) { |
| 188 | + out[k] = typeof v === 'object' && v && 'duration' in v |
| 189 | + ? { ...v, duration: v.duration * factor } |
| 190 | + : k === 'duration' ? v * factor : v; |
| 191 | + } |
| 192 | + return { ...target, transition: out }; |
| 193 | +} |
| 194 | + |
| 195 | +createRoot(document.getElementById('harness-root')!).render( |
| 196 | + <React.StrictMode> |
| 197 | + <Harness /> |
| 198 | + </React.StrictMode>, |
| 199 | +); |
0 commit comments