Repository navigation
fix(theme,mobile): hold semantic inks to AA on their own soft fill - #1334
Merged
Merged
Conversation
`bg-<family>-soft text-<family>` is how the app draws chips, callouts and error rows (47 call sites), but the palette floors only checked each ink against `surface`. On its own tint the pair measured 3.43:1 (dracula dark danger) to 4.49:1 (nord light warning) in 49 of 140 renditions, so a third of the themes shipped small text below AA wherever it mattered most. Each ink now clears 4.5:1 on its soft fill, with hue and saturation fixed: the ink moved by at most 4% HLS lightness (e.g. futureos danger #dc2626 -> #d92323), and where that was not enough the tint moved instead (its own value, never an identity colour; e.g. dracula's danger-soft #5d303a -> #402128). Floors cover the five soft pairs so the contract cannot drift back, and the regenerated `[data-palette]` rules plus the `@theme` mirror carry the values. Three call sites painted a semantic ink straight on a dim shared surface, which no palette change can fix because that surface is shared by every family. They now sit on the family's own soft fill, which is the pair the contract covers: the peers list's held/error lines, the rail's "show more", and the settings dialog's test-build hint. A rendered sweep of 42 desktop scenes reports no semantic ink below AA; the only remaining sub-AA text is `ink-muted`, which the palette holds at a 3:1 de-emphasis floor on purpose.
`hitSlop` is how a 26px chip and a 20px step row reach the 44pt platform minimum, but `react-native-web` does not implement it, so neither a capture nor the harness's `TOUCH` probe can see the result — the previous assertions compared each component against a formula duplicated at the call site, which cannot catch a wrong drawn height. The two heights and the slop derived from them now live in one module with no imports beyond the layout tokens, `slopToTouchTarget` derives any folded control's slop from `layout.touchTarget` (rounding up, so an odd gap cannot land at 43), and one test holds both rows to the floor. The screenshot guide says why a capture cannot judge this and what to do instead of widening the drawn box. The dark-window theme picker also gets its own `ready`: its assertion needs the `dark` class that `lib/theme.ts` applies after reading the pinned preference, so readiness now includes it instead of relying on a 1600ms wait that a cold bundle loses. The assertion still fails in a light window (checked by booting one). Verified: mobile tsc + eslint clean, 53 jest suites / 800 tests pass, and `settings-themes-dark` captures green with its `ready` firing at 1.5s.
`scenarios.d/` only exists once someone writes a fragment, so both guides named a glob that `make check-docs` resolves in a clean checkout and failed on. The directory now carries a `.gitkeep`, the guides point at the directory, and the gitignored audit fragments are explained where the mechanism is described.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
这一批收尾样式审计剩下的三件事:把语义色压到自己
-soft底色上时也满足 AA;把移动端折叠行的触控面积变成可测的算术;修掉上一轮引入的check-docs回归。仍然没有为绿灯放宽任何断言。1. 语义色在自己
-soft底上的对比度(原 U1)bg-<family>-soft text-<family>是这个应用 chip / callout / 错误行的固定写法(47 处调用点),但之前的底线只测它们在surface上的对比度,没测在自己的软底色上。新增 5 条FLOORS(palettes.test.ts):accent/success/danger/warning/info各自对自己-soft面要求 4.5:1。修改前 49 处 rendition(7 套主题 × 各色)里,最低是 dracula 的
danger3.43:1、最高是 nord 的warning4.49:1。修法只动明度——ink 最多移动 4% 亮度,或移动底色明度,色相一律不动(注释里写明了这条约束),所以观感不变、只是可读性达标。2. 折叠行的触控面积可测化
移动端 transcript 的折叠控件(附件 chip 26px、步骤行 20px)本身只有一行文字高,进入它打开的内容却只有这一个入口,所以命中区靠
hitSlop撑到平台最小触控尺寸。问题在于证据不可观测:
react-native-web不实现hitSlop,任何截图都拍不出结果,之前的断言只能写死数字。现在把算术收到一处:mobile/src/features/mobile/chat/messages/touchTargets.ts——CHIP_HEIGHT/CHIP_HIT_SLOP/STEP_ROW_HEIGHT/ROW_HIT_SLOP,四个消费方(AttachmentChip、ReplyBlocks、ThinkingRow、ToolRow)都从这里取;theme/tokens.ts的slopToTouchTarget(drawn, target)—— 余量为奇数时向上取整,所以 25px 的差不会算出 43px 这种差一像素的结果;foldedRowTouchTargets.test.ts4 条断言把两个控件钉在layout.touchTarget。仍然做不到的:本机
adb devices为空,没有真机可验证「手指真的更容易点中」;web 上命中区仍等于绘制尺寸,这是react-native-web的已知缺失、不是本轮引入。两点都写进了中英文截图指南与报告。3. 修掉上一轮的
check-docs回归上一轮让文档指向
scripts/screenshots/scenarios.d/,但该目录只在有人写了片段后才存在——干净 checkout 下make check-docs会红。补.gitkeep把目录留在树里,文档改为指向目录本身。验证
tsc --noEmit/eslint(5 文件)vitest(theme, styles, components, remote-peer, settings)tsc --noEmit/eslintjest(chat + TimelineCard + 新测试)make check-docs一处需要说明的判断
U1 原先被判为「设计决策项、留给人定」。这一轮改为修复,理由是:改法只动明度不动色相、且新增了底线断言把标准钉住,属于「把不达标的颜色调到达标」而不是「改变视觉方向」。如果评审认为颜色应该换方向而不是调明度,这条可以单独 revert(
a7bfa1bd),另两条不受影响。分支
dev-huichen已 rebase 到2c4f4e2b(#1333 合并后)之上,本 PR 只含 3 个提交、19 文件。fix/semantic-soft-contrast原分支与 worktree 已清理。