@hyperframes/studio 0.8.58 → 0.8.60

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/dist/assets/{hyperframes-player-zGyOcwwh.js → hyperframes-player-Di7GyCOP.js} +3 -3
  2. package/dist/assets/{index-DKJpHYYd.css → index-CBKb_0TI.css} +1 -1
  3. package/dist/assets/{index-d8ferjRc.js → index-Dpq2lkOm.js} +190 -190
  4. package/dist/assets/{index-ZJaRCDYV.js → index-Dx_pt9m4.js} +1 -1
  5. package/dist/assets/{index-BcE2OSVA.js → index-jAjhQTrB.js} +1 -1
  6. package/dist/index.d.ts +549 -13
  7. package/dist/index.html +2 -2
  8. package/dist/index.js +23133 -21941
  9. package/dist/index.js.map +1 -1
  10. package/dist/styles.css +1 -1
  11. package/package.json +7 -7
  12. package/src/components/StudioHeader.tsx +2 -13
  13. package/src/components/TimelineToolbar.test.tsx +42 -0
  14. package/src/components/TimelineToolbar.tsx +22 -8
  15. package/src/components/editor/audioInspectorInput.test.ts +55 -0
  16. package/src/components/editor/audioInspectorInput.ts +55 -0
  17. package/src/components/editor/propertyPanelFill.tsx +3 -2
  18. package/src/components/editor/propertyPanelFlatMediaSection.test.tsx +172 -0
  19. package/src/components/editor/propertyPanelFlatMediaSection.tsx +87 -1
  20. package/src/components/editor/propertyPanelFlatPrimitives.test.tsx +92 -0
  21. package/src/components/editor/propertyPanelFlatPrimitives.tsx +13 -9
  22. package/src/components/editor/propertyPanelFlatSliderReadout.tsx +106 -0
  23. package/src/components/editor/useColorGradingController.ts +2 -6
  24. package/src/components/icons/AudioMetersIcon.tsx +16 -0
  25. package/src/components/icons/InspectorIcon.tsx +18 -0
  26. package/src/components/icons/ReverseGradientIcon.tsx +23 -0
  27. package/src/components/icons/RippleEditIcon.tsx +19 -0
  28. package/src/components/nle/AudioMeterStrip.test.tsx +395 -0
  29. package/src/components/nle/AudioMeterStrip.tsx +430 -0
  30. package/src/components/nle/TimelinePane.tsx +29 -23
  31. package/src/components/ui/Menu.test.tsx +3 -4
  32. package/src/components/ui/Menu.tsx +18 -5
  33. package/src/components/ui/Select.tsx +7 -1
  34. package/src/components/ui/Tooltip.tsx +6 -1
  35. package/src/contexts/TimelineEditContext.tsx +4 -0
  36. package/src/hooks/useTimelineAssetDropOps.ts +9 -1
  37. package/src/index.ts +16 -0
  38. package/src/player/components/AudioWaveform.tsx +16 -7
  39. package/src/player/components/ImageThumbnail.tsx +3 -5
  40. package/src/player/components/LayerDisclosureRow.tsx +9 -4
  41. package/src/player/components/PlayheadIndicator.tsx +3 -3
  42. package/src/player/components/Timeline.test.ts +22 -31
  43. package/src/player/components/Timeline.tsx +34 -7
  44. package/src/player/components/TimelineAutomationLane.test.tsx +1 -1
  45. package/src/player/components/TimelineAutomationLane.tsx +5 -5
  46. package/src/player/components/TimelineCanvas.tsx +28 -71
  47. package/src/player/components/TimelineClip.test.tsx +41 -4
  48. package/src/player/components/TimelineClip.tsx +25 -5
  49. package/src/player/components/TimelineClipDiamonds.test.tsx +3 -1
  50. package/src/player/components/TimelineClipDiamonds.tsx +2 -2
  51. package/src/player/components/TimelineClipFades.test.tsx +171 -0
  52. package/src/player/components/TimelineClipFades.tsx +302 -0
  53. package/src/player/components/TimelineDiamondConnectors.tsx +2 -2
  54. package/src/player/components/TimelineEmptyState.tsx +1 -1
  55. package/src/player/components/TimelineFxButton.tsx +10 -8
  56. package/src/player/components/TimelineGroupHeader.tsx +18 -9
  57. package/src/player/components/TimelineGroupLaneLabels.tsx +12 -5
  58. package/src/player/components/TimelineGroupRow.tsx +1 -1
  59. package/src/player/components/TimelineLanes.test.tsx +14 -0
  60. package/src/player/components/TimelineOverlays.tsx +164 -165
  61. package/src/player/components/TimelineParts.test.tsx +101 -0
  62. package/src/player/components/TimelineParts.tsx +74 -0
  63. package/src/player/components/TimelinePartsParity.test.tsx +58 -0
  64. package/src/player/components/TimelinePropertyLanes.test.tsx +1 -1
  65. package/src/player/components/TimelineProvider.tsx +25 -0
  66. package/src/player/components/TimelineRazorInteraction.tsx +2 -2
  67. package/src/player/components/TimelineRuler.tsx +3 -2
  68. package/src/player/components/TimelineRulerPart.tsx +22 -0
  69. package/src/player/components/TimelineShortcutHint.tsx +2 -2
  70. package/src/player/components/TimelineTrackHeader.test.tsx +1 -1
  71. package/src/player/components/TimelineTrackHeader.tsx +4 -6
  72. package/src/player/components/TimelineTrackPlainHeader.tsx +10 -3
  73. package/src/player/components/VideoThumbnail.tsx +3 -5
  74. package/src/player/components/timelineMotionStyles.test.ts +96 -30
  75. package/src/player/components/timelineProviderStateBuilders.ts +20 -0
  76. package/src/player/components/timelineTheme.test.ts +14 -0
  77. package/src/player/components/timelineTheme.ts +12 -11
  78. package/src/player/components/useTimelineProviderState.tsx +19 -12
  79. package/src/player/lib/timelineElementHelpers.ts +20 -0
  80. package/src/player/store/timelineElement.ts +5 -0
  81. package/src/styles/hex-baseline.json +4 -23
  82. package/src/styles/studio.css +43 -47
  83. package/src/styles/theme.css +109 -1
  84. package/src/styles/theme.test.ts +9 -0
  85. package/src/utils/audioMeterMath.test.ts +44 -0
  86. package/src/utils/audioMeterMath.ts +79 -0
  87. package/src/utils/audioMeterVisibility.ts +14 -0
  88. package/src/utils/studioHelpers.ts +21 -0
  89. package/src/utils/studioUiPreferences.test.ts +10 -0
  90. package/src/utils/studioUiPreferences.ts +5 -0
  91. package/src/utils/timelineAssetDrop.test.ts +32 -0
  92. package/src/utils/timelineAssetDrop.ts +6 -1
