♻️ Refactor: DRY dark-mode SCSS with shared CSS tokens#526
Merged
Conversation
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.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
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 bodybackground-coloroverride by routing it throughvar(--ed-bg).--ed-surface-elevated#1a2238--ed-border-faintrgb(255 255 255 / 12%)--ed-overlay-faintrgb(255 255 255 / 4%)--ed-overlay-softrgb(255 255 255 / 6%)--ed-overlay-mediumrgb(255 255 255 / 8%)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
color.adjust(...)calls — they feed Bootstrap's compile-time variable pipeline (e.g.$link-hover-color); rewriting ascolor-mix(...)would force us to reproduce Bootstrap's derivations in runtime CSS.rgba($ed-navy, .88)on themed surfaces — looks like acolor-mixcandidate 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-controlborder opacity unified at 12% (was 15%, lone outlier among seven 12% borders). Visually negligible, avoids a one-off token..card-header-themednow picks up--ed-overlay-softfor cross-theme consistency.Test plan
https://expandeddecks.wipandhttps://expandedtalks.wip— visuals identical to v1.10.0 (cards, dropdowns, modals, forms, tables, popovers, list groups all still flip correctly)..cardin dark mode resolves--bs-card-bg→var(--ed-surface-elevated)→#1a2238.Diff: +34 / −27.