mirror of
https://github.com/harvard-edge/cs249r_book.git
synced 2026-05-21 13:31:55 -05:00
[PR #1751] fix(book): add body.quarto-dark selectors to foldbox dark mode CSS #14650
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/harvard-edge/cs249r_book/pull/1751
Author: @Shashank-Tripathi-07
Created: 5/17/2026
Status: 🔄 Open
Base:
dev← Head:fix/foldbox-css-quarto-dark-toggle📝 Commits (1)
4ed27bdfix(book): add body.quarto-dark selectors to foldbox dark mode CSS📊 Changes
2 files changed (+63 additions, -26 deletions)
View changed files
📝
book/quarto/_extensions/mlsysbook-ext/custom-numbered-blocks/style/foldbox.css(+28 -1)📝
book/quarto/_extensions/mlsysbook-ext/custom-numbered-blocks/style/foldbox.lua(+35 -25)📄 Description
Bug
All callout boxes (Learning Objectives, Quiz Question, Checkpoint, Definition, etc.) render incorrectly when the reader uses Quarto's manual dark mode toggle button.
The toggle adds
body.quarto-darkto the body element, butfoldbox.cssand the Lua-generated inline<style>block both used only@media (prefers-color-scheme: dark)for dark mode detection. That media query fires on OS-level system preference only. When a reader is on a light-mode OS and clicks the toggle:#f0f0f0text on a near-white background -- completely invisibleRoot cause
Two files were affected:
foldbox.css-- structural dark rules (base text color, content background, arrows) only under@media (prefers-color-scheme: dark).foldbox.lua-- per-callout dark rules (border color, background opacity, summary text, code color) generated dynamically from YAML and emitted into an inline<style>block, again only under@media (prefers-color-scheme: dark).Fix
foldbox.css: Duplicate all dark mode rules underbody.quarto-darkselectors alongside the existing@mediablock.foldbox.lua: RefactorgenerateDarkModeCSS()to extract per-callout rule emission into a sharedemitCalloutRules(prefix)helper. Call it twice -- once inside@media (prefers-color-scheme: dark) {}and once withbody.quarto-darkas the selector prefix. Adding a new callout type in YAML still requires no CSS changes.Test plan
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.