[Repo Assist] Migrate theme colors to CSS light-dark() function#1059
Draft
github-actions[bot] wants to merge 2 commits intomainfrom
Draft
[Repo Assist] Migrate theme colors to CSS light-dark() function#1059github-actions[bot] wants to merge 2 commits intomainfrom
light-dark() function#1059github-actions[bot] wants to merge 2 commits intomainfrom
Conversation
Replace the separate [data-theme=dark] block of variable overrides with
light-dark(light-val, dark-val) syntax in :root, so the browser resolves
colors automatically based on the active color-scheme.
- Add color-scheme: light dark to :root (enabling automatic system-preference
following when no explicit theme is chosen)
- Replace 25 color variables that differed between light/dark with light-dark()
- Reduce [data-theme=dark] to only color-scheme: dark (activates dark values)
- Add [data-theme=light] { color-scheme: light } to support explicit light
override when OS is dark
- Simplify fsdocs-theme-set-dark.js: apply saved localStorage preference early
(removes the now-redundant prefers-color-scheme JS check, since CSS handles
the system default automatically)
- Keep [data-theme=dark] ::backdrop rule unchanged (opacity cannot use light-dark())
Closes #1004
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This was referenced Mar 1, 2026
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.
🤖 This PR was created by Repo Assist, an automated AI assistant.
Closes #1004
As requested by @nojaf in #1004.
Summary
Migrates all theme color variables from a separate
[data-theme=dark]override block to CSSlight-dark(light-value, dark-value)syntax in:root. This is a clean, self-contained refactor that:prefers-color-schemewithout any JS when no user preference is savedChanges
docs/content/fsdocs-default.csscolor-scheme: light dark;to:rootso the browser knows the page supports both schemeslight-dark(light-val, dark-val)inline[data-theme=dark]override block; replace with a minimal:color-schemeproperty on the root element driveslight-dark()resolution throughout the page.[data-theme=dark] { ::backdrop { opacity: 0.75 } }rule unchanged (non-color properties can't uselight-dark())docs/content/fsdocs-theme-set-dark.jsSimplify the early-load script:
localStorage+matchMedia("@media(prefers-color-scheme: dark)")(the@mediaprefix was actually a bug;matchMediadoesn't use it), then only setdata-theme=darkfor dark preferencelocalStoragehas a saved preference, setdata-themeto that value. If no preference, do nothing — CSSlight-dark()withcolor-scheme: light darkwill automatically follow the OS preference with zero JS overhead.RELEASE_NOTES.mdAdded entry under
## [Unreleased]/### Changed.Behaviour
:root— light colours:rootwithcolor-scheme: light dark—light-dark()resolves to light ✅data-theme=dark→ dark colourslight-dark()resolves to dark automatically ✅ (no JS needed)data-theme=darkset → CSS overridesdata-theme=darkset →color-scheme: dark→light-dark()resolves to dark ✅data-themenot set (only dark was set) → light coloursdata-theme=lightset →color-scheme: light→light-dark()resolves to light ✅The last row is actually an improvement: previously if a user explicitly saved 'light' theme but their OS switched to dark, the old code wouldn't set
data-themeat all, which withlight-dark()would have defaulted to OS dark. The new code setsdata-theme=lightexplicitly, overriding the OS preference as intended.Test Status
This is a CSS and minor JS change with no F# code impact.