Write HTML. Render video. Built for agents.
JavaScript aiai-agentsanimationclaude-codeffmpegframeworkgsaphtmlhtml-to-videomcpmotion-graphicspuppeteerrenderingtypescriptvideo-editor
feat(studio): theme timeline colours with CSS tokens (#4211)
Miguel Ángel9bd6da848fb3
diff --git a/packages/studio/src/components/editor/propertyPanelInputCoverage.test.tsx b/packages/studio/src/components/editor/propertyPanelInputCoverage.test.tsxindex 116a2cb3d4..a1837e4247 100644--- a/packages/studio/src/components/editor/propertyPanelInputCoverage.test.tsx+++ b/packages/studio/src/components/editor/propertyPanelInputCoverage.test.tsx@@ -459,12 +459,7 @@ function representativeElement() {describe("classic PropertyPanel input coverage", () => {it("emits only named, known-section events across body inputs and header/footer chrome", async () => {vi.resetModules();- vi.doMock("./manualEditingAvailability", async () => {- const actual = await vi.importActual<typeof import("./manualEditingAvailability")>(- "./manualEditingAvailability",- );- return { ...actual, STUDIO_FLAT_INSPECTOR_ENABLED: false };- });+ vi.doMock("./manualEditingAvailability", () => ({ STUDIO_FLAT_INSPECTOR_ENABLED: false }));const { PropertyPanel } = await import("./PropertyPanel");const host = render(<PropertyPanel@@ -524,18 +519,13 @@ describe("classic PropertyPanel input coverage", () => {expect(sections.has("header")).toBe(true);expect(sections.has("footer")).toBe(true);expect(sections.size).toBeGreaterThan(2);- });+ }, 15000);});describe("flat PropertyPanel input coverage", () => {it("emits only named flat events from known sections for every visible layout input", async () => {vi.resetModules();- vi.doMock("./manualEditingAvailability", async () => {- const actual = await vi.importActual<typeof import("./manualEditingAvailability")>(- "./manualEditingAvailability",- );- return { ...actual, STUDIO_FLAT_INSPECTOR_ENABLED: true };- });+ vi.doMock("./manualEditingAvailability", () => ({ STUDIO_FLAT_INSPECTOR_ENABLED: true }));const { PropertyPanel } = await import("./PropertyPanel");const host = render(<PropertyPaneldiff --git a/packages/studio/src/player/components/TimelineClip.test.tsx b/packages/studio/src/player/components/TimelineClip.test.tsxindex c5c0ec5be4..75038954ca 100644--- a/packages/studio/src/player/components/TimelineClip.test.tsx+++ b/packages/studio/src/player/components/TimelineClip.test.tsx@@ -6,6 +6,7 @@ import { afterEach, describe, expect, it, vi } from "vitest";import type { TimelineElement } from "../store/playerStore";import { TimelineClip } from "./TimelineClip";import type { TimelineEditCapabilities } from "./timelineEditing";+import { defaultTimelineTheme, type TimelineTheme } from "./timelineTheme";Object.defineProperty(globalThis, "IS_REACT_ACT_ENVIRONMENT", {configurable: true,@@ -27,11 +28,13 @@ function renderClip({pps = 100,isSelected = false,hasCustomContent = true,+ theme = defaultTimelineTheme,}: {element: TimelineElement;pps?: number;isSelected?: boolean;hasCustomContent?: boolean;+ theme?: TimelineTheme;}) {const host = document.createElement("div");document.body.append(host);@@ -48,6 +51,7 @@ function renderClip({isHovered={false}hasCustomContent={hasCustomContent}capabilities={capabilities}+ theme={theme}isComposition={false}onHoverStart={vi.fn()}onHoverEnd={vi.fn()}@@ -115,6 +119,54 @@ describe("TimelineClip", () => {act(() => root.unmount());});+ it("passes clip and handle theme tokens to the rendered elements", () => {+ const theme: TimelineTheme = {+ ...defaultTimelineTheme,+ clipBackground: "var(--test-clip-bg)",+ clipBackgroundActive: "var(--test-clip-bg-active)",+ clipBackgroundHover: "var(--test-clip-bg-hover)",+ clipBackgroundDragging: "var(--test-clip-bg-dragging)",+ clipBorder: "var(--test-clip-border)",+ clipBorderHover: "var(--test-clip-border-hover)",+ clipBorderActive: "var(--test-clip-border-active)",+ handleColor: "var(--test-handle)",+ };+ const { host, root } = renderClip({+ element: { id: "themed", label: "Themed", tag: "div", start: 0, duration: 1, track: 0 },+ isSelected: true,+ theme,+ });+ const clip = host.querySelector<HTMLElement>(".timeline-clip")!;+ expect(clip.style.getPropertyValue("--clip-bg")).toBe("var(--test-clip-bg)");+ expect(clip.style.getPropertyValue("--clip-border-active")).toBe(+ "var(--test-clip-border-active)",+ );+ expect(clip.style.getPropertyValue("--clip-handle")).toBe("var(--test-handle)");+ expect(clip.querySelector<HTMLElement>(".timeline-clip__handle-bar")?.style.background).toBe(+ "var(--clip-handle)",+ );+ act(() => root.unmount());+ });++ it("keeps default token references off the properties they resolve", () => {+ const { host, root } = renderClip({+ element: {+ id: "default-theme",+ label: "Default",+ tag: "div",+ start: 0,+ duration: 1,+ track: 0,+ },+ isSelected: true,+ });+ const clip = host.querySelector<HTMLElement>(".timeline-clip")!;+ expect(clip.style.getPropertyValue("--clip-bg")).toBe("var(--timeline-clip-bg)");+ expect(clip.style.getPropertyValue("--clip-bg")).not.toBe("var(--clip-bg)");+ expect(clip.style.getPropertyValue("--clip-handle")).toBe("var(--timeline-handle)");+ act(() => root.unmount());+ });+it("is a roving native button with explicit selection semantics", () => {const { host, onClick, root } = renderClip({element: { id: "hero", label: "Hero", tag: "div", start: 1, duration: 2, track: 0 },diff --git a/packages/studio/src/player/components/TimelineClip.tsx b/packages/studio/src/player/components/TimelineClip.tsxindex 696746aff1..0012003be3 100644--- a/packages/studio/src/player/components/TimelineClip.tsx+++ b/packages/studio/src/player/components/TimelineClip.tsx@@ -64,6 +64,16 @@ export const TimelineClip = memo(function TimelineClip({const showDefaultText = !hasCustomContent && (widthPx >= 40 || isSelected);const startLabel = el.start.toFixed(1);const endLabel = (el.start + el.duration).toFixed(1);+ const themeVariables = {+ "--clip-bg": theme.clipBackground,+ "--clip-bg-active": theme.clipBackgroundActive,+ "--clip-bg-hover": theme.clipBackgroundHover,+ "--clip-bg-dragging": theme.clipBackgroundDragging,+ "--clip-border": theme.clipBorder,+ "--clip-border-hover": theme.clipBorderHover,+ "--clip-border-active": theme.clipBorderActive,+ "--clip-handle": theme.handleColor,+ } as CSSProperties;const clipClassName = ["timeline-clip","absolute",@@ -81,6 +91,7 @@ export const TimelineClip = memo(function TimelineClip({top: clipY,...(clipHeight === undefined ? { bottom: clipY } : { height: clipHeight }),borderRadius: theme.clipRadius,+ ...themeVariables,zIndex: isDragging ? 20 : isSelected ? 10 : isHovered ? 5 : 1,// Regular cursor over clips (CapCut-style, user preference) — no grab hand.cursor: "default",@@ -144,7 +155,7 @@ export const TimelineClip = memo(function TimelineClip({bottom: 6,width: 2,borderRadius: 1,- background: "rgba(255, 255, 255, 0.55)",+ background: "var(--clip-handle)",opacity: handleOpacity * 0.6,}}/>@@ -174,7 +185,7 @@ export const TimelineClip = memo(function TimelineClip({bottom: 6,width: 2,borderRadius: 1,- background: "rgba(255, 255, 255, 0.55)",+ background: "var(--clip-handle)",opacity: handleOpacity * 0.6,}}/>diff --git a/packages/studio/src/player/components/TimelineTrackHeader.test.tsx b/packages/studio/src/player/components/TimelineTrackHeader.test.tsxindex 396480d677..a8f6da7ead 100644--- a/packages/studio/src/player/components/TimelineTrackHeader.test.tsx+++ b/packages/studio/src/player/components/TimelineTrackHeader.test.tsx@@ -5,7 +5,7 @@ import { createRoot, type Root } from "react-dom/client";import type { GsapAnimation, PropertyGroupName } from "@hyperframes/core/gsap-parser";import { afterEach, describe, expect, it, vi } from "vitest";import { TimelinePropertyLanes } from "./TimelinePropertyLanes";-import { TimelineTrackHeader } from "./TimelineTrackHeader";+import { TimelineTrackHeader, gutterFill } from "./TimelineTrackHeader";import { defaultTimelineTheme } from "./timelineTheme";import { type TimelineElement } from "../store/playerStore";import type { TimelineEditCallbacks } from "./timelineCallbacks";@@ -794,10 +794,6 @@ describe("TimelineTrackHeader", () => {});expect(header()?.style.paddingLeft).toBe("14px");expect(header()?.style.borderLeft).toContain("2px");- // And a lighter gutter, so the row reads as sitting INSIDE its group- // rather than beside it. Overlaid on the theme's own fill rather than a- // hard-coded colour, so it follows whatever the gutter is.- expect(header()?.style.background).toContain("linear-gradient");act(() => view.root.unmount());});@@ -912,3 +908,28 @@ describe("TimelineTrackHeader", () => {});});});++// A host themes the timeline by overriding --timeline-* on theme.css, so the+// rendered gutter must carry the CSS variable, not a baked-in colour.+describe("theming", () => {+ it("reads the gutter background and border from timeline theme tokens", () => {+ const view = renderHeader({});+ const header = view.host.querySelector<HTMLElement>('[role="rowheader"]');+ expect(header?.style.background).toBe(defaultTimelineTheme.gutterBackground);+ expect(header?.style.background).toContain("var(--timeline-gutter-bg)");+ expect(header?.style.borderRight).toContain(defaultTimelineTheme.gutterBorder);+ act(() => view.root.unmount());+ });++ // happy-dom's `background` shorthand garbles a `var()` layer next to+ // `linear-gradient(...)` (verified), so this checks the same value through+ // the pure function instead of the broken CSSOM roundtrip.+ it("overlays the group-member tint on the themed gutter, not a hard-coded colour", () => {+ const filled = gutterFill(defaultTimelineTheme.gutterBackground, true);+ expect(filled).toContain("linear-gradient");+ expect(filled.endsWith(defaultTimelineTheme.gutterBackground)).toBe(true);+ expect(gutterFill(defaultTimelineTheme.gutterBackground, false)).toBe(+ defaultTimelineTheme.gutterBackground,+ );+ });+});diff --git a/packages/studio/src/player/components/TimelineTrackHeader.tsx b/packages/studio/src/player/components/TimelineTrackHeader.tsxindex f743dac025..ced3683eb3 100644--- a/packages/studio/src/player/components/TimelineTrackHeader.tsx+++ b/packages/studio/src/player/components/TimelineTrackHeader.tsx@@ -34,7 +34,7 @@ const GROUP_MEMBER_INDENT = 14;const GROUP_MEMBER_TINT = "rgba(255,255,255,0.035)";/** The gutter fill for a row, tinted when it belongs to a group. */-function gutterFill(base: string, isGroupMember: boolean): string {+export function gutterFill(base: string, isGroupMember: boolean): string {return isGroupMember? `linear-gradient(${GROUP_MEMBER_TINT}, ${GROUP_MEMBER_TINT}), ${base}`: base;diff --git a/packages/studio/src/player/components/timelineMotionStyles.test.ts b/packages/studio/src/player/components/timelineMotionStyles.test.tsindex 0ec02c3e65..e49b1d9505 100644--- a/packages/studio/src/player/components/timelineMotionStyles.test.ts+++ b/packages/studio/src/player/components/timelineMotionStyles.test.ts@@ -75,11 +75,11 @@ describe("timeline motion styles", () => {const bloomOverlayRule = expectRule(studioCss, ".timeline-clip::before");const activeBloomOverlayRule = expectRule(studioCss, ".timeline-clip[data-active]::before");- expect(baseTimelineClipRule).toContain("background-color: rgba(255, 255, 255, 0.055)");+ expect(baseTimelineClipRule).toContain("background-color: var(--clip-bg)");expect(activeTimelineClipRule).not.toContain("background: linear-gradient");- expect(activeTimelineClipRule).toContain("border-color: rgba(60, 230, 172, 0.55)");+ expect(activeTimelineClipRule).toContain("border-color: var(--clip-border-active)");expect(activeTimelineClipRule).not.toContain("box-shadow");- expect(bloomOverlayRule).toContain("background: rgba(60, 230, 172, 0.2)");+ expect(bloomOverlayRule).toContain("background: var(--clip-bg-active)");expect(bloomOverlayRule).not.toContain("linear-gradient");expect(bloomOverlayRule).toContain("opacity: 0");expect(activeBloomOverlayRule).toContain("opacity: 1");diff --git a/packages/studio/src/player/components/timelineTheme.test.ts b/packages/studio/src/player/components/timelineTheme.test.tsindex da113bee53..18675c6e70 100644--- a/packages/studio/src/player/components/timelineTheme.test.ts+++ b/packages/studio/src/player/components/timelineTheme.test.ts@@ -9,10 +9,10 @@ import { getTrackStyle } from "./timelineIcons";describe("getTimelineTrackStyle", () => {it("uses one neutral clip style for every timeline tag", () => {const expectedStyle = {- clip: "rgba(255,255,255,0.055)",- clipActive: "rgba(60,230,172,0.16)",- accent: "#3CE6AC",- label: "rgba(255,255,255,0.5)",+ clip: "var(--timeline-track-clip-fill)",+ clipActive: "var(--timeline-track-clip-active)",+ accent: "var(--color-accent)",+ label: "var(--timeline-track-label)",};expect(getTimelineTrackStyle("video")).toEqual(expectedStyle);diff --git a/packages/studio/src/player/components/timelineTheme.ts b/packages/studio/src/player/components/timelineTheme.tsindex b9d7f827bf..6ba07b6292 100644--- a/packages/studio/src/player/components/timelineTheme.ts+++ b/packages/studio/src/player/components/timelineTheme.ts@@ -22,6 +22,8 @@ export interface TimelineTheme {tickMinor: string;clipBackground: string;clipBackgroundActive: string;+ clipBackgroundHover: string;+ clipBackgroundDragging: string;clipBorder: string;clipBorderHover: string;clipBorderActive: string;@@ -36,43 +38,45 @@ export interface TimelineTheme {}const TRACK_STYLE: TimelineTrackStyle = {- clip: "rgba(255,255,255,0.055)",- clipActive: "rgba(60,230,172,0.16)",- accent: "#3CE6AC",- label: "rgba(255,255,255,0.5)",+ clip: "var(--timeline-track-clip-fill)",+ clipActive: "var(--timeline-track-clip-active)",+ accent: "var(--color-accent)",+ label: "var(--timeline-track-label)",};+// Every field reads a CSS custom property (declared in styles/theme.css)+// rather than a literal, so a host themes the timeline the same way it+// themes the rest of Studio: by overriding the token, not this object.export const defaultTimelineTheme: TimelineTheme = {- // Near-black card surfaces: the panels sit dark while the shell canvas- // between them is a step LIGHTER (#18181B), so the gaps read as visible- // seams around dark cards (CapCut-style).- shellBackground: "#0A0A0B",- shellBorder: "rgba(255,255,255,0.05)",- rulerBorder: "rgba(255,255,255,0.16)",- // All track lanes use a single uniform color — one step lighter than the panel- // surface (#0A0A0B) so lanes are visibly distinct from the ruler/shell.- rowBackground: "#101014",- rowBorder: "rgba(255,255,255,0.06)",- gutterBackground: "#0E0F12",- gutterBorder: "rgba(255,255,255,0.10)",- textPrimary: "rgba(255,255,255,0.92)",- textSecondary: "rgba(255,255,255,0.62)",- tickText: "rgba(255,255,255,0.34)",- tickMajor: "rgba(255,255,255,0.10)",- tickMinor: "rgba(255,255,255,0.06)",- clipBackground: "#141922",- clipBackgroundActive: "#181e28",- clipBorder: "rgba(255,255,255,0.10)",- clipBorderHover: "rgba(255,255,255,0.18)",- clipBorderActive: "rgba(255,255,255,0.24)",+ shellBackground: "var(--timeline-shell-bg)",+ shellBorder: "var(--timeline-shell-border)",+ rulerBorder: "var(--timeline-ruler-border)",+ rowBackground: "var(--timeline-row-bg)",+ rowBorder: "var(--timeline-row-border)",+ gutterBackground: "var(--timeline-gutter-bg)",+ gutterBorder: "var(--timeline-gutter-border)",+ textPrimary: "var(--timeline-text-primary)",+ textSecondary: "var(--timeline-text-secondary)",+ tickText: "var(--timeline-tick-text)",+ tickMajor: "var(--timeline-tick-major)",+ tickMinor: "var(--timeline-tick-minor)",+ clipBackground: "var(--timeline-clip-bg)",+ clipBackgroundActive: "var(--timeline-clip-bg-active)",+ clipBackgroundHover: "var(--timeline-clip-bg-hover)",+ clipBackgroundDragging: "var(--timeline-clip-bg-dragging)",+ clipBorder: "var(--timeline-clip-border)",+ clipBorderHover: "var(--timeline-clip-border-hover)",+ clipBorderActive: "var(--timeline-clip-border-active)",+ // Shadows stay literal: a light host still wants a dark contact shadow, so+ // these are not part of the surface/hairline/text/clip-colour theming ask.clipShadow: "none",clipShadowHover: "0 2px 8px rgba(0,0,0,0.2)",clipShadowActive: "0 2px 8px rgba(0,0,0,0.2), 0 0 0 1px rgba(255,255,255,0.04)",clipShadowDragging: "0 8px 24px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.06)",- handleColor: "rgba(255,255,255,0.2)",- panelResizeSeam: "rgba(255,255,255,0.12)",- panelResizeActive: "rgba(255,255,255,0.24)",- clipRadius: "8px",+ handleColor: "var(--timeline-handle)",+ panelResizeSeam: "var(--timeline-resize-seam)",+ panelResizeActive: "var(--timeline-resize-active)",+ clipRadius: "var(--radius-lg)",};export function getTimelineTrackStyle(_tag: string): TimelineTrackStyle {diff --git a/packages/studio/src/styles/hex-baseline.json b/packages/studio/src/styles/hex-baseline.jsonindex 752f99acb6..2ae279c532 100644--- a/packages/studio/src/styles/hex-baseline.json+++ b/packages/studio/src/styles/hex-baseline.json@@ -1,5 +1,5 @@{- "total": 418,+ "total": 385,"files": {"packages/studio/src/captions/components/CaptionOverlay.tsx": 5,"packages/studio/src/captions/components/CaptionTimeline.tsx": 11,@@ -61,7 +61,6 @@"packages/studio/src/player/components/SpeedMenu.tsx": 2,"packages/studio/src/player/components/TimelineAutomationLane.tsx": 4,"packages/studio/src/player/components/TimelineCanvas.tsx": 13,- "packages/studio/src/player/components/TimelineClip.tsx": 2,"packages/studio/src/player/components/TimelineClipDiamonds.tsx": 2,"packages/studio/src/player/components/TimelineDiamondConnectors.tsx": 2,"packages/studio/src/player/components/TimelineEmptyState.tsx": 1,@@ -75,9 +74,9 @@"packages/studio/src/player/components/TimelineTrackHeader.tsx": 2,"packages/studio/src/player/components/TimelineTrackPlainHeader.tsx": 2,"packages/studio/src/player/components/VideoThumbnail.tsx": 6,- "packages/studio/src/player/components/timelineTheme.ts": 29,+ "packages/studio/src/player/components/timelineTheme.ts": 5,"packages/studio/src/player/components/trackHeaderLabelRows.tsx": 6,- "packages/studio/src/styles/studio.css": 70,+ "packages/studio/src/styles/studio.css": 63,"packages/studio/src/telemetry/client.ts": 1,"packages/studio/src/webmcp/webmcpTestUtils.ts": 1}diff --git a/packages/studio/src/styles/studio.css b/packages/studio/src/styles/studio.cssindex fc68cdb7e7..54aa2262ca 100644--- a/packages/studio/src/styles/studio.css+++ b/packages/studio/src/styles/studio.css@@ -200,8 +200,8 @@ body {}.timeline-clip {- background-color: rgba(255, 255, 255, 0.055);- border: 1px solid rgba(255, 255, 255, 0.09);+ background-color: var(--clip-bg);+ border: 1px solid var(--clip-border);border-radius: 8px;}@@ -210,13 +210,13 @@ body {position: absolute;inset: 0;border-radius: inherit;- background: rgba(60, 230, 172, 0.2);+ background: var(--clip-bg-active);opacity: 0;pointer-events: none;}.timeline-clip[data-active] {- border-color: rgba(60, 230, 172, 0.55);+ border-color: var(--clip-border-active);}.timeline-clip[data-active]::before {@@ -240,11 +240,11 @@ body {}.timeline-clip.is-hovered {- background-color: rgba(255, 255, 255, 0.09);+ background-color: var(--clip-bg-hover);}.timeline-clip[data-active].is-hovered {- border-color: rgba(60, 230, 172, 0.75);+ border-color: var(--clip-border-hover);}.timeline-clip.is-selected {@@ -258,7 +258,7 @@ body {.timeline-clip.is-dragging {/* Solid background so the picked-up clip reads clearly while dragging — audioclips (waveform drawn on a separate layer) would otherwise look transparent. */- background-color: rgba(38, 42, 52, 0.96);+ background-color: var(--clip-bg-dragging);box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);}diff --git a/packages/studio/src/styles/theme.css b/packages/studio/src/styles/theme.cssindex d40daf17e5..55010e283a 100644--- a/packages/studio/src/styles/theme.css+++ b/packages/studio/src/styles/theme.css@@ -46,6 +46,35 @@--color-brand-gradient-from: #06e3fa;--color-brand-gradient-to: #4fdb5e;+ /* The timeline's own surfaces: darker and bluer than the shared scale, so they+ * get their own names instead of snapping to the nearest --color-bg/-surface+ * step (a host themes the timeline by overriding these). */+ --timeline-shell-bg: #0a0a0b;+ --timeline-shell-border: rgba(255, 255, 255, 0.05);+ --timeline-ruler-border: rgba(255, 255, 255, 0.16);+ --timeline-row-bg: #101014;+ --timeline-row-border: rgba(255, 255, 255, 0.06);+ --timeline-gutter-bg: #0e0f12;+ --timeline-gutter-border: rgba(255, 255, 255, 0.1);+ --timeline-text-primary: rgba(255, 255, 255, 0.92);+ --timeline-text-secondary: rgba(255, 255, 255, 0.62);+ --timeline-tick-text: rgba(255, 255, 255, 0.34);+ --timeline-tick-major: rgba(255, 255, 255, 0.1);+ --timeline-tick-minor: rgba(255, 255, 255, 0.06);+ --timeline-clip-bg: rgba(255, 255, 255, 0.12);+ --timeline-clip-bg-active: rgba(60, 230, 172, 0.2);+ --timeline-clip-bg-hover: rgba(255, 255, 255, 0.16);+ --timeline-clip-bg-dragging: rgba(38, 42, 52, 0.96);+ --timeline-clip-border: rgba(255, 255, 255, 0.22);+ --timeline-clip-border-hover: rgba(60, 230, 172, 0.75);+ --timeline-clip-border-active: rgba(60, 230, 172, 0.55);+ --timeline-handle: rgba(255, 255, 255, 0.55);+ --timeline-resize-seam: rgba(255, 255, 255, 0.12);+ --timeline-resize-active: rgba(255, 255, 255, 0.24);+ --timeline-track-clip-fill: rgba(255, 255, 255, 0.055);+ --timeline-track-clip-active: rgba(60, 230, 172, 0.16);+ --timeline-track-label: rgba(255, 255, 255, 0.5);+/* -------------------------------------------------------------- geometry */--radius-sm: 0.25rem;