mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #5073] [GUI] 复制文字时几乎看不到选区::selection 只设背景 tint,与未选中背景对比只有 1.01–1.27:1 #2361
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#2361
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @xvcezrqpbxtpzblrt on GitHub (Nov 3, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/5073
English TL;DR: The whole app has one selection rule —
apps/host/src/styles/app.css:940-942::selection { background: var(--st-accent-tint); }, shipped inhost/dist/assets/index-Dor2RFX-.cssas::selection{background:var(--st-accent-tint)}with nocolor. The tint is#ecfdf5(light) andrgba(52,211,153,.12)(dark). Measured with the WCAG relative-luminance formula against the shipped tokens: the selection highlight sits 1.01:1 to 1.27:1 above the background it is drawn on — i.e. when you drag-select text to copy it, there is effectively no visible marker, and no other cue (no border, no state text) conveys the selection. Text readability inside the selection is fine (15.65:1 / 12.32:1), so this is purely a visibility defect, not a legibility one.现象(用户本机报告,2026-11-03)
环境(本机实测)
Strata desktop 0.2.10,Windows10.0.26300,窗口模式(Chromium WebView2),浅色与深色主题都受影响(见下)host\dist\assets\index-Dor2RFX-.css(405,000 字节)唯一的相关样式(安装副本与源码一致)
安装副本里全文件只有这一条
::selection规则(用正则扫描整个 CSS 产物确认):token 取值(同一产物内):
--st-accent-tint:#ecfdf5;--st-surface:#ffffff;--st-bg:#f9fafb;--st-ink:#221e1f;--st-accent-tint:rgba(52,211,153,.12);--st-surface:#161a1d;--st-bg:#0e1113;--st-code-bg:#1b1f23;--st-code-ink:#e6e9ec;--st-ink:#eef1f3;测量结果(按 WCAG 相对亮度公式,数值由本机计算)
选区背景 与 它所覆盖的未选中背景 的对比度(这就是"看不看得出选中"的那个数):
#ecfdf5#ffffff(卡片/气泡)#ecfdf5#f9fafb(页面底)rgba(52,211,153,.12)合成 →rgb(26,48,44)#161a1d(卡片)rgba(52,211,153,.12)合成 →rgb(30,53,49)#1b1f23(代码块)选区内文字的易读性(说明问题不是"看不清字"):
#221e1f在未选中#ffffff上 16.49:1 → 在选区上 15.65:1#eef1f3在未选中#161a1d上 15.43:1 → 在选区上 12.32:1对照标准:WCAG 2.2 SC 1.4.11 Non-text Contrast 要求 UI 状态指示与相邻颜色 ≥ 3:1;选区(highlight/selection)正是该条理解文档里的例子。同时,选中状态只靠这个颜色表达,没有任何辅助线索,也触及 SC 1.4.1 Use of Color。实测 1.01–1.27:1 与 3:1 差一个数量级。
只改背景不够(已算过,避免建议落空)
要让选区达到 3:1,背景必须足够深;而现在的规则不设
color,文字色保持不变,深背景会立刻把文字对比压垮:#0f766e对#ffffff达 5.47:1(合格),但深色文字#221e1f在它上面只有 3.15:1(不合格)→ 必须同时设::selection { color: … }rgba(52,211,153,.12)即使把 alpha 提到 .38,对#161a1d也达不到 3:1;需要接近实色的 accent已验证可用的取值(同一公式计算,不是估计):
::selectionbackground:#0f766e; color:#ffffff#ffffff)#f9fafb)background:#34d399; color:#08131a#161a1d)#1b1f23)#0e1113)复现
期望 / 实际
建议
::selection同时设background与color,按主题分别给实色 accent(上表两组值已算过对比,全部 ≥3:1 且选区内文字 ≥4.5:1);不要复用只用于浅色提示的--st-accent-tint。--st-selection-bg/--st-selection-ink),把选区颜色从提示性 tint 里分离出来,避免以后被其它 tint 改动连带影响。::selection同时包含 background 与 color,且这两个 token 与--st-surface/--st-code-bg/--st-bg的对比度 ≥3(纯算术,不需要 GPU,适合放进apps/host的npm test)。.st-code pre、Markdown 表格、代码高亮 span)会继承全局::selection,改动后请在这几处一并目测:它们各自的底色调值不同(代码块#1b1f23),是最容易掉出 3:1 的位置。本报告未包含
--browser/Chrome/Edge 直接打开)下的表现——Chromium 在无color时保留文字色,建议值同样适用,但未实测;macOS/Linux 主题 token 是否有独立取值未核对(本机只有 Windows 安装副本)。相关已有讨论(先查过仓库)
selection、选中、复制 select;除 #3818 外没有覆盖"选区可见性/对比度"的开放 issue。版本核对(2026-11-03 补充)
初稿的行号取自 0.2.9 检出(克隆于 2026-11-02 14:46,落后
origin/main5,629 个提交)。现已检出 tag v0.2.10 =ffa80d73(与安装产物 mtime 06:37:26 对上)复核:apps/host/src/styles/app.css:954: 没有color。初稿写的 940-942 是旧检出的位置,以 954 为准host\dist\assets\index-Dor2RFX-.css里唯一一条(本次再核):::selection{background:var(--st-accent-tint)}