Repository navigation
Add a dark mode - #57
Merged
Merged
Conversation
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.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.