Skip to content

Commit 9bd6da8

Browse files
feat(studio): theme timeline colours with CSS tokens (#4211)
* feat(studio): the timeline's colours read CSS custom properties instead of literals The timeline's surfaces, hairlines, ruler text and clip colours were hard-coded hex/rgba, so a host with a light chrome saw a black slab. The 24 values move into new --timeline-* tokens in theme.css (the same mechanism Button and Menu already use), holding today's exact values, so a host themes the timeline by overriding a token instead of the object staying opaque. * fix(studio): route timeline clip colours through theme tokens * chore(studio): bank the colour-literal baseline * fix(studio): preserve timeline clip token defaults * fix(studio): increase default timeline clip contrast * fix(studio): keep timeline hover brighter * test(studio): stabilize property panel flag coverage
1 parent 96369c8 commit 9bd6da8

11 files changed

Lines changed: 175 additions & 69 deletions

‎packages/studio/src/components/editor/propertyPanelInputCoverage.test.tsx‎

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -459,12 +459,7 @@ function representativeElement() {
459459
describe("classic PropertyPanel input coverage", () => {
460460
it("emits only named, known-section events across body inputs and header/footer chrome", async () => {
461461
vi.resetModules();
462-
vi.doMock("./manualEditingAvailability", async () => {
463-
const actual = await vi.importActual<typeof import("./manualEditingAvailability")>(
464-
"./manualEditingAvailability",
465-
);
466-
return { ...actual, STUDIO_FLAT_INSPECTOR_ENABLED: false };
467-
});
462+
vi.doMock("./manualEditingAvailability", () => ({ STUDIO_FLAT_INSPECTOR_ENABLED: false }));
468463
const { PropertyPanel } = await import("./PropertyPanel");
469464
const host = render(
470465
<PropertyPanel
@@ -524,18 +519,13 @@ describe("classic PropertyPanel input coverage", () => {
524519
expect(sections.has("header")).toBe(true);
525520
expect(sections.has("footer")).toBe(true);
526521
expect(sections.size).toBeGreaterThan(2);
527-
});
522+
}, 15000);
528523
});
529524

530525
describe("flat PropertyPanel input coverage", () => {
531526
it("emits only named flat events from known sections for every visible layout input", async () => {
532527
vi.resetModules();
533-
vi.doMock("./manualEditingAvailability", async () => {
534-
const actual = await vi.importActual<typeof import("./manualEditingAvailability")>(
535-
"./manualEditingAvailability",
536-
);
537-
return { ...actual, STUDIO_FLAT_INSPECTOR_ENABLED: true };
538-
});
528+
vi.doMock("./manualEditingAvailability", () => ({ STUDIO_FLAT_INSPECTOR_ENABLED: true }));
539529
const { PropertyPanel } = await import("./PropertyPanel");
540530
const host = render(
541531
<PropertyPanel

‎packages/studio/src/player/components/TimelineClip.test.tsx‎

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { afterEach, describe, expect, it, vi } from "vitest";
66
import type { TimelineElement } from "../store/playerStore";
77
import { TimelineClip } from "./TimelineClip";
88
import type { TimelineEditCapabilities } from "./timelineEditing";
9+
import { defaultTimelineTheme, type TimelineTheme } from "./timelineTheme";
910

1011
Object.defineProperty(globalThis, "IS_REACT_ACT_ENVIRONMENT", {
1112
configurable: true,
@@ -27,11 +28,13 @@ function renderClip({
2728
pps = 100,
2829
isSelected = false,
2930
hasCustomContent = true,
31+
theme = defaultTimelineTheme,
3032
}: {
3133
element: TimelineElement;
3234
pps?: number;
3335
isSelected?: boolean;
3436
hasCustomContent?: boolean;
37+
theme?: TimelineTheme;
3538
}) {
3639
const host = document.createElement("div");
3740
document.body.append(host);
@@ -48,6 +51,7 @@ function renderClip({
4851
isHovered={false}
4952
hasCustomContent={hasCustomContent}
5053
capabilities={capabilities}
54+
theme={theme}
5155
isComposition={false}
5256
onHoverStart={vi.fn()}
5357
onHoverEnd={vi.fn()}
@@ -115,6 +119,54 @@ describe("TimelineClip", () => {
115119
act(() => root.unmount());
116120
});
117121

122+
it("passes clip and handle theme tokens to the rendered elements", () => {
123+
const theme: TimelineTheme = {
124+
...defaultTimelineTheme,
125+
clipBackground: "var(--test-clip-bg)",
126+
clipBackgroundActive: "var(--test-clip-bg-active)",
127+
clipBackgroundHover: "var(--test-clip-bg-hover)",
128+
clipBackgroundDragging: "var(--test-clip-bg-dragging)",
129+
clipBorder: "var(--test-clip-border)",
130+
clipBorderHover: "var(--test-clip-border-hover)",
131+
clipBorderActive: "var(--test-clip-border-active)",
132+
handleColor: "var(--test-handle)",
133+
};
134+
const { host, root } = renderClip({
135+
element: { id: "themed", label: "Themed", tag: "div", start: 0, duration: 1, track: 0 },
136+
isSelected: true,
137+
theme,
138+
});
139+
const clip = host.querySelector<HTMLElement>(".timeline-clip")!;
140+
expect(clip.style.getPropertyValue("--clip-bg")).toBe("var(--test-clip-bg)");
141+
expect(clip.style.getPropertyValue("--clip-border-active")).toBe(
142+
"var(--test-clip-border-active)",
143+
);
144+
expect(clip.style.getPropertyValue("--clip-handle")).toBe("var(--test-handle)");
145+
expect(clip.querySelector<HTMLElement>(".timeline-clip__handle-bar")?.style.background).toBe(
146+
"var(--clip-handle)",
147+
);
148+
act(() => root.unmount());
149+
});
150+
151+
it("keeps default token references off the properties they resolve", () => {
152+
const { host, root } = renderClip({
153+
element: {
154+
id: "default-theme",
155+
label: "Default",
156+
tag: "div",
157+
start: 0,
158+
duration: 1,
159+
track: 0,
160+
},
161+
isSelected: true,
162+
});
163+
const clip = host.querySelector<HTMLElement>(".timeline-clip")!;
164+
expect(clip.style.getPropertyValue("--clip-bg")).toBe("var(--timeline-clip-bg)");
165+
expect(clip.style.getPropertyValue("--clip-bg")).not.toBe("var(--clip-bg)");
166+
expect(clip.style.getPropertyValue("--clip-handle")).toBe("var(--timeline-handle)");
167+
act(() => root.unmount());
168+
});
169+
118170
it("is a roving native button with explicit selection semantics", () => {
119171
const { host, onClick, root } = renderClip({
120172
element: { id: "hero", label: "Hero", tag: "div", start: 1, duration: 2, track: 0 },

‎packages/studio/src/player/components/TimelineClip.tsx‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,16 @@ export const TimelineClip = memo(function TimelineClip({
6464
const showDefaultText = !hasCustomContent && (widthPx >= 40 || isSelected);
6565
const startLabel = el.start.toFixed(1);
6666
const endLabel = (el.start + el.duration).toFixed(1);
67+
const themeVariables = {
68+
"--clip-bg": theme.clipBackground,
69+
"--clip-bg-active": theme.clipBackgroundActive,
70+
"--clip-bg-hover": theme.clipBackgroundHover,
71+
"--clip-bg-dragging": theme.clipBackgroundDragging,
72+
"--clip-border": theme.clipBorder,
73+
"--clip-border-hover": theme.clipBorderHover,
74+
"--clip-border-active": theme.clipBorderActive,
75+
"--clip-handle": theme.handleColor,
76+
} as CSSProperties;
6777
const clipClassName = [
6878
"timeline-clip",
6979
"absolute",
@@ -81,6 +91,7 @@ export const TimelineClip = memo(function TimelineClip({
8191
top: clipY,
8292
...(clipHeight === undefined ? { bottom: clipY } : { height: clipHeight }),
8393
borderRadius: theme.clipRadius,
94+
...themeVariables,
8495
zIndex: isDragging ? 20 : isSelected ? 10 : isHovered ? 5 : 1,
8596
// Regular cursor over clips (CapCut-style, user preference) — no grab hand.
8697
cursor: "default",
@@ -144,7 +155,7 @@ export const TimelineClip = memo(function TimelineClip({
144155
bottom: 6,
145156
width: 2,
146157
borderRadius: 1,
147-
background: "rgba(255, 255, 255, 0.55)",
158+
background: "var(--clip-handle)",
148159
opacity: handleOpacity * 0.6,
149160
}}
150161
/>
@@ -174,7 +185,7 @@ export const TimelineClip = memo(function TimelineClip({
174185
bottom: 6,
175186
width: 2,
176187
borderRadius: 1,
177-
background: "rgba(255, 255, 255, 0.55)",
188+
background: "var(--clip-handle)",
178189
opacity: handleOpacity * 0.6,
179190
}}
180191
/>

‎packages/studio/src/player/components/TimelineTrackHeader.test.tsx‎

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { createRoot, type Root } from "react-dom/client";
55
import type { GsapAnimation, PropertyGroupName } from "@hyperframes/core/gsap-parser";
66
import { afterEach, describe, expect, it, vi } from "vitest";
77
import { TimelinePropertyLanes } from "./TimelinePropertyLanes";
8-
import { TimelineTrackHeader } from "./TimelineTrackHeader";
8+
import { TimelineTrackHeader, gutterFill } from "./TimelineTrackHeader";
99
import { defaultTimelineTheme } from "./timelineTheme";
1010
import { type TimelineElement } from "../store/playerStore";
1111
import type { TimelineEditCallbacks } from "./timelineCallbacks";
@@ -794,10 +794,6 @@ describe("TimelineTrackHeader", () => {
794794
});
795795
expect(header()?.style.paddingLeft).toBe("14px");
796796
expect(header()?.style.borderLeft).toContain("2px");
797-
// And a lighter gutter, so the row reads as sitting INSIDE its group
798-
// rather than beside it. Overlaid on the theme's own fill rather than a
799-
// hard-coded colour, so it follows whatever the gutter is.
800-
expect(header()?.style.background).toContain("linear-gradient");
801797
act(() => view.root.unmount());
802798
});
803799

@@ -912,3 +908,28 @@ describe("TimelineTrackHeader", () => {
912908
});
913909
});
914910
});
911+
912+
// A host themes the timeline by overriding --timeline-* on theme.css, so the
913+
// rendered gutter must carry the CSS variable, not a baked-in colour.
914+
describe("theming", () => {
915+
it("reads the gutter background and border from timeline theme tokens", () => {
916+
const view = renderHeader({});
917+
const header = view.host.querySelector<HTMLElement>('[role="rowheader"]');
918+
expect(header?.style.background).toBe(defaultTimelineTheme.gutterBackground);
919+
expect(header?.style.background).toContain("var(--timeline-gutter-bg)");
920+
expect(header?.style.borderRight).toContain(defaultTimelineTheme.gutterBorder);
921+
act(() => view.root.unmount());
922+
});
923+
924+
// happy-dom's `background` shorthand garbles a `var()` layer next to
925+
// `linear-gradient(...)` (verified), so this checks the same value through
926+
// the pure function instead of the broken CSSOM roundtrip.
927+
it("overlays the group-member tint on the themed gutter, not a hard-coded colour", () => {
928+
const filled = gutterFill(defaultTimelineTheme.gutterBackground, true);
929+
expect(filled).toContain("linear-gradient");
930+
expect(filled.endsWith(defaultTimelineTheme.gutterBackground)).toBe(true);
931+
expect(gutterFill(defaultTimelineTheme.gutterBackground, false)).toBe(
932+
defaultTimelineTheme.gutterBackground,
933+
);
934+
});
935+
});

‎packages/studio/src/player/components/TimelineTrackHeader.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const GROUP_MEMBER_INDENT = 14;
3434
const GROUP_MEMBER_TINT = "rgba(255,255,255,0.035)";
3535

3636
/** The gutter fill for a row, tinted when it belongs to a group. */
37-
function gutterFill(base: string, isGroupMember: boolean): string {
37+
export function gutterFill(base: string, isGroupMember: boolean): string {
3838
return isGroupMember
3939
? `linear-gradient(${GROUP_MEMBER_TINT}, ${GROUP_MEMBER_TINT}), ${base}`
4040
: base;

‎packages/studio/src/player/components/timelineMotionStyles.test.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@ describe("timeline motion styles", () => {
7575
const bloomOverlayRule = expectRule(studioCss, ".timeline-clip::before");
7676
const activeBloomOverlayRule = expectRule(studioCss, ".timeline-clip[data-active]::before");
7777

78-
expect(baseTimelineClipRule).toContain("background-color: rgba(255, 255, 255, 0.055)");
78+
expect(baseTimelineClipRule).toContain("background-color: var(--clip-bg)");
7979
expect(activeTimelineClipRule).not.toContain("background: linear-gradient");
80-
expect(activeTimelineClipRule).toContain("border-color: rgba(60, 230, 172, 0.55)");
80+
expect(activeTimelineClipRule).toContain("border-color: var(--clip-border-active)");
8181
expect(activeTimelineClipRule).not.toContain("box-shadow");
82-
expect(bloomOverlayRule).toContain("background: rgba(60, 230, 172, 0.2)");
82+
expect(bloomOverlayRule).toContain("background: var(--clip-bg-active)");
8383
expect(bloomOverlayRule).not.toContain("linear-gradient");
8484
expect(bloomOverlayRule).toContain("opacity: 0");
8585
expect(activeBloomOverlayRule).toContain("opacity: 1");

‎packages/studio/src/player/components/timelineTheme.test.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ import { getTrackStyle } from "./timelineIcons";
99
describe("getTimelineTrackStyle", () => {
1010
it("uses one neutral clip style for every timeline tag", () => {
1111
const expectedStyle = {
12-
clip: "rgba(255,255,255,0.055)",
13-
clipActive: "rgba(60,230,172,0.16)",
14-
accent: "#3CE6AC",
15-
label: "rgba(255,255,255,0.5)",
12+
clip: "var(--timeline-track-clip-fill)",
13+
clipActive: "var(--timeline-track-clip-active)",
14+
accent: "var(--color-accent)",
15+
label: "var(--timeline-track-label)",
1616
};
1717

1818
expect(getTimelineTrackStyle("video")).toEqual(expectedStyle);

‎packages/studio/src/player/components/timelineTheme.ts‎

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ export interface TimelineTheme {
2222
tickMinor: string;
2323
clipBackground: string;
2424
clipBackgroundActive: string;
25+
clipBackgroundHover: string;
26+
clipBackgroundDragging: string;
2527
clipBorder: string;
2628
clipBorderHover: string;
2729
clipBorderActive: string;
@@ -36,43 +38,45 @@ export interface TimelineTheme {
3638
}
3739

3840
const TRACK_STYLE: TimelineTrackStyle = {
39-
clip: "rgba(255,255,255,0.055)",
40-
clipActive: "rgba(60,230,172,0.16)",
41-
accent: "#3CE6AC",
42-
label: "rgba(255,255,255,0.5)",
41+
clip: "var(--timeline-track-clip-fill)",
42+
clipActive: "var(--timeline-track-clip-active)",
43+
accent: "var(--color-accent)",
44+
label: "var(--timeline-track-label)",
4345
};
4446

47+
// Every field reads a CSS custom property (declared in styles/theme.css)
48+
// rather than a literal, so a host themes the timeline the same way it
49+
// themes the rest of Studio: by overriding the token, not this object.
4550
export const defaultTimelineTheme: TimelineTheme = {
46-
// Near-black card surfaces: the panels sit dark while the shell canvas
47-
// between them is a step LIGHTER (#18181B), so the gaps read as visible
48-
// seams around dark cards (CapCut-style).
49-
shellBackground: "#0A0A0B",
50-
shellBorder: "rgba(255,255,255,0.05)",
51-
rulerBorder: "rgba(255,255,255,0.16)",
52-
// All track lanes use a single uniform color — one step lighter than the panel
53-
// surface (#0A0A0B) so lanes are visibly distinct from the ruler/shell.
54-
rowBackground: "#101014",
55-
rowBorder: "rgba(255,255,255,0.06)",
56-
gutterBackground: "#0E0F12",
57-
gutterBorder: "rgba(255,255,255,0.10)",
58-
textPrimary: "rgba(255,255,255,0.92)",
59-
textSecondary: "rgba(255,255,255,0.62)",
60-
tickText: "rgba(255,255,255,0.34)",
61-
tickMajor: "rgba(255,255,255,0.10)",
62-
tickMinor: "rgba(255,255,255,0.06)",
63-
clipBackground: "#141922",
64-
clipBackgroundActive: "#181e28",
65-
clipBorder: "rgba(255,255,255,0.10)",
66-
clipBorderHover: "rgba(255,255,255,0.18)",
67-
clipBorderActive: "rgba(255,255,255,0.24)",
51+
shellBackground: "var(--timeline-shell-bg)",
52+
shellBorder: "var(--timeline-shell-border)",
53+
rulerBorder: "var(--timeline-ruler-border)",
54+
rowBackground: "var(--timeline-row-bg)",
55+
rowBorder: "var(--timeline-row-border)",
56+
gutterBackground: "var(--timeline-gutter-bg)",
57+
gutterBorder: "var(--timeline-gutter-border)",
58+
textPrimary: "var(--timeline-text-primary)",
59+
textSecondary: "var(--timeline-text-secondary)",
60+
tickText: "var(--timeline-tick-text)",
61+
tickMajor: "var(--timeline-tick-major)",
62+
tickMinor: "var(--timeline-tick-minor)",
63+
clipBackground: "var(--timeline-clip-bg)",
64+
clipBackgroundActive: "var(--timeline-clip-bg-active)",
65+
clipBackgroundHover: "var(--timeline-clip-bg-hover)",
66+
clipBackgroundDragging: "var(--timeline-clip-bg-dragging)",
67+
clipBorder: "var(--timeline-clip-border)",
68+
clipBorderHover: "var(--timeline-clip-border-hover)",
69+
clipBorderActive: "var(--timeline-clip-border-active)",
70+
// Shadows stay literal: a light host still wants a dark contact shadow, so
71+
// these are not part of the surface/hairline/text/clip-colour theming ask.
6872
clipShadow: "none",
6973
clipShadowHover: "0 2px 8px rgba(0,0,0,0.2)",
7074
clipShadowActive: "0 2px 8px rgba(0,0,0,0.2), 0 0 0 1px rgba(255,255,255,0.04)",
7175
clipShadowDragging: "0 8px 24px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.06)",
72-
handleColor: "rgba(255,255,255,0.2)",
73-
panelResizeSeam: "rgba(255,255,255,0.12)",
74-
panelResizeActive: "rgba(255,255,255,0.24)",
75-
clipRadius: "8px",
76+
handleColor: "var(--timeline-handle)",
77+
panelResizeSeam: "var(--timeline-resize-seam)",
78+
panelResizeActive: "var(--timeline-resize-active)",
79+
clipRadius: "var(--radius-lg)",
7680
};
7781

7882
export function getTimelineTrackStyle(_tag: string): TimelineTrackStyle {

‎packages/studio/src/styles/hex-baseline.json‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"total": 418,
2+
"total": 385,
33
"files": {
44
"packages/studio/src/captions/components/CaptionOverlay.tsx": 5,
55
"packages/studio/src/captions/components/CaptionTimeline.tsx": 11,
@@ -61,7 +61,6 @@
6161
"packages/studio/src/player/components/SpeedMenu.tsx": 2,
6262
"packages/studio/src/player/components/TimelineAutomationLane.tsx": 4,
6363
"packages/studio/src/player/components/TimelineCanvas.tsx": 13,
64-
"packages/studio/src/player/components/TimelineClip.tsx": 2,
6564
"packages/studio/src/player/components/TimelineClipDiamonds.tsx": 2,
6665
"packages/studio/src/player/components/TimelineDiamondConnectors.tsx": 2,
6766
"packages/studio/src/player/components/TimelineEmptyState.tsx": 1,
@@ -75,9 +74,9 @@
7574
"packages/studio/src/player/components/TimelineTrackHeader.tsx": 2,
7675
"packages/studio/src/player/components/TimelineTrackPlainHeader.tsx": 2,
7776
"packages/studio/src/player/components/VideoThumbnail.tsx": 6,
78-
"packages/studio/src/player/components/timelineTheme.ts": 29,
77+
"packages/studio/src/player/components/timelineTheme.ts": 5,
7978
"packages/studio/src/player/components/trackHeaderLabelRows.tsx": 6,
80-
"packages/studio/src/styles/studio.css": 70,
79+
"packages/studio/src/styles/studio.css": 63,
8180
"packages/studio/src/telemetry/client.ts": 1,
8281
"packages/studio/src/webmcp/webmcpTestUtils.ts": 1
8382
}

0 commit comments

Comments
 (0)