import { useState } from 'react' import { Stage, type Act } from '../kit' import './edges.css' type State = { changed: boolean; offset: 0 | 45 | 64; moving: boolean; started: boolean } const initial: State = { changed: false, offset: 0, moving: false, started: false } export const edgeLessons = [ { id: 'label-boundary', title: 'A label hits a hard edge', note: 'Watch the letter shapes at the top and bottom of the button’s label slot. The boundary should soften the moving text, while resting text stays sharp.', bad: 'Letters are sliced by the slot', good: 'Letters soften as they reach the edge' }, { id: 'viewport-edge', title: 'Scrolling content meets the edge', note: 'Both lists start with three whole rows. After scrolling begins, the softened edges indicate content above or below; they clear when no content remains hidden there.', bad: 'Rows meet an abrupt clipping edge', good: 'Only the concealed edges are softened' }, ] as const async function labels(a: Act) { await a.wait(1200) await a.set({ changed: true }) await a.wait(2000) await a.set({ changed: false }) } async function scrolling(a: Act) { await a.wait(1200) await a.set({ offset: 45, moving: true, started: true }) await a.wait(900) await a.set({ moving: false }) await a.wait(800) await a.set({ offset: 64, moving: true }) await a.wait(900) await a.set({ moving: false }) await a.wait(1200) await a.set({ offset: 0, moving: true }) await a.wait(900) await a.set({ moving: false }) } function LabelSlot({ state, good }: { state: State; good: boolean }) { return
Upload fileUploaded
} function Viewport({ state, good }: { state: State; good: boolean }) { const top = state.started && (state.offset > 0 || state.moving) const bottom = state.started && (state.offset < 64 || state.moving) && (state.offset > 0 || state.moving) return
Project files5 files
{['Brief.pdf', 'Wireframes.fig', 'Review.md', 'Prototype.fig', 'Notes.txt'].map((file, i) =>
{file}{[24, 182, 4, 96, 2][i]} KB
)}
} export function EdgeComparison({ lessonId }: { lessonId: string }) { const [revision, replay] = useState(0) const lesson = edgeLessons.find(item => item.id === lessonId)! const viewport = lesson.id === 'viewport-edge' const height = viewport ? 218 : 150 return

{lesson.title}

{lesson.note}

key={revision} width={704} height={height} compact={{ below: 704, width: 340, height: height * 2 + 16 }} initial={initial} poster={{ ...initial, changed: true }} script={viewport ? scrolling : labels} play="once" className="tc-stage"> {state =>
{[false, true].map(good =>
{viewport ? : }
{good ? lesson.good : lesson.bad}
)}
}
}