Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #365 +/- ##
=======================================
Coverage ? 45.92%
=======================================
Files ? 2
Lines ? 405
Branches ? 0
=======================================
Hits ? 186
Misses ? 219
Partials ? 0
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
🎭 Visual Regression Test ResultsDetails
Skipped testsmobile-chrome › theme.spec.ts › Theme Features › f-string interpolation styling |
There was a problem hiding this comment.
Pull request overview
This PR implements a comprehensive dark theme overhaul for the QuantEcon Book Theme, replacing the previous ad-hoc collection of ~35 inconsistent dark mode CSS rules with a cohesive design system based on a well-defined color palette. The changes address multiple critical bugs (dark-on-dark table text, indistinguishable links, broken images/SVGs, poor inline code styling) and add comprehensive VS Code Dark+ inspired syntax highlighting for ~40 token types. A new FOUC (Flash of Unstyled Content) prevention script ensures the dark theme is applied before the page renders when dark mode is saved in localStorage.
Changes:
- Complete rewrite of
_dark-theme.scss(~550 lines) with organized sections for all UI components using a consistent 8-color palette - Added ~224 lines of dark mode syntax highlighting tokens in
_code.scsswith VS Code Dark+ inspired colors - Updated
_stderr.scssdark mode colors to match the new palette - Added early-executing dark mode script in
layout.htmlto prevent FOUC, plus dark mode overrides for non-QuantEcon projects
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
src/quantecon_book_theme/theme/quantecon_book_theme/layout.html |
Adds FOUC prevention script and non-QuantEcon project dark mode overrides for links, borders, and toctree captions |
src/quantecon_book_theme/assets/styles/_stderr.scss |
Updates dark mode stderr warning colors from #ffc107 to #d4a017 with semi-transparent backgrounds matching new palette |
src/quantecon_book_theme/assets/styles/_dark-theme.scss |
Complete rewrite with consistent color palette, organized sections for all components (toolbar, sidebar, tables, admonitions, modals, etc.) |
src/quantecon_book_theme/assets/styles/_code.scss |
Adds comprehensive dark mode syntax highlighting palette for all Pygments token types using :where() for low specificity |
src/quantecon_book_theme/theme/quantecon_book_theme/layout.html
Outdated
Show resolved
Hide resolved
src/quantecon_book_theme/theme/quantecon_book_theme/layout.html
Outdated
Show resolved
Hide resolved
src/quantecon_book_theme/theme/quantecon_book_theme/layout.html
Outdated
Show resolved
Hide resolved
Complete rewrite of the dark theme for a modern, consistent, and readable dark mode experience. Color palette: - Replace ad-hoc grays (#222/#333/#444) with a cohesive navy-charcoal palette - Body background: #1a1a2e, Surfaces: #252540/#2d2d4a - Text: #d4d4e4 (soft white, reduces eye strain vs pure #fff) - Links: #6cb6ff (distinguishable from body text) - Borders: #3a3a5c (subtle, consistent) Syntax highlighting: - Add complete dark mode token colors for all ~40 syntax classes - VS Code Dark+ inspired palette - Previously only 3 of ~40 tokens had dark overrides Bug fixes: - Fix table row text color (#333 on dark bg was unreadable) - Fix links being indistinguishable from body text (all were #fff) - Fix inline code having light border on dark background - Fix sidebar search area remaining white in dark mode - Fix toolbar border remaining light gray - Fix image inversion being too aggressive (now uses subtle opacity) New dark mode coverage: - Modals, admonitions (type-specific accents), homepage elements - Collapse/toggle bars, tooltips, anchor links, autodoc, footnotes - Non-QuantEcon project color overrides, toctree caption text UX improvements: - Eliminate FOUC with early dark mode injection script - SVG icons use currentColor instead of forced white - Images use subtle opacity reduction instead of aggressive inversion - Stderr warnings updated to match new palette
66774f4 to
063328d
Compare
- Flatten SCSS nesting to plain CSS in layout.html <style> tag (browsers can't parse SCSS) - Add missing semicolon in .toctree-wrapper .caption-text rule - Scope svg g selector to UI icon containers only (.qe-toolbar, .qe-sidebar, .topbar-main, nav) to avoid breaking matplotlib/plotly charts - Remove duplicate .highlight rules (unreachable :where() block) - Use strict equality (=== '1') in FOUC prevention script
|
/update-snapshots |
|
✅ All visual snapshots have been regenerated and committed to this PR. 📦 Download snapshot-update-diff artifact to review before/after images. |
Declare 16 CSS custom properties on body.dark-theme so downstream projects can override palette colors without duplicating selectors: --qe-dark-bg, --qe-dark-surface, --qe-dark-surface-alt, --qe-dark-border, --qe-dark-text, --qe-dark-text-muted, --qe-dark-heading, --qe-dark-heading-top, --qe-dark-text-light, --qe-dark-link, --qe-dark-link-hover, --qe-dark-link-visited, --qe-dark-code-bg, --qe-dark-inline-code, --qe-dark-accent, --qe-dark-accent-dark All ~120 hardcoded palette hex values replaced with var() references. Semantic colors (admonition accents, modal button text) remain hardcoded intentionally. Docs updated with full reference table of available properties.
The :only-child fallback was matching .logo-img:only-child, but each <img> is always the sole child of its own <a> wrapper, so it matched even when a dark logo existed — showing both logos. Fixed by checking :only-child on the <a> wrapper instead: p.logo > a:only-child > .logo-img When a dark logo IS configured there are two <a> siblings inside <p class="logo">, so a:only-child won't match and only the dark logo is shown. Fixes: double logo issue reported in PR #365
|
Fixed in ccdc837. The root cause was the The bug: The fix: Check // Before (buggy — always matches):
.logo-img:only-child { display: block; filter: invert(100%)... }
// After (correct — only matches when no dark logo <a> sibling exists):
p.logo > a:only-child > .logo-img { display: block; filter: invert(100%)... }When a dark logo IS configured, the |
The page header (title link, authors, 'Last changed' button) and the changelog dropdown used colors.$body (#444) which is invisible on the dark background. Added dark theme overrides for the full .qe-page__header section: - Title link → heading-top color - Authors → primary text - 'Last changed' button → muted text with accent border - Changelog dropdown → dark surface background, proper borders - Commit hash, author, time, message → appropriate text colors
Add entries for: - CSS custom properties refactor (16 overridable --qe-dark-* vars) - Double logo fix (only-child selector bug) - Page header/changelog readability fix
The dark theme applied font-weight: 600 to .reference links, making them visually heavier than in light mode. Color alone provides sufficient contrast on dark backgrounds.
|
Silky reading on iPhone after dark. Lovely theme addition. |
|
thanks @DrDrij -- I did some research on contrast ratio's :-) |

Comprehensive Dark Theme Overhaul
A complete rewrite of the dark theme for a modern, consistent, and readable dark mode experience. The previous dark theme had numerous issues identified through a deep audit — this PR addresses all of them.
Before / After Summary
The old dark theme used an ad-hoc collection of ~35 CSS rules with inconsistent gray values (
#222,#333,#444,#fff). This PR replaces it with a cohesive design system.Color Palette
#222#1a1a2e(deep navy-charcoal)#333(everything the same)#252540/#2d2d4a(visual hierarchy)#fff(pure white, harsh)#d4d4e4(soft white, reduced eye strain)#fff(indistinguishable from text)#6cb6ff(clearly identifiable)#ccc(light mode leftover)#3a3a5c(subtle, dark-appropriate)Critical Bugs Fixed
#333(dark on dark) — now properly readable#fff, identical to body text — now distinct blue#6cb6ffwith hover/visited statesinvert(100%)broke photos/charts — now uses subtle opacity reductioncurrentColor#ccccccdotted border on dark background — now#3a3a5cSyntax Highlighting (NEW)
Previously only 3 of ~40 token types had dark mode colors. This PR adds a complete VS Code Dark+ inspired palette:
#c586c0)#ce9178)#b5cea8)#dcdcaa)#4ec9b0)#7c8a9e)#9cdcfe)New Component Coverage
Components that previously had zero dark mode styling:
UX Improvements
dark-themeclass before the page renders, eliminating the white flashinvert(100%) hue-rotate(-180deg)with subtle opacity reduction that preserves photo/chart colorsFiles Changed
Testing
npm run buildcompiles successfullypre-commit run --all-filespasses all checks