Skip to content

feat: add color vision settings for protanopia and deuteranopia, and tritanopia - #299

Closed
nickvigilante wants to merge 4 commits into
mainfrom
vigilante/docs-color-vision
Closed

nickvigilante wants to merge 4 commits into
mainfrom
vigilante/docs-color-vision

Conversation

@nickvigilante

@nickvigilante nickvigilante commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

Merge order

Independent of #298 (the Fumadocs 16.17.9 upgrade). This branch keeps its CSS in a new color-vision.css and leaves brand.css untouched, 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:

Standard and Protanopia and deuteranopia callouts

Design

  • Preference. colorVision joins DISPLAY_PREFERENCES: key docs-color-vision, attribute data-color-vision, values standard, protan-deuter and tritan. 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 CSSWG color-vision-adjustment idea, [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.
  • UI. A stacked radio row of three options, because "Protanopia and deuteranopia" does not fit a three-column segment in the w-64 panel. 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.
  • Palette (packages/docs-theme/src/color-vision.css). Overrides of --color-fd-info/success/idea/warning/error and 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 with html:root[data-color-vision="protan-deuter"] or html:root[data-color-vision="tritan"]; the html prefix out-ranks the More contrast pill rules by specificity, so More needs no twin and the palette is AAA-clean under More already.
  • Checks. contrast:check now also measures the callout colors (on the page and on their 9% tint), color-vision and tritan palettes at AA, and color-vision more and tritan more palettes at AAA, including the code overrides, and still throws on a color-vision rule it cannot place. scripts/cvd.mjs is a small Machado 2009 simulation plus CIEDE2000, and color-vision.test.mjs pins 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.
  • Audit. Callouts keep a title and a per-type icon (Info, CircleCheck, Lightbulb, TriangleAlert, CircleX), pills are text, the ✅/❌ icons differ in shape and carry hidden Yes/No text, the TOC has an indicator thumb, the copy button swaps to a check icon, and Shiki applies only the foreground of diff tokens (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.

Pair Default light New light Default dark New dark
success vs warning 5.3 / 9.2 19.2 / 22.6 5.9 / 8.2 18.0 / 10.3
success vs error 12.7 / 6.0 37.8 / 40.7 22.4 / 12.0 24.6 / 33.3
warning vs error 14.4 / 4.5 30.0 / 19.5 25.2 / 17.3 30.5 / 24.2

Callout colors (contrast on the page, on the 9% tint):

Type Light Dark
info #272a5c (13.4, 11.3) #a1bff3 (10.7, 9.4)
success #06607e (7.0, 6.2) #32d6cc (11.0, 9.8)
idea #480ab0 (10.8, 9.1) #b882ec (7.1, 6.4)
warning #621035 (12.8, 10.7) #d981a6 (7.2, 6.6)
error #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):

Tone Light Dark
purple #bf9df8 / #2b1949 (7.0) #530ba4 / #e1c8fd (7.1)
sky #acd3e3 / #0a2531 (10.0) #122d3f / #d4ebfb (11.6)
orange #fbe1b7 / #48320e (9.5) #6e3f0b / #fbe9d5 (7.4)
red #e3afad / #421e1d (7.7) #460b09 / #e8c5c3 (10.1)
teal #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):

Token Light Dark
info #120f5b (16.9, 14.0) #a8aee0 (9.3, 8.3)
success #0f5991 (7.3, 6.4) #5dc0e8 (9.6, 8.6)
idea #5a18a0 (10.1, 8.6) #ba86f9 (7.5, 6.8)
warning #5a1b40 (12.6, 10.6) #f958da (7.0, 6.5)
error #aa1c10 (7.3, 6.2) #dca99c (9.7, 8.6)
Tone Light Dark
purple #ba95f1 / #210d3f (7.3) #410f8c / #e2d8f3 (9.2)
sky #e3eff6 / #0f3a52 (10.3) #0f2639 / #d8edff (12.9)
orange #fde5c5 / #2f2519 (12.3) #4e3019 / #fbf0e8 (10.6)
red #f39782 / #361912 (7.3) #981614 / #ffefee (7.7)
teal #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):

Palette Protanopia Deuteranopia Tritanopia
Default 5.3 / 2.6 (light), 5.9 / 6.2 (dark) 4.5 / 0.8 (light), 8.2 / 2.8 (dark) 8.6 / 3.9 (light), 7.7 / 2.5 (dark)
Protan-deuter 11.2 / 13.7 (light), 14.0 / 16.0 (dark) 11.8 / 12.3 (light), 10.1 / 15.4 (dark) 7.8 / 8.2 (light), 6.3 / 11.7 (dark)
Tritan 9.1 / 0.5 (light), 2.6 / 4.4 (dark) 5.9 / 5.6 (light), 2.3 / 12.7 (dark) 21.0 / 18.8 (light), 15.3 / 16.2 (dark)

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 #024c1a to #0a5670 (light) and from #7ee787 to #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.

  1. Open the preview's 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."
  2. Select "Protanopia and deuteranopia". The hint changes to "For people who find reds and greens hard to tell apart." and the panel keeps its size. The Premium and Early Access pills change color at once, with no reload and no page jump. Then open install/operate/upgrade/best-practices/ (Note, Tip, Caution callouts) and admin/networking/workspace-proxies/ (a diff fence): the callouts, the diff's added line, and the pill recolor there too.
  3. Reload the page. It comes back already recolored, with no flash of the old colors, and the panel still shows Protanopia and deuteranopia selected.
  4. Select "Tritanopia" and repeat the visits in step 2. The hint changes to "For people who find blues and greens, or yellows and purples, hard to tell apart." Success callouts turn blue, warnings magenta, errors stay red, and the pills take the tritan colors. Reload: it comes back recolored with no flash.
  5. Set Theme to Dark, then Contrast to More, for each of the two non-standard options. Callouts and pills keep their distinct colors and stay readable in each combination.
  6. Keyboard: Tab to the panel, focus the Color vision row, press the Right and Left arrow keys. The selection moves through the three options like the other rows, and the focus ring is visible.
  7. Select Standard. The colors return to the current ones.
  8. Optional, Chrome: DevTools, More tools, Rendering, "Emulate vision deficiencies", Protanopia (or Tritanopia with that setting), with the setting on. Callout types and pill tones stay distinguishable. Firefox's Accessibility panel has a similar "Simulate" menu; I did not verify that step in Firefox DevTools.

Pages to compare

The preview is not deployed by this PR: docs-pr-preview.yml has 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. The authoring/ fixture pages exist only in the CI fixture build.

What to check Production Preview
Premium and Early Access pills in the page header and sidebar https://coder.com/docs/admin/templates/managing-templates/external-workspaces/ <preview>/admin/templates/managing-templates/external-workspaces/
Several callout types (Note, Tip, Caution) https://coder.com/docs/install/operate/upgrade/best-practices/ <preview>/install/operate/upgrade/best-practices/
Note, Tip, and Warning callouts https://coder.com/docs/user-guides/desktop/ <preview>/user-guides/desktop/
A Premium pill and a diff code fence (one added line) https://coder.com/docs/admin/networking/workspace-proxies/ <preview>/admin/networking/workspace-proxies/

Testing

  • pnpm lint, pnpm typecheck, and pnpm test pass; pnpm --filter @coder/docs-theme contrast:check reports 0 new failures, including the color-vision and tritan (AA) and color-vision more and tritan more (AAA) palettes.
  • Axe (a11y:axe, fixture build) passes with 0 new findings across 110 scans: the callouts, states, code, and tables pages in vision-{light,dark}, vision-more-{light,dark}, vision-tritan-{light,dark}, and vision-tritan-more-{light,dark}, plus the open display settings panel in each. a11y:keyboard, csp:check, and first-load:check pass.
  • Playwright on the fixture build, in Chromium and Firefox, light and dark: with the setting stored, the first animation frame already has data-color-vision and the new token values; switching between all three options in the panel applies at once and persists, and a reload with Tritanopia on has data-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.
  • Chromium reports the same layout-shift score with and without the setting on every fixture page (for example 0.094 on the tables page both ways, 0 in Firefox), so the setting adds none. The nonzero Chromium baseline is not from this change and I did not investigate it.
  • Not verified: a real browser's built-in vision-deficiency simulation (Chrome Rendering, Firefox Accessibility), real-corpus pages (only the fixture corpus was built), and the offline export, whose layout renders the same inline script and imports the same theme CSS but was not built here.

Upstream

No. The palette, the Coder vocabulary, and DisplayPreferencesScript are 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.

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
@vercel

vercel Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Actions Updated
coder-docs Skipped Skipped Nov 2, 2026 9:37pm UTC
coder-docs-router Skipped Skipped Nov 2, 2026 9:37pm UTC

Request Review

@linear-code

linear-code Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
DOCS-1474 Add colour-vision settings (protanopia and deuteranopia) to the docs site

Summary

Add 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.
It sits next to Theme, Contrast, and Motion in the Display settings panel.

Why

The docs already meet WCAG 1.4.1 where it matters: callouts, state pills, ✅/❌ icons, and diffs all carry a label, glyph, or sign.
A CVD simulation (Machado 2009, CIEDE2000) shows the hues are still hard to tell apart in places:

  • Light Warning vs Caution callouts: ΔE 4.5 under deuteranopia; light Tip vs Warning: 5.3 under protanopia.
  • Early Access vs Deprecated pills (dark): 2.8 under deuteranopia.
  • Diff +/- line colours (light): 1.8 under deuteranopia.
  • Red and green Shiki tokens (light keyword vs tag): 4.9 under protanopia.

The Coder dashboard already ships light-protan-deuter and dark-protan-deuter themes (site/src/theme/, coder/coder#24672), so the docs should match that vocabulary and palette.
GitHub takes the same approach, swapping red and green for orange and blue.

Scope

  • Add a colorVision entry to DISPLAY_PREFERENCES in packages/docs-next/src/display-preferences.tsx: storage key docs-color-vision, attribute data-color-vision, values standard and protan-deuter.
  • No "system" value, because browsers expose no CVD signal (CSSWG proposal [mediaqueries] CSS Media Feature for Color Vision Adjustments  w3c/csswg-drafts#10335 is not implemented). A missing attribute means standard.
  • Extend DISPLAY_PREFERENCES_SCRIPT so the attribute is set before first paint.
  • Add token overrides in packages/docs-theme for the callout colours (--color-fd-info, -success, -idea, -warning, -error) and the --docs-state-* pill tokens, in light and dark, with and without More contrast.
  • Take the hues from the dashboard (success sky, destructive orange, warning fuchsia), then re-derive them at the docs contrast bar. At 7:1 depth, sky and fuchsia converge (ΔE 1.6 under deuteranopia), so Tip and Warning must also differ in lightness.
  • Override the red and green Shiki token colours with the attribute-selector approach used for the More contrast comment colour.
  • Add a "Color vision" row to display-settings.tsx. The segmented control is three columns wide, so use a stacked radio list or a select for the longer label.

Out of scope

  • Tritanopia. Revisit after the first release; the dashboard has it, and adding a value is cheap once the mechanism exists.
  • Swapping Shiki themes. Shiki does not bundle GitHub's colorblind themes, and extra themes grow every code block.
  • Documenting the dashboard's CVD themes in coder/coder docs. Only the API schema mentions them today; track that separately.

Constraints

  • No new third-party origins (CSP).
  • Cumulative layout shift stays at 0 through load, hydration, and toggling.
  • Must pass axe and contrast:check in every mode combination.

Acceptance criteria

  • Choosing "Protanopia and deuteranopia" changes callout and pill colours at once, with no reload.
  • The choice persists across pages and reloads, and applies before first paint.
  • Under simulated protanopia and deuteranopia, success, warning, and error callouts differ by at least 10 CIEDE2000, pinned by a unit test.
  • contrast:check covers the new palettes at AA, and at AAA with More contrast; its palette parser gains the colour-vision dimension.
  • The axe pass covers the new mode on fixture pages with callouts, pills, ✅/❌, and a diff block.
  • display-preferences.test.tsx and display-settings.test.tsx cover the new preference.

Verify before starting

  • Fumadocs callout icons, the TOC active indicator, and the copy-button success state (not read during research).
  • Whether Shiki applies the theme's diff line backgrounds.

Estimate

About half a day of audit, then 2 to 3 days for the preference and tests.

Upstream

Likely no.
The palette and vocabulary are Coder-specific, and the preference code is ours rather than a Fumadocs extension point.

Created by Coder Agents on behalf of @Vigilante*.*

Review in Linear

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
@vercel
vercel Bot temporarily deployed to Preview – coder-docs-router November 2, 2026 21:37 Inactive
@vercel
vercel Bot temporarily deployed to Preview – coder-docs November 2, 2026 21:37 Inactive
@nickvigilante nickvigilante changed the title feat: add a color vision setting for protanopia and deuteranopia feat: add color vision settings for protanopia and deuteranopia, and tritanopia Nov 2, 2026

This branch was previously deployed

2 inactive deployments
Preview – coder-docs-router — 85e89313 Deployed Nov 2, 2026 by vercel[bot]
Preview – coder-docs — 85e89313 Deployed Nov 2, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant