Skip to content

Add a dark mode - #57

Merged
PeterSlijkhuis merged 2 commits into
mainfrom
dark-mode
Oct 8, 2026
Merged

PeterSlijkhuis merged 2 commits into
mainfrom
dark-mode

Conversation

@PeterSlijkhuis

@PeterSlijkhuis PeterSlijkhuis commented Oct 8, 2026 •

Copy link
Copy Markdown
Owner

Before: StatLab only had a light theme, so it stayed bright even when the student's system was set to dark.

After: on a first visit the site follows the system setting. A "Dark mode" button at the bottom of the sidebar's Reference list switches the theme and remembers the choice in the browser. A small script in index.html applies the theme before the first paint, so a dark page never flashes white.

How: the colours that had been typed straight into component styles now come from theme tokens in src/App.css, and a [data-theme="dark"] block redefines those tokens. Some things keep fixed colours on purpose. The R editor is shown inverted, which keeps CodeMirror's syntax colours readable. Code output, R plots and the simulations stay as they are, because they are figures. The University of Twente and BMS Lab logos are shown white on the dark page.

Checks: the accessibility scan (e2e/accessibility.spec.ts) now runs on every page in both themes, and both pass locally. Unit tests pass, including a new Sidebar test for the toggle. A few light-mode tints moved by a shade where near-identical colours were merged into one token.

The site follows the system setting on a first visit, and a Dark mode
button in the sidebar switches it and remembers the choice. Colours that
were typed into component styles are now theme tokens, so both themes
come from one set of values. The R editor, code output, plots and the
simulations keep their own colours. The accessibility scan now checks
every page in both themes.
@PeterSlijkhuis PeterSlijkhuis self-assigned this Oct 8, 2026
Until the student picks a theme, switching the system to dark or light
now switches the page straight away instead of on the next load. The
browser bar colour on phones follows the theme too.
@PeterSlijkhuis
PeterSlijkhuis marked this pull request as ready for review October 8, 2026 09:30
@PeterSlijkhuis
PeterSlijkhuis merged commit 7467ba6 into main Oct 8, 2026
4 checks passed
@PeterSlijkhuis
PeterSlijkhuis deleted the dark-mode branch October 8, 2026 09:32
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