import { useRef, useState } from 'react' import { Roll, Stage, type Act } from '../kit' import { MacPointer } from '../kit/cursors' import { Cursor } from '../kit/cursor' import './continuity.css' type State = { pressed: boolean; gripped: boolean; moved: boolean; settled: boolean; phase: 'idle' | 'pending' | 'done' } const initial: State = { pressed: false, gripped: false, moved: false, settled: false, phase: 'idle' } export const continuityLessons = [ { id: 'drag-offset', title: 'Grabbing an object moves it', note: 'The pointer grabs the right side of the file. Follow that exact point through the drag and release.', bad: 'Snaps its center under the pointer', good: 'Keeps the point that was grabbed' }, { id: 'spinner-start', title: 'A spinner arrives stopped', note: 'Watch the first moment of the saving state. Feedback should already be moving as it appears.', bad: 'Appears, waits, then starts spinning', good: 'Already spinning as it appears' }, ] as const async function drag(a: Act) { await a.wait(1100) a.put({ pressed: true }) await a.wait(60) a.put({ gripped: true }) await a.wait(70) a.put({ pressed: false }) await a.wait(120) a.put({ moved: true }) await a.wait(1000) a.put({ gripped: false }) } async function pending(a: Act) { await a.wait(1100) await a.set({ pressed: true }) await a.wait(180) await a.set({ pressed: false, phase: 'pending' }) await a.wait(1700) await a.set({ phase: 'done' }) await a.wait(220) await a.set({ settled: true }) } function Drag({ state, good }: { state: State; good: boolean }) { const cursor = useRef(null) return
Draft
} function Pending({ state, good }: { state: State; good: boolean }) { return
{state.phase === 'idle' ? 'Save' : state.phase === 'pending' ? 'Saving' : 'Saved'}
} export function ContinuityComparison({ lessonId }: { lessonId: string }) { const [revision, replay] = useState(0) const lesson = continuityLessons.find(item => item.id === lessonId)! const isDrag = lesson.id === 'drag-offset' return

{lesson.title}

{lesson.note}

key={`${lessonId}-${revision}`} width={704} height={150} compact={{ below: 704, width: 340, height: 316 }} initial={initial} poster={{ pressed: false, gripped: false, moved: true, settled: true, phase: 'done' }} script={isDrag ? drag : pending} play="once" className="tc-stage"> {state =>
{[false, true].map(good =>
{isDrag ? : }
{good ? lesson.good : lesson.bad}
)}
}
}