import { createEffect, For, onCleanup } from "solid-js" import { createStore } from "solid-js/store" import { TextReveal } from "./text-reveal" const defaults = { text: "Refactor ToolStatusTitle DOM measurement", growOnly: true, truncate: false, duration: 600, bounce: 1, bounceSoft: 1, hybridTravel: 25, hybridEdge: 17, edge: 17, revealTravel: 0, } export default { title: "UI/TextReveal", id: "components-text-reveal", tags: ["autodocs"], component: TextReveal, args: defaults, argTypes: { duration: { control: { type: "range", min: 100, max: 1400, step: 10 } }, bounce: { control: { type: "range", min: 1, max: 2, step: 0.01 } }, bounceSoft: { control: { type: "range", min: 1, max: 1.5, step: 0.01 } }, hybridTravel: { control: { type: "range", min: 0, max: 40, step: 1 } }, hybridEdge: { control: { type: "range", min: 0, max: 40, step: 1 } }, edge: { control: { type: "range", min: 0, max: 40, step: 1 } }, revealTravel: { control: { type: "range", min: 0, max: 16, step: 1 } }, }, parameters: { docs: { description: { component: `### Overview Playground for the TextReveal text transition component. **Hybrid** — mask wipe + vertical slide: gradient sweeps AND text moves downward. **Wipe only** — pure mask wipe: gradient sweeps top-to-bottom, text stays in place.`, }, }, }, } const TEXTS = [ defaults.text, "Remove inline measure nodes", "Run typechecks and report changes", "Verify reduced-motion behavior", "Review diff for animation edge cases", "Check keyboard semantics", undefined, "Planning key generation details", "Analyzing error handling", "Considering edge cases", ] const btn = (accent?: boolean) => ({ padding: "5px 12px", "border-radius": "6px", border: accent ? "1px solid var(--color-accent, #58f)" : "1px solid var(--color-divider, #333)", background: accent ? "var(--color-accent, #58f)" : "var(--color-fill-element, #222)", color: "var(--color-text, #eee)", cursor: "pointer", "font-size": "12px", }) as const const sliderLabel = { width: "90px", "font-size": "12px", color: "var(--color-text-secondary, #a3a3a3)", "flex-shrink": "0", } as const const cardStyle = { padding: "20px 24px", "border-radius": "10px", border: "1px solid var(--color-divider, #333)", background: "var(--color-fill-element, #1a1a1a)", display: "grid", gap: "12px", } as const const cardLabel = { "font-size": "11px", "font-family": "monospace", color: "var(--color-text-weak, #666)", } as const const previewRow = { display: "flex", "align-items": "center", gap: "8px", "font-size": "14px", "font-weight": "500", "line-height": "20px", color: "var(--text-weak, #aaa)", "min-height": "20px", overflow: "visible", } as const const headingSlot = { "min-width": "0", overflow: "visible", color: "var(--text-weaker, #888)", "font-weight": "400", } as const export const Playground = { render: (args: typeof defaults) => { const [state, setState] = createStore({ ...defaults, index: 0, cycling: false, }) for (const key of [ "duration", "bounce", "bounceSoft", "hybridTravel", "hybridEdge", "edge", "revealTravel", ] as const) { createEffect(() => setState(key, args[key])) } createEffect(() => setState("growOnly", args.growOnly)) createEffect(() => { setState("text", args.text) setState("index", 0) }) const index = () => state.index const cycling = () => state.cycling const growOnly = () => state.growOnly const duration = () => state.duration const bounce = () => state.bounce const bounceSoft = () => state.bounceSoft const hybridTravel = () => state.hybridTravel const hybridEdge = () => state.hybridEdge const edge = () => state.edge const revealTravel = () => state.revealTravel let timer: number | undefined const text = () => (index() === 0 ? state.text || undefined : TEXTS[index()]) const next = () => setState("index", (value) => (value + 1) % TEXTS.length) const prev = () => setState("index", (value) => (value - 1 + TEXTS.length) % TEXTS.length) const toggleCycle = () => { if (cycling()) { if (timer) clearTimeout(timer) timer = undefined setState("cycling", false) return } setState("cycling", true) const tick = () => { next() timer = window.setTimeout(tick, 700 + Math.floor(Math.random() * 600)) } timer = window.setTimeout(tick, 700 + Math.floor(Math.random() * 600)) } onCleanup(() => { if (timer) clearTimeout(timer) }) const spring = () => `cubic-bezier(0.34, ${bounce()}, 0.64, 1)` const springSoft = () => `cubic-bezier(0.34, ${bounceSoft()}, 0.64, 1)` return (