Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions frontend/src/v2/__tests__/v2-layout-invariants.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -614,4 +614,25 @@ describe('v2 layout invariants (CSS rule presence)', () => {
/@media \(prefers-reduced-motion: reduce\)[\s\S]*?\.v2-thread-replies[\s\S]*?transition: none/,
);
});
test('zh-CN: every negative-tracking title is reset under :lang(zh) — CJK never takes negative letter-spacing (TASK-055)', () => {
// Every selector in v2.css that declares negative letter-spacing must be
// listed in the :lang(zh) reset block. Measured in a real browser: CJK
// glyphs have no side bearings, so -0.025em on a 20px title crushes strokes.
// The selector list may span lines (`a,\nb,\nc {`) — capture the whole
// list, then split on commas, or a multi-line list is checked by its last
// line only (sprint-review's gate on #1253: h1–h5 slipped past h6).
const negative = [...v2.matchAll(/\n((?:[^\n{}]+,\n)*[^\n{}]+) \{[^}]*letter-spacing:\s*-[^;]+;/g)]
.flatMap((m) => m[1].split(',').map((sel) => sel.trim()))
.filter(Boolean);
expect(negative.length).toBeGreaterThan(0);
const resetStart = v2.indexOf('.v2-root:lang(zh) .v2-rail__brand');
expect(resetStart).toBeGreaterThan(-1);
const resetBlock = v2.slice(resetStart, v2.indexOf('}', resetStart));
expect(resetBlock).toContain('letter-spacing: 0');
for (const sel of negative) {
const bare = sel.replace(/^\.v2-root /, '');
expect(resetBlock).toContain(`.v2-root:lang(zh) ${bare}`);
}
});

});
30 changes: 30 additions & 0 deletions frontend/src/v2/v2.css
Original file line number Diff line number Diff line change
Expand Up @@ -7449,3 +7449,33 @@ body.modern-ui.v2-canvas {
transition: none;
}
}

/* ---------------------------------------------------------------------------
* zh-CN: no negative tracking on CJK (TASK-055, rule class 1).
* The 12 title selectors above tighten Latin display type with negative
* letter-spacing. CJK glyphs are full-width squares with no side bearings to
* reclaim, so the same value only crushes strokes together. Measured in the
* real browser (.dev/task-055-zh-harness.html): .v2-chat__title -0.5px,
* .v2-pods__title -0.32px, .v2-inspector__now-title -0.15px on Chinese text.
* `html[lang]` is set by frontend/src/i18n/index.ts, so :lang(zh) matches
* zh-CN. Guarded by v2-layout-invariants.test.ts.
* ------------------------------------------------------------------------ */
.v2-root:lang(zh) .v2-rail__brand,
.v2-root:lang(zh) .v2-pods__title,
.v2-root:lang(zh) .v2-chat__title,
.v2-root:lang(zh) .v2-first-run__title,
.v2-root:lang(zh) .v2-chat__new-pod-title,
.v2-root:lang(zh) button.v2-inspector__tab,
.v2-root:lang(zh) .v2-inspector__now-title,
.v2-root:lang(zh) .v2-inspector__detail-name,
.v2-root:lang(zh) .v2-login__title,
.v2-root:lang(zh) .v2-feature__title,
.v2-root:lang(zh) .v2-feature__legacy .MuiTypography-h1,
.v2-root:lang(zh) .v2-feature__legacy .MuiTypography-h2,
.v2-root:lang(zh) .v2-feature__legacy .MuiTypography-h3,
.v2-root:lang(zh) .v2-feature__legacy .MuiTypography-h4,
.v2-root:lang(zh) .v2-feature__legacy .MuiTypography-h5,
.v2-root:lang(zh) .v2-feature__legacy .MuiTypography-h6,
.v2-root:lang(zh) .v2-team__title {
letter-spacing: 0;
}
Loading