Repository navigation
feat: add color vision settings for protanopia and deuteranopia, and tritanopia - #299
nickvigilante wants to merge 4 commits into
Conversation
Red-green color vision deficiency pulls the tip, warning and caution callouts, and the Early Access and Deprecated pills, close together under simulation. The labels and icons still carry the meaning, but the hues should not mislead. `data-color-vision="protan-deuter"` on <html> now recolors the callout and state pill tokens and the green code colors, using the hues of the Coder dashboard's protan-deuter themes (teal and sky for success, orange for error, magenta for warning) re-tuned to 7:1 text contrast, so the palette also holds with More contrast on. The html prefix lets the overrides beat the More pill rules without depending on source order. contrast:check gains the callout colors, a color-vision palette, and a color-vision over More palette, and still fails on a rule it cannot place. A Machado 2009 simulation with CIEDE2000 pins every callout, pill background and diff color at least 10 apart under both deficiencies. Assisted-by: AI
The panel gets a Color vision row, Standard or Protanopia and deuteranopia, stored as docs-color-vision and mirrored onto <html> as data-color-vision by the same inline head script that carries contrast and motion, so it applies before first paint on the docs site and the offline export. There is no system option, because browsers expose no signal for it; a missing attribute is the standard palette. The axe pass scans the pages with callouts, state pills, check and cross icons and a diff in the new mode, with and without More contrast, and the open panel in it. The states fixture now carries a pill of every tone and the code fixture a diff block. Assisted-by: AI
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
DOCS-1474 Add colour-vision settings (protanopia and deuteranopia) to the docs site
SummaryAdd a "Color vision" display preference to the docs site so readers with protanopia or deuteranopia get a palette that does not rely on red versus green. WhyThe docs already meet WCAG 1.4.1 where it matters: callouts, state pills, ✅/❌ icons, and diffs all carry a label, glyph, or sign.
The Coder dashboard already ships Scope
Out of scope
Constraints
Acceptance criteria
Verify before starting
EstimateAbout half a day of audit, then 2 to 3 days for the preference and tests. UpstreamLikely no. Created by Coder Agents on behalf of @Vigilante*.* |
Tritanopia confuses blue with green and yellow with violet, so the red-green palette is not enough for it. `data-color-vision="tritan"` now recolors callouts and state pills like the Coder dashboard's tritan themes (sky for success, magenta for warning, red kept for errors), re-tuned to 7:1 text contrast so More contrast needs no twin. The code colors keep the default Shiki values, which already stay far apart under tritanopia. contrast:check gains tritan and tritan more palettes, and still fails on a rule it cannot place. The simulation gains tritanopia, and the tests pin every callout, pill background and diff color at least 10 CIEDE2000 apart under it. Assisted-by: AI
The Color vision row gains a third option, stored as tritan under the same docs-color-vision key and copied onto <html> by the same head script, which still ignores any other value. The row's hint now describes the selected option, in a reserved three-line slot so choosing one never resizes the panel. The axe pass scans the same pages and the open panel with Tritanopia on, with and without More contrast. Assisted-by: AI
Merge order
Independent of #298 (the Fumadocs 16.17.9 upgrade). This branch keeps its CSS in a new
color-vision.cssand leavesbrand.cssuntouched, so the two should not conflict; whichever lands second rebases, and #298's Shiki 4.5.0 bump needs no change here because the code overrides match token colors, not Shiki internals.Summary
Adds a Color vision row to the Display settings panel, Standard, Protanopia and deuteranopia, or Tritanopia, matching the dashboard's split. Protanopia and deuteranopia are for readers who find reds and greens hard to tell apart; Tritanopia is for readers who find blues and greens, or yellows and purples, hard to tell apart. Choosing one recolors callouts and feature-state pills (and, for protanopia and deuteranopia, the green code colors: diff additions, HTML tags) onto hues that stay distinct under that deficiency. The labels, icons, and
+/-signs already carried the meaning, so this fixes the hues, not WCAG 1.4.1. It follows the Coder dashboard's protan-deuter themes (sky/teal for success, orange for error, magenta for warning) and tritan themes (sky for success, magenta for warning, red kept for error), re-tuned to the docs' contrast bars.Before and after for Protanopia and deuteranopia on the callouts fixture page (light, Standard on the left); I did not regenerate it for Tritanopia:
Design
colorVisionjoinsDISPLAY_PREFERENCES: keydocs-color-vision, attributedata-color-vision, valuesstandard,protan-deuterandtritan. The existing inline head script copies it onto<html>before first paint, so it works on the docs site and in the offline export with no extra script and no CSP change. There is no "System" choice, because no browser exposes a color-vision signal (the CSSWGcolor-vision-adjustmentidea, [mediaqueries] CSS Media Feature for Color Vision Adjustments w3c/csswg-drafts#10335, is only a proposal); a missing attribute is Standard, and picking Standard clears the key.w-64panel. The hint below the row describes the selected option ("The default colors.", "For people who find reds and greens hard to tell apart.", or "For people who find blues and greens, or yellows and purples, hard to tell apart.") and sits in a reserved three-line slot, so choosing an option never resizes the panel. Targets are 28px (44px on touch), arrow keys move between the options like the other rows, and the panel only mounts when opened, so there is no layout shift.packages/docs-theme/src/color-vision.css). Overrides of--color-fd-info/success/idea/warning/errorand the--docs-state-*pill tokens for light and dark, once per palette, plus two--shiki-*overrides (green to blue) for protanopia and deuteranopia only; the default Shiki colors already stay far apart under tritanopia. Every rule starts withhtml:root[data-color-vision="protan-deuter"]orhtml:root[data-color-vision="tritan"]; thehtmlprefix out-ranks the More contrast pill rules by specificity, so More needs no twin and the palette is AAA-clean under More already.contrast:checknow also measures the callout colors (on the page and on their 9% tint),color-visionandtritanpalettes at AA, andcolor-vision moreandtritan morepalettes at AAA, including the code overrides, and still throws on a color-vision rule it cannot place.scripts/cvd.mjsis a small Machado 2009 simulation plus CIEDE2000, andcolor-vision.test.mjspins every callout color, every pill background, and diff additions vs deletions at 10 or more apart under both protanopia and deuteranopia, and the same for the tritan palette under tritanopia.difftokens (not the line backgrounds), with the+/-sign in the text. Nothing relied on color alone, so nothing needed fixing in the default theme.Palette and simulated distances
CIEDE2000 under protanopia / deuteranopia (Machado 2009, severity 1.0). "Default" is the existing palette.
Callout colors (contrast on the page, on the 9% tint):
#272a5c(13.4, 11.3)#a1bff3(10.7, 9.4)#06607e(7.0, 6.2)#32d6cc(11.0, 9.8)#480ab0(10.8, 9.1)#b882ec(7.1, 6.4)#621035(12.8, 10.7)#d981a6(7.2, 6.6)#76370c(9.0, 7.8)#fd8660(8.3, 7.5)Every pair of the five callout colors and of the five pill backgrounds is at least 10 apart in both modes. The lowest pair is 10.1 (dark info vs success). The default pill backgrounds had pairs as low as 0.8 (light) and 2.8 (dark).
Pills (background / text, contrast):
#bf9df8/#2b1949(7.0)#530ba4/#e1c8fd(7.1)#acd3e3/#0a2531(10.0)#122d3f/#d4ebfb(11.6)#fbe1b7/#48320e(9.5)#6e3f0b/#fbe9d5(7.4)#e3afad/#421e1d(7.7)#460b09/#e8c5c3(10.1)#d0f9ef/#145345(7.9)#0a5344/#cffdf3(8.1)Tritan palette (CIEDE2000 under simulated tritanopia: callouts at least 21.0 apart in light and 15.3 in dark, pill backgrounds at least 18.8 and 16.2):
#120f5b(16.9, 14.0)#a8aee0(9.3, 8.3)#0f5991(7.3, 6.4)#5dc0e8(9.6, 8.6)#5a18a0(10.1, 8.6)#ba86f9(7.5, 6.8)#5a1b40(12.6, 10.6)#f958da(7.0, 6.5)#aa1c10(7.3, 6.2)#dca99c(9.7, 8.6)#ba95f1/#210d3f(7.3)#410f8c/#e2d8f3(9.2)#e3eff6/#0f3a52(10.3)#0f2639/#d8edff(12.9)#fde5c5/#2f2519(12.3)#4e3019/#fbf0e8(10.6)#f39782/#361912(7.3)#981614/#ffefee(7.7)#8ffaf9/#072525(13.2)#245b4a/#f3f9f8(7.4)Smallest simulated distance between any two callouts or any two pill backgrounds, for information only (the palettes are only required to pass their own deficiency):
Each cell is callouts / pill backgrounds. The tritan palette is not meant for red-green deficiencies, and the table shows why the setting has three options rather than one.
Code: green tags and diff additions move from
#024c1ato#0a5670(light) and from#7ee787to#a5f3fc(dark); both stay above 7:1 on the code surfaces.Dark success first used
#b0effd, and axe caught a Shiki comment on the inline-code chip dropping under 4.5:1 on its tint, so it became#32d6cc.QA
All in a browser, in Chrome and Firefox. Use the preview named under Pages to compare.
admin/templates/managing-templates/external-workspaces/page. In the left sidebar footer, click the sliders icon ("Display settings"). The panel has four rows: Theme, Contrast, Color vision, Motion. Color vision lists Standard, Protanopia and deuteranopia, and Tritanopia, with Standard selected and the hint "The default colors."install/operate/upgrade/best-practices/(Note, Tip, Caution callouts) andadmin/networking/workspace-proxies/(adifffence): the callouts, the diff's added line, and the pill recolor there too.Pages to compare
The preview is not deployed by this PR:
docs-pr-preview.ymlhas to be run on this branch (agents may not run it), and it prints the URL; the preview alias needs a Vercel login. The setting does not exist on production yet, so compare production Standard with the preview in each mode. Each production URL returns 200. Theauthoring/fixture pages exist only in the CI fixture build.<preview>/admin/templates/managing-templates/external-workspaces/<preview>/install/operate/upgrade/best-practices/<preview>/user-guides/desktop/diffcode fence (one added line)<preview>/admin/networking/workspace-proxies/Testing
pnpm lint,pnpm typecheck, andpnpm testpass;pnpm --filter @coder/docs-theme contrast:checkreports 0 new failures, including thecolor-visionandtritan(AA) andcolor-vision moreandtritan more(AAA) palettes.a11y:axe, fixture build) passes with 0 new findings across 110 scans: the callouts, states, code, and tables pages invision-{light,dark},vision-more-{light,dark},vision-tritan-{light,dark}, andvision-tritan-more-{light,dark}, plus the open display settings panel in each.a11y:keyboard,csp:check, andfirst-load:checkpass.data-color-visionand the new token values; switching between all three options in the panel applies at once and persists, and a reload with Tritanopia on hasdata-color-vision="tritan"and the tritan tokens in the first frame; the Color vision row fits in the 256px panel with no clipped label or hint, the panel height is the same for all three options, 28px options (44px on touch; touch height was checked for the first two options before Tritanopia was added), and arrow keys move through them. I did not re-measure layout shift after adding Tritanopia. Diff additions render#0a5670(light) and#a5f3fc(dark) in both browsers.Upstream
No. The palette, the Coder vocabulary, and
DisplayPreferencesScriptare ours rather than Fumadocs extension points, and Fumadocs has no setting for pre-paint display preferences to hook into, so there is no generic fix to offer.Linear: DOCS-1474
🤖 Built with AI assistance.