Skip to content

Commit 64673c1

Browse files
committed
fix(studio): captions UX — mode exit, undo, autosave surfacing, honest gating
1 parent 81d53b6 commit 64673c1

13 files changed

Lines changed: 736 additions & 177 deletions

‎packages/studio/src/captions/components/CaptionAnimationPanel.tsx‎

Lines changed: 46 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,13 @@ const EASE_PRESETS = [
6161
"bounce.out",
6262
];
6363

64-
import { Section, Row, inputCls } from "./shared";
64+
import { Section, Row, inputCls, NumberField } from "./shared";
65+
66+
// Animation edits currently mutate only the in-memory model: they are not
67+
// applied to the preview and not serialized by buildOverrides, so tuning them
68+
// would be editing blind. Controls stay visible (so the capability is
69+
// discoverable) but disabled until the apply/persist pipeline exists.
70+
const ANIMATION_PIPELINE_WIRED = false;
6571

6672
// ---------------------------------------------------------------------------
6773
// Animation phase controls
@@ -72,6 +78,7 @@ interface AnimationPhaseProps {
7278
presets: string[];
7379
animation: CaptionAnimation | null;
7480
showIntensity?: boolean;
81+
disabled?: boolean;
7582
onChange: (update: Partial<CaptionAnimation>) => void;
7683
}
7784

@@ -80,6 +87,7 @@ function AnimationPhase({
8087
presets,
8188
animation,
8289
showIntensity,
90+
disabled,
8391
onChange,
8492
}: AnimationPhaseProps) {
8593
const preset = animation?.preset ?? "none";
@@ -93,6 +101,8 @@ function AnimationPhase({
93101
<Row label="Preset">
94102
<select
95103
value={preset}
104+
disabled={disabled}
105+
aria-label={`${label} preset`}
96106
onChange={(e) => onChange({ preset: e.target.value })}
97107
className={inputCls}
98108
>
@@ -105,20 +115,22 @@ function AnimationPhase({
105115
</Row>
106116

107117
<Row label="Duration">
108-
<input
109-
type="number"
118+
<NumberField
110119
value={duration}
111120
step={0.05}
112121
min={0}
113122
max={2}
114-
onChange={(e) => onChange({ duration: Number(e.target.value) })}
115-
className={inputCls}
123+
disabled={disabled}
124+
ariaLabel={`${label} duration`}
125+
onCommit={(v) => onChange({ duration: v })}
116126
/>
117127
</Row>
118128

119129
<Row label="Ease">
120130
<select
121131
value={ease}
132+
disabled={disabled}
133+
aria-label={`${label} ease`}
122134
onChange={(e) => onChange({ ease: e.target.value })}
123135
className={inputCls}
124136
>
@@ -131,14 +143,14 @@ function AnimationPhase({
131143
</Row>
132144

133145
<Row label="Stagger">
134-
<input
135-
type="number"
146+
<NumberField
136147
value={stagger}
137148
step={0.02}
138149
min={0}
139150
max={0.5}
140-
onChange={(e) => onChange({ stagger: Number(e.target.value) })}
141-
className={inputCls}
151+
disabled={disabled}
152+
ariaLabel={`${label} stagger`}
153+
onCommit={(v) => onChange({ stagger: v })}
142154
/>
143155
</Row>
144156

@@ -151,8 +163,13 @@ function AnimationPhase({
151163
max={1}
152164
step={0.01}
153165
value={intensity}
154-
onChange={(e) => onChange({ intensity: Number(e.target.value) })}
155-
className="flex-1 accent-studio-accent"
166+
disabled={disabled}
167+
aria-label={`${label} intensity`}
168+
onChange={(e) => {
169+
const v = Number(e.target.value);
170+
if (Number.isFinite(v)) onChange({ intensity: v });
171+
}}
172+
className="flex-1 accent-studio-accent disabled:opacity-40"
156173
/>
157174
<span className="text-2xs text-neutral-400 font-mono w-8 text-right flex-shrink-0">
158175
{intensity.toFixed(2)}
@@ -222,19 +239,31 @@ export const CaptionAnimationPanel = memo(function CaptionAnimationPanel() {
222239
if (!group || !resolvedGroupId || !animation) {
223240
return (
224241
<div className="flex items-center justify-center h-full px-4 text-center">
225-
<p className="text-xs text-neutral-500">Select a caption group to edit animations</p>
242+
<p className="text-xs text-neutral-500">Select a caption word to edit animations</p>
226243
</div>
227244
);
228245
}
229246

247+
const gated = !ANIMATION_PIPELINE_WIRED;
248+
230249
return (
231250
<div className="flex flex-col h-full min-h-0">
251+
{gated && (
252+
<div className="flex-shrink-0 mx-3 mt-2 px-2 py-1.5 rounded border border-amber-500/30 bg-amber-500/10">
253+
<p className="text-2xs text-amber-300/90 leading-snug">
254+
Animation editing isn&apos;t applied to playback or saved yet, so these controls are
255+
disabled.
256+
</p>
257+
</div>
258+
)}
259+
232260
{/* Scrollable content */}
233261
<div className="flex-1 overflow-y-auto px-3 py-2">
234262
<AnimationPhase
235263
label="Entrance"
236264
presets={ENTRANCE_PRESETS}
237265
animation={animation.entrance}
266+
disabled={gated}
238267
onChange={handleEntranceChange}
239268
/>
240269

@@ -243,13 +272,15 @@ export const CaptionAnimationPanel = memo(function CaptionAnimationPanel() {
243272
presets={HIGHLIGHT_PRESETS}
244273
animation={animation.highlight}
245274
showIntensity
275+
disabled={gated}
246276
onChange={handleHighlightChange}
247277
/>
248278

249279
<AnimationPhase
250280
label="Exit"
251281
presets={EXIT_PRESETS}
252282
animation={animation.exit}
283+
disabled={gated}
253284
onChange={handleExitChange}
254285
/>
255286
</div>
@@ -259,7 +290,9 @@ export const CaptionAnimationPanel = memo(function CaptionAnimationPanel() {
259290
<button
260291
type="button"
261292
onClick={handleApplyToAll}
262-
className="w-full py-1.5 rounded border border-neutral-700 text-2xs text-neutral-300 hover:border-studio-accent/50 hover:text-studio-accent transition-colors"
293+
disabled={gated}
294+
title={gated ? "Disabled until animation editing is applied to playback" : undefined}
295+
className="w-full py-1.5 rounded border border-neutral-700 text-2xs text-neutral-300 hover:border-studio-accent/50 hover:text-studio-accent transition-colors disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:border-neutral-700 disabled:hover:text-neutral-300"
263296
>
264297
Apply to all groups
265298
</button>

0 commit comments

Comments
 (0)