Skip to content

Commit 4e74eef

Browse files
committed
fix(studio): meet the 24x24 pointer target minimum on toolbar and lane controls
1 parent 6902069 commit 4e74eef

10 files changed

Lines changed: 121 additions & 17 deletions

‎packages/studio/src/components/StudioLeftSidebar.tsx‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,10 @@ export function StudioLeftSidebar({
154154
onAddAssetToTimeline={onAddAssetToTimeline}
155155
onAddCompositionToTimeline={onAddCompositionToTimeline}
156156
/>
157-
{/* Vertical resize divider: 3px visible seam, 8px pointer-capture zone via
157+
{/* Vertical resize divider: 3px visible seam, 13px pointer-capture zone via
158158
the absolutely-positioned inner hit area. The outer element is w-[3px] so
159-
it contributes only 3px of gap in the flex row; the inner -left-[2.5px]
160-
element widens the hit area to 8px without affecting layout. */}
159+
it contributes only 3px of gap in the flex row; the inner -left-[2px]
160+
element widens the hit area without affecting layout. */}
161161
<div
162162
role="separator"
163163
aria-label="Resize sidebar"
@@ -176,8 +176,13 @@ export function StudioLeftSidebar({
176176
adjustPanelWidth("left", delta);
177177
}}
178178
>
179-
{/* Expanded hit zone: 8px wide, centered on the 3px seam */}
180-
<div className="absolute inset-y-0 -left-[2.5px] w-2" />
179+
{/* Expanded hit zone, deliberately asymmetric: 2px into the sidebar card,
180+
the 3px seam, then 8px into the preview pane's p-2 stage gutter — the
181+
only dead space adjacent to this seam. It stops at 13px rather than the
182+
24px WCAG 2.2 (2.5.8) target because the next pixel on either side is
183+
live: the sidebar's scrolling tab content on the left, the preview
184+
stage on the right. Silently stealing their clicks is the worse bug. */}
185+
<div className="absolute inset-y-0 -left-[2px] w-[13px]" />
181186
{/* Visible hairline */}
182187
<div className="absolute top-1/2 left-0 h-[52px] w-[3px] -translate-y-1/2 bg-white/12 transition-colors group-hover:bg-white/18 group-active:bg-white/24" />
183188
</div>

‎packages/studio/src/components/StudioRightPanel.tsx‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ export function StudioRightPanel({
446446

447447
return (
448448
<>
449-
{/* Vertical resize divider: 3px visible seam, 8px pointer-capture zone via
449+
{/* Vertical resize divider: 3px visible seam, 13px pointer-capture zone via
450450
the absolutely-positioned inner hit area. */}
451451
<div
452452
role="separator"
@@ -467,8 +467,12 @@ export function StudioRightPanel({
467467
adjustPanelWidth("right", delta);
468468
}}
469469
>
470-
{/* Expanded hit zone: 8px wide, centered on the 3px seam */}
471-
<div className="absolute inset-y-0 -left-[2.5px] w-2" />
470+
{/* Expanded hit zone, deliberately asymmetric: 8px into the preview pane's
471+
p-2 stage gutter (the only dead space here), the 3px seam, then 2px
472+
into the inspector card. It stops at 13px rather than the 24px WCAG 2.2
473+
(2.5.8) target because the next pixel on either side is live: the
474+
preview stage on the left, the inspector's own controls on the right. */}
475+
<div className="absolute inset-y-0 -left-[8px] w-[13px]" />
472476
{/* Visible hairline */}
473477
<div className="absolute top-1/2 left-0 h-[52px] w-[3px] -translate-y-1/2 bg-white/12 transition-colors group-hover:bg-white/18 group-active:bg-white/24" />
474478
</div>

‎packages/studio/src/components/TimelineToolbar.tsx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,9 @@ export function TimelineToolbar({ domEditSession, onSplitElement }: TimelineTool
449449
setZoomMode("manual");
450450
setManualZoomPercent(timelineSliderToZoomPercent(Number(e.target.value)));
451451
}}
452-
className="mx-1 w-[96px] cursor-pointer appearance-none bg-transparent [&::-webkit-slider-runnable-track]:h-[2px] [&::-webkit-slider-runnable-track]:rounded-full [&::-webkit-slider-runnable-track]:bg-neutral-700 [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-[10px] [&::-webkit-slider-thumb]:h-[10px] [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-white [&::-webkit-slider-thumb]:-mt-1 [&::-webkit-slider-thumb]:shadow-[0_0_0_2px_#0a0a0a,0_1px_3px_rgba(0,0,0,0.5)] [&::-webkit-slider-thumb]:cursor-grab [&::-webkit-slider-thumb:active]:cursor-grabbing"
452+
// h-6 on the input is the 24x24 WCAG 2.2 (2.5.8) target: the visible
453+
// track stays 2px and the thumb 10px, only the pointer box grows.
454+
className="mx-1 h-6 w-[96px] cursor-pointer appearance-none bg-transparent [&::-webkit-slider-runnable-track]:h-[2px] [&::-webkit-slider-runnable-track]:rounded-full [&::-webkit-slider-runnable-track]:bg-neutral-700 [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-[10px] [&::-webkit-slider-thumb]:h-[10px] [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-white [&::-webkit-slider-thumb]:-mt-1 [&::-webkit-slider-thumb]:shadow-[0_0_0_2px_#0a0a0a,0_1px_3px_rgba(0,0,0,0.5)] [&::-webkit-slider-thumb]:cursor-grab [&::-webkit-slider-thumb:active]:cursor-grabbing"
453455
/>
454456
<Tooltip label="Zoom in">
455457
<button

‎packages/studio/src/components/editor/KeyframeNavigation.tsx‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,11 @@ export const KeyframeNavigation = memo(function KeyframeNavigation({
167167
};
168168

169169
return (
170+
// The two 12x20 steppers sit gap-0.5 apart with a 9px diamond between them,
171+
// so they stay below the 24px WCAG 2.2 (2.5.8) minimum under that criterion's
172+
// own spacing/inline exception: centred 24px targets here would overlap each
173+
// other AND the diamond, and one control swallowing its neighbour's clicks is
174+
// a worse 2.5.8 failure than a small target. Do not "fix" these to 24.
170175
<div className="flex h-5 items-center gap-0.5">
171176
<button
172177
type="button"

‎packages/studio/src/components/editor/propertyPanelPrimitives.tsx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,9 @@ export function SliderControl({
189189
onMouseUp={() => commitDraft(draft)}
190190
onTouchEnd={() => commitDraft(draft)}
191191
onBlur={() => commitDraft(draft)}
192-
className="h-4 min-w-0 w-full cursor-pointer appearance-none bg-transparent disabled:cursor-not-allowed disabled:opacity-50 [&::-webkit-slider-runnable-track]:h-[2px] [&::-webkit-slider-runnable-track]:rounded-full [&::-webkit-slider-runnable-track]:bg-panel-border [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-[10px] [&::-webkit-slider-thumb]:h-[10px] [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-white [&::-webkit-slider-thumb]:-mt-1 [&::-webkit-slider-thumb]:shadow-[0_0_0_2px_#0C0C0E,0_1px_3px_rgba(0,0,0,0.5)] [&::-webkit-slider-thumb]:cursor-grab [&::-webkit-slider-thumb:active]:cursor-grabbing"
192+
// h-6 is the 24x24 WCAG 2.2 (2.5.8) target: the visible track stays 2px
193+
// and the thumb 10px, only the pointer box grows.
194+
className="h-6 min-w-0 w-full cursor-pointer appearance-none bg-transparent disabled:cursor-not-allowed disabled:opacity-50 [&::-webkit-slider-runnable-track]:h-[2px] [&::-webkit-slider-runnable-track]:rounded-full [&::-webkit-slider-runnable-track]:bg-panel-border [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-[10px] [&::-webkit-slider-thumb]:h-[10px] [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-white [&::-webkit-slider-thumb]:-mt-1 [&::-webkit-slider-thumb]:shadow-[0_0_0_2px_#0C0C0E,0_1px_3px_rgba(0,0,0,0.5)] [&::-webkit-slider-thumb]:cursor-grab [&::-webkit-slider-thumb:active]:cursor-grabbing"
193195
/>
194196
<div className="min-w-[44px] rounded-md bg-panel-input px-2 py-1.5 text-right text-[11px] font-medium text-panel-text-1 tabular-nums">
195197
{formatDisplayValue?.(draft) ?? displayValue}

‎packages/studio/src/components/nle/TimelineResizeDivider.tsx‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ export function TimelineResizeDivider({
7373
);
7474

7575
return (
76-
// Horizontal resize divider: 3px visible seam (h-[3px]), 8px pointer-capture
76+
// Horizontal resize divider: 3px visible seam (h-[3px]), 10px pointer-capture
7777
// zone via the absolutely-positioned inner hit area so the layout gap stays
78-
// at 3px while draggability is preserved over the full 8px band.
78+
// at 3px while draggability is preserved over the full band.
7979
<div
8080
role="separator"
8181
aria-orientation="horizontal"
@@ -94,8 +94,13 @@ export function TimelineResizeDivider({
9494
onPointerCancel={handlePointerUp}
9595
onKeyDown={handleKeyDown}
9696
>
97-
{/* Expanded hit zone: 8px tall, centered on the 3px seam */}
98-
<div className="absolute inset-x-0 -top-[2.5px] h-2" />
97+
{/* Expanded hit zone, deliberately asymmetric: 4px up into the transport
98+
row's vertical centring slack, the 3px seam, then 3px down into the
99+
timeline card's border + toolbar padding. It stops at 10px rather than
100+
the 24px WCAG 2.2 (2.5.8) target because that is all the dead space
101+
there is: 28px transport buttons sit above and 28px toolbar buttons
102+
below, and silently stealing their clicks is the worse bug. */}
103+
<div className="absolute inset-x-0 -top-[4px] h-[10px]" />
99104
{/* Visible hairline — invisible at rest, subtle wash on hover/drag/focus */}
100105
<div className="h-[3px] w-full bg-transparent transition-colors group-hover:bg-white/12 group-active:bg-white/18 group-focus-visible:bg-studio-accent/60" />
101106
</div>
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// @vitest-environment happy-dom
2+
3+
import { act } from "react";
4+
import { createRoot, type Root } from "react-dom/client";
5+
import { afterEach, describe, expect, it, vi } from "vitest";
6+
import { CompositionsTab } from "./sidebar/CompositionsTab";
7+
import { TimelineToolbar } from "./TimelineToolbar";
8+
9+
// WCAG 2.2 (2.5.8) requires a 24x24 CSS pixel pointer target. happy-dom has no
10+
// CSS engine, so getBoundingClientRect() is 0x0 for everything here and the size
11+
// itself cannot be measured — these assert the utility classes that PRODUCE the
12+
// size instead, which is enough to fail if someone drops them. Real geometry
13+
// still needs a browser check.
14+
15+
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true });
16+
(
17+
window as unknown as { happyDOM: { settings: { disableIframePageLoading: boolean } } }
18+
).happyDOM.settings.disableIframePageLoading = true;
19+
20+
let root: Root | null = null;
21+
22+
afterEach(() => {
23+
if (root) act(() => root?.unmount());
24+
root = null;
25+
document.body.innerHTML = "";
26+
});
27+
28+
function mount(element: React.ReactNode) {
29+
const host = document.createElement("div");
30+
document.body.append(host);
31+
root = createRoot(host);
32+
act(() => root?.render(element));
33+
return host;
34+
}
35+
36+
describe("pointer target size (WCAG 2.5.8)", () => {
37+
it("gives the timeline zoom slider a 24px box without changing its 2px track or 10px thumb", () => {
38+
const host = mount(<TimelineToolbar />);
39+
const slider = host.querySelector<HTMLInputElement>('input[aria-label="Timeline zoom"]');
40+
if (!slider) throw new Error("zoom slider did not render");
41+
42+
expect(slider.className).toContain("h-6");
43+
expect(slider.className).toContain("[&::-webkit-slider-runnable-track]:h-[2px]");
44+
expect(slider.className).toContain("[&::-webkit-slider-thumb]:h-[10px]");
45+
expect(slider.className).toContain("[&::-webkit-slider-thumb]:w-[10px]");
46+
});
47+
48+
it("gives the composition card's render button a 24x24 box around its 14px glyph", () => {
49+
const host = mount(
50+
<CompositionsTab
51+
projectId="demo"
52+
compositions={["compositions/headline.html"]}
53+
activeComposition={null}
54+
onSelect={vi.fn()}
55+
onRenderComposition={vi.fn()}
56+
/>,
57+
);
58+
const button = host.querySelector<HTMLButtonElement>('button[aria-label="Render headline"]');
59+
if (!button) throw new Error("render button did not render");
60+
61+
expect(button.className).toContain("h-6");
62+
expect(button.className).toContain("w-6");
63+
expect(button.querySelector("svg")?.getAttribute("width")).toBe("14");
64+
});
65+
});

‎packages/studio/src/components/sidebar/CompositionsTab.tsx‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,10 @@ function CompCard({
317317
e.stopPropagation();
318318
onRender();
319319
}}
320-
className={`flex-shrink-0 p-1 rounded transition-colors ${
320+
// h-6 w-6 = the 24x24 WCAG 2.2 (2.5.8) minimum target; the 14px glyph
321+
// is unchanged, only the box grows. The sibling "+" button is h-8 w-8,
322+
// so the card row already has the room.
323+
className={`flex h-6 w-6 flex-shrink-0 items-center justify-center rounded transition-colors ${
321324
isRendering
322325
? "text-neutral-600 cursor-not-allowed"
323326
: "text-neutral-600 hover:text-studio-accent hover:bg-neutral-800"

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ export type { TimelineDiamondKeyframe } from "./timelineDiamondTypes";
2727
// stops there: at the zoom floor the gap alone left a ~7px target, which is
2828
// neither hittable nor selectable with any accuracy. Boxes may overlap slightly
2929
// below this width; each diamond still owns the half-gap around its own centre.
30+
//
31+
// Deliberately below the 24px WCAG 2.2 (2.5.8) minimum, under that criterion's
32+
// own spacing exception: at normal keyframe density the neighbour gap is under
33+
// 24px, so a 24px floor would make adjacent diamonds' hit boxes OVERLAP — one
34+
// diamond swallowing its neighbour's clicks is a worse 2.5.8 failure than a
35+
// small target. Do not "fix" this to 24.
3036
const KF_MIN_HIT_W = 12;
3137

3238
/** A clip-% is a float division, so a raw tooltip reads `25.032499999999995%`. */
@@ -141,6 +147,10 @@ export const TimelineDiamondLane = memo(function TimelineDiamondLane({
141147
? Math.round(clipHeightPx * 0.45)
142148
: Math.round(LANE_H * DIAMOND_RATIO);
143149
const centerY = beatsActive ? BEAT_BAND_H + (clipHeightPx - BEAT_BAND_H) / 2 : clipHeightPx / 2;
150+
// Hit-box height only — the glyph keeps `marker.visualSize`. 24 is the WCAG 2.2
151+
// (2.5.8) minimum and still fits the 28px lane. Beat-strip lanes keep the
152+
// shrunken box: 24px there would reach up into the beat strip.
153+
const hitHeight = beatsActive ? diamondSize : 24;
144154
const sorted = keyframesData.keyframes
145155
.filter((kf) => kf.percentage >= KF_MIN_PCT && kf.percentage <= KF_MAX_PCT)
146156
.sort((a, b) => a.percentage - b.percentage);
@@ -412,7 +422,7 @@ export const TimelineDiamondLane = memo(function TimelineDiamondLane({
412422
top: centerY,
413423
transform: "translateY(-50%)",
414424
width: marker.hitWidth,
415-
height: diamondSize,
425+
height: hitHeight,
416426
zIndex: isHighlighted ? 2 : 1,
417427
pointerEvents: "auto",
418428
background: "none",

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,10 @@ export function TimelineDiamondConnectors({
103103
data-keyframe-ease-button=""
104104
aria-label={`Edit ${ease} easing`}
105105
title={`Edit ${ease} easing`}
106-
className="absolute flex items-center justify-center rounded opacity-0 transition-opacity group-hover:opacity-100 focus-visible:opacity-100"
106+
// A visible 24x24 badge would collide with the diamonds either
107+
// side, so the WCAG 2.2 (2.5.8) target is met with a centered
108+
// transparent ::before overlay; the box stays 16x16.
109+
className="absolute flex items-center justify-center rounded opacity-0 transition-opacity group-hover:opacity-100 focus-visible:opacity-100 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-['']"
107110
style={{
108111
left: "50%",
109112
top: "50%",

0 commit comments

Comments
 (0)