Skip to content

♻️ Refactor: DRY dark-mode SCSS with shared CSS tokens#526

Merged
jbourdin merged 1 commit intodevelopfrom
experimental/scss-simplify
May 6, 2026
Merged

♻️ Refactor: DRY dark-mode SCSS with shared CSS tokens#526
jbourdin merged 1 commit intodevelopfrom
experimental/scss-simplify

Conversation

@jbourdin
Copy link
Copy Markdown
Owner

@jbourdin jbourdin commented May 6, 2026

Summary

Promote five repeated dark-surface literals to CSS custom properties declared once on :root[data-bs-theme="dark"], then reference them throughout the dark-mode block. Drop the redundant body background-color override by routing it through var(--ed-bg).

New token Resolves to Replaces N literals
--ed-surface-elevated #1a2238 5
--ed-border-faint rgb(255 255 255 / 12%) 7
--ed-overlay-faint rgb(255 255 255 / 4%) 3
--ed-overlay-soft rgb(255 255 255 / 6%) 3
--ed-overlay-medium rgb(255 255 255 / 8%) 2

Affected selectors: .card, .dropdown-menu, .modal-content, .popover, .list-group, .table, .alert, .form-control, .form-select, .card-header-themed, .table-themed thead, .cms-content blockquote's neighbours.

What deliberately stayed the same

  • SCSS color.adjust(...) calls — they feed Bootstrap's compile-time variable pipeline (e.g. $link-hover-color); rewriting as color-mix(...) would force us to reproduce Bootstrap's derivations in runtime CSS.
  • rgba($ed-navy, .88) on themed surfaces — looks like a color-mix candidate but isn't: dark mode wants a different recipe (overlay on dark) rather than the same recipe with a swapped palette.
  • :root { --ed-navy: #{$ed-navy}; } SCSS interpolation — keeps the light-mode source of truth in one place; bare-hex would invite drift between the SCSS variable and its CSS-var mirror.

Cosmetic notes

  • .form-control border opacity unified at 12% (was 15%, lone outlier among seven 12% borders). Visually negligible, avoids a one-off token.
  • expandedtalks dark .card-header-themed now picks up --ed-overlay-soft for cross-theme consistency.

Test plan

  • CI green.
  • Toggle macOS dark/light on https://expandeddecks.wip and https://expandedtalks.wip — visuals identical to v1.10.0 (cards, dropdowns, modals, forms, tables, popovers, list groups all still flip correctly).
  • DevTools sanity check: a .card in dark mode resolves --bs-card-bgvar(--ed-surface-elevated)#1a2238.

Diff: +34 / −27.

Promote the repeated dark-surface literals (#1a2238 ×5, white/12% ×7,
white/4% ×3, white/6% ×3, white/8% ×2) to scoped CSS custom properties
declared once at :root[data-bs-theme="dark"]:

  --ed-surface-elevated  #1a2238
  --ed-border-faint      rgb(255 255 255 / 12%)
  --ed-overlay-faint     rgb(255 255 255 / 4%)
  --ed-overlay-soft      rgb(255 255 255 / 6%)
  --ed-overlay-medium    rgb(255 255 255 / 8%)

Rewrite the Bootstrap-component dark overrides (.card, .dropdown-menu,
.modal-content, .popover, .list-group, .table, .alert, .form-control)
and the themed surfaces (.card-header-themed, .table-themed thead,
rich-text tables) to read from those tokens. Drop the redundant
[data-bs-theme="dark"] body { background-color: var(--ed-bg) } rule by
moving body's background-color from $ed-bg to var(--ed-bg) directly,
so the dark variant takes effect through the existing --ed-bg switch.

Cosmetic tightening: .form-control border opacity unified at 12% (was
15%, lone outlier among 7 borders at 12%).

expandedtalks dark .card-header-themed picks up the same
--ed-overlay-soft for consistency across themes.
@sentry
Copy link
Copy Markdown

sentry Bot commented May 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@jbourdin jbourdin merged commit f92ee4c into develop May 6, 2026
6 checks passed
@jbourdin jbourdin deleted the experimental/scss-simplify branch May 6, 2026 08:31
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