@@ -1,9 +1,15 @@
1
1
  import { memo, type CSSProperties, type ReactNode } from "react";
2
2
  import type { TimelineElement } from "../store/playerStore";
3
- import { defaultTimelineTheme, getClipHandleOpacity, type TimelineTheme } from "./timelineTheme";
3
+ import {
4
+ clipWidthLadder,
5
+ defaultTimelineTheme,
6
+ getClipHandleOpacity,
7
+ type TimelineTheme,
8
+ } from "./timelineTheme";
4
9
  import type { TimelineEditCapabilities } from "./timelineEditing";
5
10
  import { isAudioTimelineElement } from "../../utils/timelineInspector";
6
11
  import { timelineClipFocusId } from "./timelineNavigationIdentity";
12
+ import { TimelineClipFades } from "./TimelineClipFades";
7
13
 
8
14
  interface TimelineClipProps {
9
15
  el: TimelineElement;
@@ -59,9 +65,10 @@ export const TimelineClip = memo(function TimelineClip({
59
65
  const widthPx = Math.max(el.duration * pps, 4);
60
66
  const handleOpacity = getClipHandleOpacity({ isHovered, isSelected, isDragging });
61
67
  const displayLabel = el.label || el.id || el.tag;
68
+ const ladder = clipWidthLadder(widthPx);
62
69
  const showHandles = handleOpacity > 0.01 && (widthPx >= 32 || isSelected);
63
- const showLabel = widthPx >= 40 || isSelected;
64
- const showDefaultText = !hasCustomContent && (widthPx >= 40 || isSelected);
70
+ const showLabel = ladder === "labeled";
71
+ const showDefaultText = !hasCustomContent && ladder === "labeled";
65
72
  const startLabel = el.start.toFixed(1);
66
73
  const endLabel = (el.start + el.duration).toFixed(1);
67
74
  const themeVariables = {
@@ -74,6 +81,7 @@ export const TimelineClip = memo(function TimelineClip({
74
81
  "--clip-border-active": theme.clipBorderActive,
75
82
  "--clip-handle": theme.handleColor,
76
83
  } as CSSProperties;
84
+ const isAudioClip = isAudioTimelineElement(el);
77
85
  const clipClassName = [
78
86
  "timeline-clip",
79
87
  "absolute",
@@ -81,7 +89,7 @@ export const TimelineClip = memo(function TimelineClip({
81
89
  isSelected ? "is-selected" : "",
82
90
  isHovered ? "is-hovered" : "",
83
91
  isDragging ? "is-dragging" : "",
84
- isAudioTimelineElement(el) ? "is-audio" : "",
92
+ isAudioClip ? "is-audio" : "",
85
93
  ]
86
94
  .filter((className) => className.length > 0)
87
95
  .join(" ");
@@ -90,7 +98,7 @@ export const TimelineClip = memo(function TimelineClip({
90
98
  width: widthPx,
91
99
  top: clipY,
92
100
  ...(clipHeight === undefined ? { bottom: clipY } : { height: clipHeight }),
93
- borderRadius: theme.clipRadius,
101
+ borderRadius: isAudioClip ? theme.audioClipRadius : theme.clipRadius,
94
102
  ...themeVariables,
95
103
  zIndex: isDragging ? 20 : isSelected ? 10 : isHovered ? 5 : 1,
96
104
  // Regular cursor over clips (CapCut-style, user preference) — no grab hand.
@@ -112,6 +120,7 @@ export const TimelineClip = memo(function TimelineClip({
112
120
  data-clip-start={el.start}
113
121
  data-clip-end={el.start + el.duration}
114
122
  data-clip-hidden={el.hidden ? "true" : undefined}
123
+ data-ladder={ladder}
115
124
  data-active={isActive ? "" : undefined}
116
125
  aria-hidden={isGestureActor ? "true" : undefined}
117
126
  tabIndex={isGestureActor ? undefined : tabIndex}
@@ -198,6 +207,17 @@ export const TimelineClip = memo(function TimelineClip({
198
207
  </span>
199
208
  )}
200
209
  {children}
210
+ {/* Fade handles + ramps for anything the mixer hears — audio clips and
211
+ videos marked data-has-audio. They write data-fade-in/out on the clip
212
+ and are the timeline half of the inspector's Fade rows. */}
213
+ {(isAudioClip || el.hasAudio) && !isGestureActor && (
214
+ <TimelineClipFades
215
+ el={el}
216
+ pps={pps}
217
+ widthPx={widthPx}
218
+ showHandles={(isHovered || isSelected) && !isDragging}
219
+ />
220
+ )}
201
221
  </button>
202
222
  );
203
223
  });
@@ -258,7 +258,9 @@ describe("TimelineClipDiamonds", () => {
258
258
  const selectedDiamond = host.querySelector<HTMLButtonElement>('button[title="60%"]');
259
259
  expect(playheadDiamond?.dataset.keyframeAtPlayhead).toBe("true");
260
260
  expect(playheadDiamond?.dataset.keyframeSelected).toBe("false");
261
- expect(playheadDiamond?.querySelector("path:last-child")?.getAttribute("fill")).toBe("#a3a3a3");
261
+ expect(playheadDiamond?.querySelector("path:last-child")?.getAttribute("fill")).toBe(
262
+ "var(--timeline-diamond-muted)",
263
+ );
262
264
  expect(playheadDiamond?.querySelector('path[stroke="#4ba3d2"]')).not.toBeNull();
263
265
  expect(selectedDiamond?.dataset.keyframeAtPlayhead).toBe("false");
264
266
  expect(selectedDiamond?.dataset.keyframeSelected).toBe("true");
@@ -225,7 +225,7 @@ export const TimelineDiamondLane = memo(function TimelineDiamondLane({
225
225
  isSelected && halfFramePct > 0
226
226
  ? nearestKeyframeWithin(sorted, currentPercentage, halfFramePct)
227
227
  : null;
228
- const baseColor = isSelected ? accentColor : "#a3a3a3";
228
+ const baseColor = isSelected ? accentColor : "var(--timeline-diamond-muted)";
229
229
  const baseOpacity = isSelected ? 0.4 : 0.25;
230
230
  const canDrag = isSelected && !!onMoveKeyframe;
231
231
 
@@ -280,7 +280,7 @@ export const TimelineDiamondLane = memo(function TimelineDiamondLane({
280
280
  const isKfSelected = selectedKeyframes.has(kfKey);
281
281
  const atPlayhead = kf === playheadKeyframe;
282
282
  const isHighlighted = isKfSelected || atPlayhead;
283
- const color = isKfSelected ? accentColor : "#a3a3a3";
283
+ const color = isKfSelected ? accentColor : "var(--timeline-diamond-muted)";
284
284
 
285
285
  const onPointerDown = (e: React.PointerEvent<HTMLButtonElement>) => {
286
286
  if (e.button !== 0) return;
@@ -0,0 +1,171 @@
1
+ // @vitest-environment happy-dom
2
+
3
+ import React, { act } from "react";
4
+ import { createRoot } from "react-dom/client";
5
+ import { afterEach, describe, expect, it, vi } from "vitest";
6
+ import type { TimelineElement } from "../store/playerStore";
7
+ import { TimelineClipFades } from "./TimelineClipFades";
8
+ import { TimelineEditProvider } from "../../contexts/TimelineEditContext";
9
+
10
+ (globalThis as unknown as { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
11
+
12
+ afterEach(() => {
13
+ document.body.innerHTML = "";
14
+ });
15
+
16
+ const clip: TimelineElement = {
17
+ id: "music",
18
+ tag: "audio",
19
+ src: "assets/music.wav",
20
+ start: 2,
21
+ duration: 10,
22
+ track: 1,
23
+ fadeIn: 1,
24
+ fadeOut: 2,
25
+ };
26
+
27
+ function render(
28
+ el: TimelineElement,
29
+ options: { showHandles?: boolean; provide?: boolean; onClipPointerDown?: () => void } = {},
30
+ ) {
31
+ const host = document.createElement("div");
32
+ document.body.append(host);
33
+ const root = createRoot(host);
34
+ const onSetElementAttributeLive = vi.fn();
35
+ const onSetElementAttributeQuiet = vi.fn().mockResolvedValue(undefined);
36
+ // Stands in for the TimelineClip button the handles live inside.
37
+ const node = (
38
+ <div data-testid="clip" onPointerDown={options.onClipPointerDown}>
39
+ <TimelineClipFades
40
+ el={el}
41
+ pps={100}
42
+ widthPx={el.duration * 100}
43
+ showHandles={options.showHandles ?? true}
44
+ />
45
+ </div>
46
+ );
47
+ act(() => {
48
+ root.render(
49
+ options.provide === false ? (
50
+ node
51
+ ) : (
52
+ <TimelineEditProvider value={{ onSetElementAttributeLive, onSetElementAttributeQuiet }}>
53
+ {node}
54
+ </TimelineEditProvider>
55
+ ),
56
+ );
57
+ });
58
+ return { host, root, onSetElementAttributeLive, onSetElementAttributeQuiet };
59
+ }
60
+
61
+ function pointer(type: string, clientX: number, pointerId = 1) {
62
+ const event = new MouseEvent(type, { bubbles: true, clientX, button: 0 });
63
+ Object.defineProperty(event, "pointerId", { value: pointerId });
64
+ return event;
65
+ }
66
+
67
+ function armCapture(handle: HTMLElement) {
68
+ let captured = false;
69
+ Object.defineProperty(handle, "setPointerCapture", { value: () => (captured = true) });
70
+ Object.defineProperty(handle, "releasePointerCapture", { value: () => (captured = false) });
71
+ Object.defineProperty(handle, "hasPointerCapture", { value: () => captured });
72
+ }
73
+
74
+ describe("TimelineClipFades", () => {
75
+ it("shades the fade-in and fade-out as ramps sized by pps", () => {
76
+ const { host, root } = render(clip, { showHandles: false, provide: false });
77
+ const fadeIn = host.querySelector('[data-testid="clip-fade-in"]');
78
+ const fadeOut = host.querySelector('[data-testid="clip-fade-out"]');
79
+ // 1 s in at 100 px/s: the wedge spans 0..100; 2 s out on a 1000 px clip: 800..1000.
80
+ expect(fadeIn?.getAttribute("points")).toBe("0,0 100,0 0,100");
81
+ expect(fadeOut?.getAttribute("points")).toBe("800,0 1000,0 1000,100");
82
+ // Outside a provider there is nothing to write to, so no handles either.
83
+ expect(host.querySelector('[data-testid="clip-fade-handle-in"]')).toBeNull();
84
+ act(() => root.unmount());
85
+ });
86
+
87
+ it("renders nothing for a clip without fades when the handles are hidden", () => {
88
+ const { host, root } = render(
89
+ { ...clip, fadeIn: undefined, fadeOut: undefined },
90
+ {
91
+ showHandles: false,
92
+ },
93
+ );
94
+ expect(host.querySelector('[data-testid="clip"]')?.innerHTML).toBe("");
95
+ act(() => root.unmount());
96
+ });
97
+
98
+ it("drags the fade-in dot to the right, previewing live and committing once on release", () => {
99
+ const { host, root, onSetElementAttributeLive, onSetElementAttributeQuiet } = render(clip);
100
+ const handle = host.querySelector<HTMLElement>('[data-testid="clip-fade-handle-in"]');
101
+ if (!handle) throw new Error("expected a fade-in handle");
102
+ armCapture(handle);
103
+ // The handle sits at the 1 s mark (x=100). Drag 150 px right → 2.5 s.
104
+ act(() => handle.dispatchEvent(pointer("pointerdown", 100)));
105
+ act(() => handle.dispatchEvent(pointer("pointermove", 200)));
106
+ act(() => handle.dispatchEvent(pointer("pointermove", 250)));
107
+ expect(onSetElementAttributeLive).toHaveBeenLastCalledWith(clip, "data-fade-in", "2.5");
108
+ expect(onSetElementAttributeQuiet).not.toHaveBeenCalled();
109
+ // The ramp follows the pointer before anything is persisted.
110
+ expect(host.querySelector('[data-testid="clip-fade-in"]')?.getAttribute("points")).toBe(
111
+ "0,0 250,0 0,100",
112
+ );
113
+ act(() => handle.dispatchEvent(pointer("pointerup", 250)));
114
+ expect(onSetElementAttributeQuiet).toHaveBeenCalledTimes(1);
115
+ expect(onSetElementAttributeQuiet).toHaveBeenCalledWith(clip, "data-fade-in", "2.5", "Fade in");
116
+ act(() => root.unmount());
117
+ });
118
+
119
+ it("drags the fade-out dot to the left, growing the fade, and never past the fade-in", () => {
120
+ const { host, root, onSetElementAttributeLive, onSetElementAttributeQuiet } = render(clip);
121
+ const handle = host.querySelector<HTMLElement>('[data-testid="clip-fade-handle-out"]');
122
+ if (!handle) throw new Error("expected a fade-out handle");
123
+ armCapture(handle);
124
+ // Handle at x=800 (2 s before the end). 300 px left → 5 s.
125
+ act(() => handle.dispatchEvent(pointer("pointerdown", 800)));
126
+ act(() => handle.dispatchEvent(pointer("pointermove", 500)));
127
+ expect(onSetElementAttributeLive).toHaveBeenLastCalledWith(clip, "data-fade-out", "5");
128
+ // Way past the start: clamps to duration − fadeIn = 9 s.
129
+ act(() => handle.dispatchEvent(pointer("pointermove", -500)));
130
+ expect(onSetElementAttributeLive).toHaveBeenLastCalledWith(clip, "data-fade-out", "9");
131
+ act(() => handle.dispatchEvent(pointer("pointerup", -500)));
132
+ expect(onSetElementAttributeQuiet).toHaveBeenCalledWith(clip, "data-fade-out", "9", "Fade out");
133
+ act(() => root.unmount());
134
+ });
135
+
136
+ it("removes the attribute when dragged back to zero", () => {
137
+ const { host, root, onSetElementAttributeQuiet } = render(clip);
138
+ const handle = host.querySelector<HTMLElement>('[data-testid="clip-fade-handle-in"]');
139
+ if (!handle) throw new Error("expected a fade-in handle");
140
+ armCapture(handle);
141
+ act(() => handle.dispatchEvent(pointer("pointerdown", 100)));
142
+ act(() => handle.dispatchEvent(pointer("pointermove", -40)));
143
+ act(() => handle.dispatchEvent(pointer("pointerup", -40)));
144
+ expect(onSetElementAttributeQuiet).toHaveBeenCalledWith(clip, "data-fade-in", null, "Fade in");
145
+ act(() => root.unmount());
146
+ });
147
+
148
+ it("puts the live value back and writes nothing when the gesture is cancelled", () => {
149
+ const { host, root, onSetElementAttributeLive, onSetElementAttributeQuiet } = render(clip);
150
+ const handle = host.querySelector<HTMLElement>('[data-testid="clip-fade-handle-in"]');
151
+ if (!handle) throw new Error("expected a fade-in handle");
152
+ armCapture(handle);
153
+ act(() => handle.dispatchEvent(pointer("pointerdown", 100)));
154
+ act(() => handle.dispatchEvent(pointer("pointermove", 300)));
155
+ act(() => handle.dispatchEvent(pointer("pointercancel", 300)));
156
+ expect(onSetElementAttributeLive).toHaveBeenLastCalledWith(clip, "data-fade-in", "1");
157
+ expect(onSetElementAttributeQuiet).not.toHaveBeenCalled();
158
+ act(() => root.unmount());
159
+ });
160
+
161
+ it("does not let a press on the dot start the clip's own move gesture", () => {
162
+ const outer = vi.fn();
163
+ const { host, root } = render(clip, { onClipPointerDown: outer });
164
+ const handle = host.querySelector<HTMLElement>('[data-testid="clip-fade-handle-in"]');
165
+ if (!handle) throw new Error("expected a fade-in handle");
166
+ armCapture(handle);
167
+ act(() => handle.dispatchEvent(pointer("pointerdown", 100)));
168
+ expect(outer).not.toHaveBeenCalled();
169
+ act(() => root.unmount());
170
+ });
171
+ });
@@ -0,0 +1,302 @@
1
+ import {
2
+ useEffect,
3
+ useRef,
4
+ useState,
5
+ type CSSProperties,
6
+ type KeyboardEvent,
7
+ type PointerEvent,
8
+ } from "react";
9
+ import {
10
+ HF_AUDIO_FADE_IN_ATTR,
11
+ HF_AUDIO_FADE_OUT_ATTR,
12
+ clampFadesToDuration,
13
+ formatFadeSeconds,
14
+ } from "@hyperframes/core/audio-fade";
15
+ import type { TimelineElement } from "../store/playerStore";
16
+ import { useTimelineEditContextOptional } from "../../contexts/TimelineEditContext";
17
+
18
+ type FadeEdge = "in" | "out";
19
+
20
+ const HANDLE_SIZE = 10;
21
+ const HANDLE_HIT = 16;
22
+ /** Pixels of pointer travel before a press on the handle counts as a drag. */
23
+ const DRAG_THRESHOLD_PX = 2;
24
+
25
+ interface TimelineClipFadesProps {
26
+ el: TimelineElement;
27
+ pps: number;
28
+ widthPx: number;
29
+ /** Handles show on hover/selection; the shaded ramps show whenever a fade is set. */
30
+ showHandles: boolean;
31
+ }
32
+
33
+ /** Corner dots that drag `data-fade-in` / `data-fade-out`; the wedge is the faded region. */
34
+ export function TimelineClipFades({ el, pps, widthPx, showHandles }: TimelineClipFadesProps) {
35
+ const { onSetElementAttributeLive, onSetElementAttributeQuiet } =
36
+ useTimelineEditContextOptional();
37
+ const canEdit = Boolean(onSetElementAttributeLive && onSetElementAttributeQuiet);
38
+
39
+ // Draft holds the value under the pointer during a drag; it also bridges
40
+ // the gap between release and the store re-reading the file, so the ramp
41
+ // does not snap back for a frame.
42
+ const [draft, setDraft] = useState<{ edge: FadeEdge; seconds: number } | null>(null);
43
+ const [dragging, setDragging] = useState<FadeEdge | null>(null);
44
+ const authoredIn = el.fadeIn ?? 0;
45
+ const authoredOut = el.fadeOut ?? 0;
46
+ useEffect(() => setDraft(null), [authoredIn, authoredOut]);
47
+
48
+ const fades = clampFadesToDuration(
49
+ {
50
+ fadeIn: draft?.edge === "in" ? draft.seconds : authoredIn,
51
+ fadeOut: draft?.edge === "out" ? draft.seconds : authoredOut,
52
+ },
53
+ el.duration,
54
+ );
55
+ const inPx = Math.min(widthPx, fades.fadeIn * pps);
56
+ const outPx = Math.min(widthPx, fades.fadeOut * pps);
57
+
58
+ const gesture = useRef<{
59
+ edge: FadeEdge;
60
+ pointerId: number;
61
+ originClientX: number;
62
+ originSeconds: number;
63
+ otherSeconds: number;
64
+ moved: boolean;
65
+ last: number;
66
+ } | null>(null);
67
+
68
+ const attrFor = (edge: FadeEdge) =>
69
+ edge === "in" ? HF_AUDIO_FADE_IN_ATTR : HF_AUDIO_FADE_OUT_ATTR;
70
+ const attrText = (seconds: number) => (seconds > 0 ? formatFadeSeconds(seconds) : null);
71
+
72
+ const secondsAt = (clientX: number): number => {
73
+ const g = gesture.current;
74
+ if (!g) return 0;
75
+ const deltaSeconds = (clientX - g.originClientX) / Math.max(pps, 1e-6);
76
+ // Fade-in grows to the right, fade-out grows to the left.
77
+ const raw = g.edge === "in" ? g.originSeconds + deltaSeconds : g.originSeconds - deltaSeconds;
78
+ const limit = Math.max(0, el.duration - g.otherSeconds);
79
+ const clamped = Math.min(limit, Math.max(0, raw));
80
+ return Math.round(clamped * 100) / 100;
81
+ };
82
+
83
+ const onHandlePointerDown = (edge: FadeEdge) => (e: PointerEvent<HTMLDivElement>) => {
84
+ if (e.button !== 0 || !canEdit) return;
85
+ // Ours, not the clip's: a press here must not start a move or trim.
86
+ e.stopPropagation();
87
+ e.preventDefault();
88
+ e.currentTarget.setPointerCapture(e.pointerId);
89
+ gesture.current = {
90
+ edge,
91
+ pointerId: e.pointerId,
92
+ originClientX: e.clientX,
93
+ originSeconds: edge === "in" ? authoredIn : authoredOut,
94
+ otherSeconds: edge === "in" ? authoredOut : authoredIn,
95
+ moved: false,
96
+ last: edge === "in" ? authoredIn : authoredOut,
97
+ };
98
+ setDragging(edge);
99
+ };
100
+
101
+ const onHandlePointerMove = (e: PointerEvent<HTMLDivElement>) => {
102
+ const g = gesture.current;
103
+ if (!g || g.pointerId !== e.pointerId) return;
104
+ if (!g.moved && Math.abs(e.clientX - g.originClientX) < DRAG_THRESHOLD_PX) return;
105
+ g.moved = true;
106
+ const seconds = secondsAt(e.clientX);
107
+ if (seconds === g.last) return;
108
+ g.last = seconds;
109
+ setDraft({ edge: g.edge, seconds });
110
+ onSetElementAttributeLive?.(el, attrFor(g.edge), attrText(seconds));
111
+ };
112
+
113
+ type Gesture = NonNullable<typeof gesture.current>;
114
+
115
+ /** Ends the pointer gesture and returns it, or null when the event is not ours. */
116
+ const endGesture = (e: PointerEvent<HTMLDivElement>): Gesture | null => {
117
+ const g = gesture.current;
118
+ if (!g || g.pointerId !== e.pointerId) return null;
119
+ gesture.current = null;
120
+ setDragging(null);
121
+ if (e.currentTarget.hasPointerCapture(e.pointerId)) {
122
+ e.currentTarget.releasePointerCapture(e.pointerId);
123
+ }
124
+ return g;
125
+ };
126
+
127
+ /** Puts the live document back where the file has it and drops the draft. */
128
+ const revertGesture = (g: Gesture) => {
129
+ if (g.moved) onSetElementAttributeLive?.(el, attrFor(g.edge), attrText(g.originSeconds));
130
+ setDraft(null);
131
+ };
132
+
133
+ const finish = (e: PointerEvent<HTMLDivElement>, cancelled: boolean) => {
134
+ const g = endGesture(e);
135
+ if (!g) return;
136
+ if (cancelled || !g.moved) return revertGesture(g);
137
+ setDraft({ edge: g.edge, seconds: g.last });
138
+ void onSetElementAttributeQuiet?.(
139
+ el,
140
+ attrFor(g.edge),
141
+ attrText(g.last),
142
+ g.edge === "in" ? "Fade in" : "Fade out",
143
+ );
144
+ };
145
+
146
+ const onHandleKeyDown = (e: KeyboardEvent<HTMLDivElement>) => {
147
+ const g = gesture.current;
148
+ if (e.key !== "Escape" || !g) return;
149
+ e.preventDefault();
150
+ gesture.current = null;
151
+ setDragging(null);
152
+ revertGesture(g);
153
+ };
154
+
155
+ const showIn = fades.fadeIn > 0;
156
+ const showOut = fades.fadeOut > 0;
157
+ const handlesVisible = showHandles || dragging !== null;
158
+ if (!showIn && !showOut && !handlesVisible) return null;
159
+
160
+ const handleStyle = (leftPx: number): CSSProperties => ({
161
+ position: "absolute",
162
+ top: -(HANDLE_HIT - HANDLE_SIZE) / 2 + 1,
163
+ left: leftPx - HANDLE_HIT / 2,
164
+ width: HANDLE_HIT,
165
+ height: HANDLE_HIT,
166
+ display: "flex",
167
+ alignItems: "center",
168
+ justifyContent: "center",
169
+ cursor: "ew-resize",
170
+ zIndex: 6,
171
+ opacity: handlesVisible ? 1 : 0,
172
+ pointerEvents: handlesVisible && canEdit ? "auto" : "none",
173
+ touchAction: "none",
174
+ outline: "none",
175
+ });
176
+
177
+ return (
178
+ <>
179
+ {(showIn || showOut) && (
180
+ <svg
181
+ aria-hidden="true"
182
+ data-testid="clip-fade-ramps"
183
+ style={{
184
+ position: "absolute",
185
+ inset: 0,
186
+ width: "100%",
187
+ height: "100%",
188
+ pointerEvents: "none",
189
+ zIndex: 5,
190
+ overflow: "visible",
191
+ }}
192
+ viewBox={`0 0 ${Math.max(widthPx, 1)} 100`}
193
+ preserveAspectRatio="none"
194
+ >
195
+ {/* The shaded wedge is the gain that is NOT there: above the ramp. */}
196
+ {showIn && (
197
+ <>
198
+ <polygon
199
+ data-testid="clip-fade-in"
200
+ points={`0,0 ${inPx},0 0,100`}
201
+ fill="var(--timeline-fade-shade)"
202
+ />
203
+ <line
204
+ x1={0}
205
+ y1={100}
206
+ x2={inPx}
207
+ y2={0}
208
+ stroke="var(--clip-handle)"
209
+ strokeOpacity={0.9}
210
+ strokeWidth={1.25}
211
+ vectorEffect="non-scaling-stroke"
212
+ />
213
+ </>
214
+ )}
215
+ {showOut && (
216
+ <>
217
+ <polygon
218
+ data-testid="clip-fade-out"
219
+ points={`${widthPx - outPx},0 ${widthPx},0 ${widthPx},100`}
220
+ fill="var(--timeline-fade-shade)"
221
+ />
222
+ <line
223
+ x1={widthPx - outPx}
224
+ y1={0}
225
+ x2={widthPx}
226
+ y2={100}
227
+ stroke="var(--clip-handle)"
228
+ strokeOpacity={0.9}
229
+ strokeWidth={1.25}
230
+ vectorEffect="non-scaling-stroke"
231
+ />
232
+ </>
233
+ )}
234
+ </svg>
235
+ )}
236
+ {canEdit && (
237
+ <>
238
+ <div
239
+ role="slider"
240
+ tabIndex={-1}
241
+ aria-label="Fade in"
242
+ aria-valuemin={0}
243
+ aria-valuemax={Math.max(0, el.duration - fades.fadeOut)}
244
+ aria-valuenow={fades.fadeIn}
245
+ aria-valuetext={`${formatFadeSeconds(fades.fadeIn)}s`}
246
+ data-testid="clip-fade-handle-in"
247
+ title={`Fade in: ${formatFadeSeconds(fades.fadeIn)}s — drag to change`}
248
+ style={handleStyle(inPx)}
249
+ onPointerDown={onHandlePointerDown("in")}
250
+ onPointerMove={onHandlePointerMove}
251
+ onPointerUp={(e) => finish(e, false)}
252
+ onPointerCancel={(e) => finish(e, true)}
253
+ onKeyDown={onHandleKeyDown}
254
+ onClick={(e) => e.stopPropagation()}
255
+ onDoubleClick={(e) => e.stopPropagation()}
256
+ >
257
+ <FadeDot active={dragging === "in"} />
258
+ </div>
259
+ <div
260
+ role="slider"
261
+ tabIndex={-1}
262
+ aria-label="Fade out"
263
+ aria-valuemin={0}
264
+ aria-valuemax={Math.max(0, el.duration - fades.fadeIn)}
265
+ aria-valuenow={fades.fadeOut}
266
+ aria-valuetext={`${formatFadeSeconds(fades.fadeOut)}s`}
267
+ data-testid="clip-fade-handle-out"
268
+ title={`Fade out: ${formatFadeSeconds(fades.fadeOut)}s — drag to change`}
269
+ style={handleStyle(widthPx - outPx)}
270
+ onPointerDown={onHandlePointerDown("out")}
271
+ onPointerMove={onHandlePointerMove}
272
+ onPointerUp={(e) => finish(e, false)}
273
+ onPointerCancel={(e) => finish(e, true)}
274
+ onKeyDown={onHandleKeyDown}
275
+ onClick={(e) => e.stopPropagation()}
276
+ onDoubleClick={(e) => e.stopPropagation()}
277
+ >
278
+ <FadeDot active={dragging === "out"} />
279
+ </div>
280
+ </>
281
+ )}
282
+ </>
283
+ );
284
+ }
285
+
286
+ function FadeDot({ active }: { active: boolean }) {
287
+ return (
288
+ <span
289
+ aria-hidden="true"
290
+ style={{
291
+ display: "block",
292
+ width: HANDLE_SIZE,
293
+ height: HANDLE_SIZE,
294
+ borderRadius: "50%",
295
+ background: active ? "var(--timeline-fade-dot-active)" : "var(--clip-handle)",
296
+ boxShadow: "0 0 0 1.5px var(--timeline-fade-dot-ring)",
297
+ transform: active ? "scale(1.15)" : undefined,
298
+ transition: "transform 80ms ease-out",
299
+ }}
300
+ />
301
+ );
302
+ }
@@ -213,8 +213,8 @@ function SegmentEaseControl({
213
213
  zIndex: 3,
214
214
  pointerEvents: "auto",
215
215
  padding: 0,
216
- border: "1px solid rgba(255, 255, 255, 0.14)",
217
- background: "#171717",
216
+ border: "1px solid var(--timeline-diamond-border)",
217
+ background: "var(--timeline-diamond-bg)",
218
218
  cursor: "pointer",
219
219
  }}
220
220
  onPointerDown={(e) => {
@@ -18,7 +18,7 @@ export function TimelineEmptyState({
18
18
  }: TimelineEmptyStateProps) {
19
19
  return (
20
20
  <div
21
- className={`h-full border-t bg-[#0a0a0b] flex flex-col select-none transition-colors duration-150 ${
21
+ className={`h-full border-t bg-[var(--timeline-shell-bg)] flex flex-col select-none transition-colors duration-150 ${
22
22
  isDragOver ? "border-studio-accent/50 bg-studio-accent/3" : "border-neutral-800/50"
23
23
  }`}
24
24
  onDragOver={onDragOver}
@@ -79,7 +79,7 @@ function GroupNameDialog({
79
79
  <div
80
80
  role="dialog"
81
81
  aria-label="This track cannot be grouped"
82
- className="z-200 w-64 rounded-md border border-white/10 bg-[#1b1b1f] p-3 text-[11px] leading-snug text-white/75 shadow-xl"
82
+ className="z-200 w-64 rounded-md border border-[var(--timeline-tick-major)] bg-[var(--timeline-dialog-bg)] p-3 text-[11px] leading-snug text-[var(--timeline-text-soft)] shadow-xl"
83
83
  style={{ position: "fixed", ...groupDialogPosition(anchorRect) }}
84
84
  onPointerDown={(event) => event.stopPropagation()}
85
85
  onKeyDown={(event) => {
@@ -97,7 +97,7 @@ function GroupNameDialog({
97
97
  <div
98
98
  role="dialog"
99
99
  aria-label="Name this group"
100
- className="z-200 w-64 rounded-md border border-white/10 bg-[#1b1b1f] p-3 text-[11px] text-white/75 shadow-xl"
100
+ className="z-200 w-64 rounded-md border border-[var(--timeline-tick-major)] bg-[var(--timeline-dialog-bg)] p-3 text-[11px] text-[var(--timeline-text-soft)] shadow-xl"
101
101
  style={{ position: "fixed", ...groupDialogPosition(anchorRect) }}
102
102
  onPointerDown={(event) => event.stopPropagation()}
103
103
  onKeyDown={(event) => {
@@ -108,14 +108,14 @@ function GroupNameDialog({
108
108
  if (event.key === "Enter") confirm();
109
109
  }}
110
110
  >
111
- <p className="mb-1.5 font-medium text-white">Name this group</p>
111
+ <p className="mb-1.5 font-medium text-[var(--timeline-text-solid)]">Name this group</p>
112
112
  <input
113
113
  ref={inputRef}
114
114
  type="text"
115
115
  aria-label="Group name"
116
116
  value={label}
117
117
  onChange={(event) => setLabel(event.currentTarget.value)}
118
- className="w-full rounded-sm border border-white/20 bg-black/30 px-1.5 py-1 text-[11px] text-white outline-hidden focus:border-[#3CE6AC]"
118
+ className="w-full rounded-sm border border-[var(--timeline-border-strong)] bg-[var(--timeline-input-bg)] px-1.5 py-1 text-[11px] text-[var(--timeline-text-solid)] outline-hidden focus:border-[var(--timeline-accent)]"
119
119
  />
120
120
  {/* The sentence. No jargon, and it names both things a bus does. */}
121
121
  <p className="mt-2 leading-snug">
@@ -125,14 +125,14 @@ function GroupNameDialog({
125
125
  <div className="mt-2.5 flex justify-end gap-1.5">
126
126
  <button
127
127
  type="button"
128
- className="rounded-sm border border-white/20 px-2 py-1 text-[10px] text-white/75 hover:bg-white/10"
128
+ className="rounded-sm border border-[var(--timeline-border-strong)] px-2 py-1 text-[10px] text-[var(--timeline-text-soft)] hover:bg-[var(--timeline-tick-major)]"
129
129
  onClick={onCancel}
130
130
  >
131
131
  Cancel
132
132
  </button>
133
133
  <button
134
134
  type="button"
135
- className="rounded-sm border border-[#3CE6AC] bg-[#3CE6AC]/15 px-2 py-1 text-[10px] font-semibold text-[#3CE6AC] hover:bg-[#3CE6AC]/25"
135
+ className="rounded-sm border border-[var(--timeline-accent)] bg-[var(--timeline-accent-button-bg)] px-2 py-1 text-[10px] font-semibold text-[var(--timeline-accent)] hover:bg-[var(--timeline-accent-hover)]"
136
136
  onClick={confirm}
137
137
  >
138
138
  Group
@@ -212,7 +212,7 @@ export function TimelineFxButton(props: TimelineFxButtonProps) {
212
212
  ref={buttonRef}
213
213
  aria-label="Effects — group these clips first"
214
214
  title="Group these clips to add effects to all of them"
215
- className="flex h-6 items-center justify-center rounded-sm border-0 bg-transparent px-1 text-[10px] font-semibold text-white/35 hover:text-white/75"
215
+ className="flex h-6 items-center justify-center rounded-sm border-0 bg-transparent px-1 text-[10px] font-semibold text-[var(--timeline-text-faint)] hover:text-[var(--timeline-text-soft)]"
216
216
  onPointerDown={(event) => event.stopPropagation()}
217
217
  onClick={(event) => {
218
218
  event.stopPropagation();
@@ -253,7 +253,9 @@ export function TimelineFxButton(props: TimelineFxButtonProps) {
253
253
  aria-label={nodeCount > 0 ? `Effects — ${nodeCount} applied` : "Effects"}
254
254
  title="Effects"
255
255
  className={`flex h-6 items-center justify-center gap-0.5 rounded border-0 bg-transparent px-1 text-[10px] font-semibold transition-colors ${
256
- open || nodeCount > 0 ? "text-[#3CE6AC]" : "text-white/35 hover:text-white/75"
256
+ open || nodeCount > 0
257
+ ? "text-[var(--timeline-accent)]"
258
+ : "text-[var(--timeline-text-faint)] hover:text-[var(--timeline-text-soft)]"
257
259
  }`}
258
260
  onPointerDown={(event) => event.stopPropagation()}
259
261
  onClick={(event) => {