Skip to content

[Feature] REA's website blinds me at night: add a dark mode #1

Closed

Description

@CassieFox23

Rehearsal copy on my own fork. It walks through issue, PR and merge here first. The real issue goes to morluto/rea later.

TL;DR: rea.tools has no dark mode, so it is very bright at night. The site keeps its main colors in six CSS variables, so most of a dark theme is small. The figures need their own edits. I'll build one here as a rehearsal.

Before submitting

  • I searched the open and closed issues and pull requests for a related proposal.
  • I removed credentials, tokens, private paths, and sensitive target data.

Area

Documentation

Current limitation

The website only has a light theme. website/public/assets/styles.css sets color-scheme: light on :root. So a reader whose system is set to dark still gets a white page. That is hard on the eyes at night.

Use cases

  • Reading a guide at night, or in a dark room.
  • Readers who keep their whole system in dark mode.

Desired outcome and success criteria

  • With the system set to dark, the site uses a dark theme. With it set to light, nothing changes.
  • Text, links and code keep good contrast. The dark colors below all pass WCAG AAA (7:1 or more). The light theme does not change.
  • The figures and code highlights stay readable on the dark page.
  • The figures keep every label, value and arrow. Only colors change.
  • Checked in both schemes at 320 px and 1280 px, at the site root and under /rea/.
  • python3 scripts/website.py check still passes.

Authority boundaries and non-goals

  • No toggle button and no saved setting. It follows the system setting only.
  • No new layout, fonts or effects. The style guide's look stays the same.
  • Only the website. Not the VitePress docs build.
  • The sharing image stays light. Link previews ignore the system setting.

Alternatives considered

  • A toggle button. It needs JavaScript and storage, so I left it out.
  • Leaving it to browser dark-mode add-ons. Those often break diagrams and code blocks.

Possible direction

  • Add a @media (prefers-color-scheme: dark) block that sets color-scheme: dark and swaps the six variables.
  • The stylesheet also has 37 fixed colors: 32 hex values and five uses of white. Swap them, or move them into variables first.
  • The 5 SVG figures all have white fills. Pages load them with <img>, so page CSS cannot restyle them. Each needs its own @media (prefers-color-scheme: dark) block inside the file, or a light backing on the dark page. One figure, th04-bullet-ring.svg, already has a <style> block to extend.
  • Swap ::selection (styles.css line 38) and give the dark agent terminals a visible border. Their #202933 background is almost the same as the dark page.
  • Add a dark theme-color meta tag. The light one is in website/templates/page.html and 17 pages.
  • The blog page blog/touhou-reconstruction/index.html has five inline arrow strokes with fixed colors. The dinosaur game in assets/dino-demo.js draws with fixed colors too.
  • Add a dark column to the color table in website/style-guide.md, so the guide stays the source of truth.

I'd suggest the colors of Catppuccin Mocha, an MIT-licensed palette. A mapping is in the fold below. I'm happy to use any other dark colors you prefer.

References

  • website/style-guide.md, "Use the existing visual system", lists the six variables. They are set in website/public/assets/styles.css lines 1 to 8, with color-scheme: light on line 2. Main at 0ecf3f2.
  • The Catppuccin palette is under the MIT license.
The dark colors I propose
Variable Light now Dark (Catppuccin Mocha)
--page #ffffff #1e1e2e (base)
--ink #20252b #cdd6f4 (text)
--muted #5b6570 #a6adc8 (subtext0)
--line #e0e5e9 #45475a (surface1)
--soft #f4f6f8 #181825 (mantle)
--accent #294f82 #89b4fa (blue)

Contrast ratios, computed with the WCAG formula:

Pair Light now Dark
Main text on page 15.4:1 11.3:1
Secondary text on page 5.9:1 7.4:1
Links on page 8.3:1 7.8:1

🤖 Generated with Claude Code (Opus 5.5, verified by Fable 5.1) 🦊

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions