Write HTML. Render video. Built for agents.
JavaScript aiai-agentsanimationclaude-codeffmpegframeworkgsaphtmlhtml-to-videomcpmotion-graphicspuppeteerrenderingtypescriptvideo-editor
feat(studio): the segment ease control is discoverable at rest (#4074)
Miguel Ángel5ef5419a9e9b
diff --git a/packages/studio/src/player/components/TimelineClipDiamonds.test.tsx b/packages/studio/src/player/components/TimelineClipDiamonds.test.tsxindex c1ddaf917d..59b86766c3 100644--- a/packages/studio/src/player/components/TimelineClipDiamonds.test.tsx+++ b/packages/studio/src/player/components/TimelineClipDiamonds.test.tsx@@ -1275,7 +1275,8 @@ describe("TimelineClipDiamonds", () => {expect(host.querySelectorAll("[data-keyframe-ease-segment]").length).toBe(2);const ease = host.querySelector<HTMLButtonElement>("[data-keyframe-ease-button]")!;expect(ease.getAttribute("aria-label")).toBe("Edit none easing after 10s");- expect(ease.classList.contains("opacity-0")).toBe(true);+ expect(ease.getAttribute("title")).toBe("Edit none easing");+ expect(ease.classList.contains("opacity-40")).toBe(true);act(() => ease.click());expect(onSelectSegment).toHaveBeenCalledOnce();expect(usePlayerStore.getState().requestedSeekTime).toBeNull();@@ -1318,6 +1319,17 @@ describe("TimelineClipDiamonds", () => {act(() => root.unmount());});+ it("keeps the ease button hover-only on a segment too narrow to show it at rest", () => {+ // Same narrow clip as above: showing the button at rest here would sit on+ // top of both diamonds instead of clear of them.+ const { host, root } = renderSegmentLane(false, 40);+ const ease = host.querySelector<HTMLButtonElement>("[data-keyframe-ease-button]");++ expect(ease?.classList.contains("opacity-0")).toBe(true);+ expect(ease?.classList.contains("opacity-40")).toBe(false);+ act(() => root.unmount());+ });+it("hides the inline ease button on a segment with no source animation id", () => {// A runtime-scanned keyframe has no animationId, so there is no tween to// target; the segment ending on it must not render a (dead) ease button.diff --git a/packages/studio/src/player/components/TimelineDiamondConnectors.test.ts b/packages/studio/src/player/components/TimelineDiamondConnectors.test.tsnew file mode 100644index 0000000000..83d98600cb--- /dev/null+++ b/packages/studio/src/player/components/TimelineDiamondConnectors.test.ts@@ -0,0 +1,16 @@+import { describe, expect, it } from "vitest";+import { hasRoomForRestingEase } from "./TimelineDiamondConnectors";++describe("hasRoomForRestingEase", () => {+ it("is false just under the threshold", () => {+ expect(hasRoomForRestingEase(23)).toBe(false);+ });++ it("is true exactly at the threshold", () => {+ expect(hasRoomForRestingEase(24)).toBe(true);+ });++ it("is true well above the threshold", () => {+ expect(hasRoomForRestingEase(78)).toBe(true);+ });+});diff --git a/packages/studio/src/player/components/TimelineDiamondConnectors.tsx b/packages/studio/src/player/components/TimelineDiamondConnectors.tsxindex 0312a4791c..0b92c679a9 100644--- a/packages/studio/src/player/components/TimelineDiamondConnectors.tsx+++ b/packages/studio/src/player/components/TimelineDiamondConnectors.tsx@@ -13,6 +13,17 @@ export interface TimelineDiamondMarker {visualSize: number;}+const EASE_BUTTON_PX = 16;+const EASE_BUTTON_REST_GAP_PX = 4;++/** Whether a segment is wide enough to show the ease button at rest (button+ * box plus a clear gap each side) without overlapping either neighboring+ * diamond. 24 coincides with roomForFullTarget's threshold below but is a+ * separate constraint; don't assume changing one keeps the other in sync. */+export function hasRoomForRestingEase(connectorWidth: number): boolean {+ return connectorWidth >= EASE_BUTTON_PX + EASE_BUTTON_REST_GAP_PX * 2;+}+/*** The line between each pair of adjacent diamonds, plus the ease control that* sits at the segment's midpoint. Split out of TimelineClipDiamonds only to keep@@ -96,6 +107,7 @@ export function TimelineDiamondConnectors({// the hit test and steal their clicks at fit zoom. Grow the// target only where the room exists.roomForFullTarget={connectorWidth >= 24}+ restingVisible={hasRoomForRestingEase(connectorWidth)}onSelectSegment={onSelectSegment}/>)}@@ -133,6 +145,7 @@ function SegmentEaseControl({rovingTargetId,afterLabel,roomForFullTarget,+ restingVisible,onSelectSegment,}: {left: number;@@ -146,6 +159,9 @@ function SegmentEaseControl({/** Time label of the keyframe this segment starts at, for the accessible name. */afterLabel: string;roomForFullTarget: boolean;+ /** Whether the segment is wide enough to show the button at rest; too+ * narrow and it stays hover-only so it doesn't smear over the diamonds. */+ restingVisible: boolean;onSelectSegment: (target: TimelineKeyframeTarget) => void;}) {// The ease button sits dead centre of its segment, which on a two-keyframe clip@@ -187,7 +203,7 @@ function SegmentEaseControl({// for that overlay the button keeps its 16x16 hit area, which is WCAG's// target-spacing exception: the neighbouring diamonds are themselves the// reason it cannot grow, and stealing their clicks is the worse failure.- className={`absolute flex items-center justify-center rounded opacity-0 transition-opacity group-hover:opacity-100 focus-visible:opacity-100 ${roomForFullTarget ? "before:absolute before:left-1/2 before:top-1/2 before:h-6 before:w-6 before:-translate-x-1/2 before:-translate-y-1/2 before:content-['']" : ""}`}+ className={`absolute flex items-center justify-center rounded ${restingVisible ? "opacity-40" : "opacity-0"} transition-opacity hover:opacity-100 group-hover:opacity-100 focus-visible:opacity-100 ${roomForFullTarget ? "before:absolute before:left-1/2 before:top-1/2 before:h-6 before:w-6 before:-translate-x-1/2 before:-translate-y-1/2 before:content-['']" : ""}`}style={{left: "50%",top: "50%",diff --git a/packages/studio/src/player/components/TimelinePropertyLanes.test.tsx b/packages/studio/src/player/components/TimelinePropertyLanes.test.tsxindex 61ceba4a0f..a3241a3790 100644--- a/packages/studio/src/player/components/TimelinePropertyLanes.test.tsx+++ b/packages/studio/src/player/components/TimelinePropertyLanes.test.tsx@@ -406,7 +406,7 @@ describe("TimelinePropertyLanes", () => {expect(laneDiamonds(host, "position")).toHaveLength(3);const buttons = laneEaseButtons(host, "position");expect(buttons).toHaveLength(2);- expect(buttons.every((button) => button.classList.contains("opacity-0"))).toBe(true);+ expect(buttons.every((button) => button.classList.contains("opacity-40"))).toBe(true);expect(buttons.every((button) => button.classList.contains("group-hover:opacity-100"))).toBe(true,);