mirror of
https://github.com/harvard-edge/cs249r_book.git
synced 2026-05-06 09:38:33 -05:00
Shared SCSS architecture
This directory holds the cross-site SCSS layer for the MLSysBook ecosystem. Subsites import from here so the look & feel stays coherent across the landing page, the textbook, labs, kits, slides, instructors, MLSys·im, and TinyTorch.
File map
shared/styles/
├── _brand.scss # raw brand colours (single source of truth)
├── _ecosystem-base.scss # light-mode ecosystem defaults
├── _ecosystem-base-dark.scss # dark-mode ecosystem defaults
├── _site-dark.scss # dark-mode rules used by the site (landing/about/etc.)
├── _book-only.scss # textbook-only rules
├── _book-only-dark.scss # textbook-only dark-mode rules
├── style-site.scss # entrypoint for site pages (landing/about/community/newsletter)
├── dark-mode-site.scss # dark-mode entrypoint for site pages
├── BRAND.md # palette + non-SCSS hardcoded reference list
├── partials/
│ ├── _tokens.scss # typography + callout palette (depends on theme $accent)
│ ├── _navbar.scss
│ ├── _sidebar.scss
│ ├── _buttons.scss
│ ├── _links.scss
│ ├── _headers.scss
│ ├── _toc.scss
│ ├── _tables.scss
│ ├── _blockquotes.scss
│ ├── _figures.scss
│ ├── _callouts.scss
│ └── _mobile.scss
└── themes/
├── _theme-harvard.scss # Vol I + site (Harvard Crimson)
├── _theme-eth.scss # Vol II (ETH Blue)
├── _theme-labs.scss
├── _theme-kits.scss
├── _theme-instructors.scss
└── _theme-tinytorch.scss
Layering contract
flowchart TD
Brand[_brand.scss<br/>raw colors]
Theme[themes/_theme-*.scss<br/>$accent, $accent-dark, $callout-*]
Tokens[partials/_tokens.scss<br/>typography + derived callouts]
Partials[partials/_navbar, _links, _buttons, ...]
Entry[style-site.scss<br/>or per-subsite entrypoint]
Dark[dark-mode-*.scss]
Brand --> Theme
Theme --> Tokens
Tokens --> Entry
Theme --> Entry
Partials --> Entry
Entry --> Output[compiled CSS]
Theme --> Dark
Dark --> Output
Concretely:
_brand.scssdefines raw hex values once.- A theme file (
_theme-harvard.scss,_theme-eth.scss, ...) imports_brand.scssand exposes semantic variables$accent,$accent-dark,$callout-info,$callout-success,$callout-caution,$callout-secondary. partials/_tokens.scssand the rest of the partials assume those semantic variables already exist.- A site entrypoint (e.g.
style-site.scssorbook/quarto/assets/styles/style-vol1.scss) imports the theme first, then_tokens, then any partials it needs. - Dark-mode entrypoints (
dark-mode-*.scss) re-import the theme so$accent-darkis in scope, then layer dark-only rules.
The /*-- scss:defaults --*/ and /*-- scss:rules --*/ markers are Quarto's
way of separating Sass variable defaults from CSS rules; keep them aligned
with this layering.
Per-subsite entrypoints
| Subsite | Light entry | Dark entry |
|---|---|---|
| Site (landing/about/community/newsletter) | shared/styles/style-site.scss |
shared/styles/dark-mode-site.scss |
| Book Vol I | book/quarto/assets/styles/style-vol1.scss |
book/quarto/assets/styles/dark-mode-vol1.scss |
| Book Vol II | book/quarto/assets/styles/style-vol2.scss |
book/quarto/assets/styles/dark-mode-vol2.scss |
| Labs | labs/assets/styles/style.scss |
labs/assets/styles/dark-mode.scss |
| Kits | kits/assets/styles/style.scss |
kits/assets/styles/dark-mode.scss |
| Slides | slides/assets/styles/style.scss |
slides/assets/styles/dark-mode.scss |
| Instructors | instructors/assets/styles/style.scss |
instructors/assets/styles/dark-mode.scss |
| MLSys·im docs | mlsysim/docs/styles/style.scss |
mlsysim/docs/styles/dark-mode.scss |
| TinyTorch (Quarto) | tinytorch/quarto/assets/styles/style.scss |
tinytorch/quarto/assets/styles/dark-mode.scss |
The book Vol I / Vol II theme files in book/quarto/assets/styles/themes/
are symlinks to the canonical files in shared/styles/themes/.
Brand palette
See BRAND.md for the canonical palette and the list of
non-SCSS surfaces (HTML configs, plain CSS, SVG, JS, Python) that still
hardcode colour values.
Conventions
- Edit raw colours only in
_brand.scss. - New shared component → add to
partials/and import explicitly from each entrypoint that needs it (do not auto-import everything; some subsites intentionally skip e.g. callouts). - New ecosystem subsite → create a
themes/_theme-<subsite>.scssthat imports_brand.scssand defines$accent/$accent-dark, then point the subsite'sstyle.scssat it. - Light/dark are still separate files for now; merging them via
prefers-color-schememedia queries is a future cleanup.