[3.0] Theme split (wave 5, part 2) — give the default theme a dark mode - #9497
Open
albertlast wants to merge 2 commits into
Open
[3.0] Theme split (wave 5, part 2) — give the default theme a dark mode#9497albertlast wants to merge 2 commits into
albertlast wants to merge 2 commits into
Conversation
Wave 4 tokenised index.css area by area and left a remainder: 55 declarations that no area owned, scattered across the file. This takes those, so that every colour the default theme draws now resolves through variables.css. Most are one-offs - the forum title link, the current page number, the status words, the COPPA contact block, the error file viewer, the warning level bars. Three are not: the sheen gradients on raised controls, on their hover state and on the overlay surfaces are each shared by a long selector list spanning menus, quick buttons, popups and post options, so they are named for what they are rather than for any one component that uses them. Every token is seeded with the literal it takes over from, so this is not meant to change what the forum looks like, and does not. Verified by recording the computed color, background, background-image, border colours, box-shadow, outline and text-shadow of every element on twelve pages - the board index, a topic, the poster, the profile, the stats, help, search, the calendar, personal messages, the admin centre, its permission grid and its theme list - before and after: 4254 elements, zero differences. The one literal left is the diagonal stripe the progress bar draws over its fill, which is a translucent white texture rather than a colour. Signed-off-by: Mathias Alberts <mathiaspapealbert@hotmail.com> Signed-off-by: albertlast <mathiaspapealbert@hotmail.com>
The colour mode plumbing has been in 3.0 since Alpha: Theme.php resolves the mode, Themes.template.php and ThemeOptions.php offer it to the admin and the member, index.template.php writes it into data-mode, and dark.css has sat in the theme as a placeholder. None of it has ever run. Turning the flag on was not enough, because the feature is broken in four places rather than one. loadMode() had no callers. It is the method that resolves the mode and loads dark.css, and nothing anywhere invoked it, so data-mode was never emitted and the stylesheet was never asked for. It is now called beside loadVariant(), which is its sibling and is read by the same line of the template. The 'system' mode lost the very thing that makes it 'system'. That mode works by loading dark.css with a (prefers-color-scheme: dark) media attribute, but attributes are only printed for files served on their own - loadCSSFile() defaults to minimizing, and a file folded into the bundle loses them. The browser was never asked, so 'system' would have meant 'always dark'. That mode now opts out of the bundle; 'light' and 'dark' carry no attribute and still share one cached file. Saving the chosen mode to a member's profile was fatal. Db::insert() wants a list of rows and was handed a single flat one, which is a critical error rather than a warning outside backward compatibility mode, so the first time a logged in member chose a mode the page died. loadVariant() has the identical defect three lines further down; it is left alone here because this branch neither enables nor exercises variants, and shipping an unverified fix is worse than recording a known one. dark.css itself is written against release-3.0's own tokens rather than ported. The snapshot on SimpleMachines#7933 could not be used: of its 197 overrides only 84 name a token that exists here, while 213 colour-bearing tokens here have no value in it. It overrides 243 tokens and restates no rules, all written against twelve values declared at the top of the file, so the way to review it is to agree those and then check each component reached for the right one. The ramps are deliberately untouched, so a variant still re-tints the forum by moving --primary-color-hue and dark mode moves with it. Verified on a running forum. Light mode is unchanged: the computed colours of 4254 elements over twelve pages are identical with the file present and absent. All three modes emit the right markup and the right stylesheets, including the media attribute on 'system' alone. Eighteen pages were swept in both modes for text that lands on a background too close to it; dark mode has nineteen elements below the AA ratio against light mode's hundred and thirty-six, and both dark causes sit outside the theme - the bundled coloris colour picker, which carries no tokens at all, and the Administrator group's online_color, which is data. No errors were logged. Signed-off-by: Mathias Alberts <mathiaspapealbert@hotmail.com> Signed-off-by: albertlast <mathiaspapealbert@hotmail.com>
This was referenced Aug 11, 2026
Closed
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.
Description
The colour mode plumbing has been in 3.0 since Alpha.
Theme.phpresolves the mode,Themes.template.phpandThemeOptions.phpoffer it to the admin and the member,index.template.phpwrites it intodata-mode, anddark.csshas sat in the theme as a placeholder waiting to be filled.None of it has ever run. Turning the flag on is not enough, because the feature is broken in four places rather than one. Each of these was found by trying to use it, not by reading it.
Theme::loadMode()had no callersdark.css. Nothing anywhere invoked it, sodata-modewas never emitted and the stylesheet never requested. Now called besideloadVariant(), its sibling, which the same line of the template reads.systemlost the thing that makes itsystemdark.csswith a(prefers-color-scheme: dark)media attribute. But attributes are only printed for files served on their own,loadCSSFile()defaults to minimizing, and a file folded into the bundle loses them — so the browser was never asked andsystemwould have meant always dark. That mode now opts out of the bundle.lightanddarkcarry no attribute and still share one cached file.Db::insert()wants a list of rows and was handed a single flat one. Outside backward-compatibility mode that is a critical error, so the first time a logged-in member picked a mode the page died with Invalid data structure sent to the database.dark.csswas emptyThe stylesheet
Written against
release-3.0's own tokens rather than ported. The snapshot on #7933 could not be used: of its 197 overrides only 84 name a token that exists here, while 213 colour-bearing tokens here have no value in it. Taken as-is it would have produced a dark mode with most of the forum still showing its light values.It overrides 243 tokens and restates no rules. Everything is written against twelve values declared at the top of the file — five surfaces, two hairline weights, three text weights and two link colours — so the way to review this is to agree those twelve and then check that each component reached for the right one.
The primary and secondary ramps are deliberately left untouched. They carry the theme's identity and a variant re-tints the forum by moving
--primary-color-hue; leaving them alone means dark mode moves with it. Where a token pointed at the dark end of a ramp because it was drawn on a light surface, the override points it at the light end instead, rather than redefining what the ramp means.Verification
Run against a real forum, not read.
color,background-color,background-image, all four border colours,box-shadow,outline-colorandtext-shadowfor every element on twelve pages, with the file present and absent: 4254 elements, 0 differences.systemand onsystemalone.Known gaps, both outside the theme
The 19 are two causes, neither of them a token:
coloris.min.css) is third-party and carries no tokens at all, so itsHex/RGB/HSLlabels stay light-on-light. Same class of thing as.sceditor-container— not ours to name.online_coloris#FF0000, set by the installer. That is data, not styling, and it is marginal in light mode too.Depends on #9496 (wave 5, part 1), which gives the last hard-coded colours in
index.cssa token. Without it#wrapperkeeps a white background, the.titlebgheadings stay#555on a dark bar and the three sheen gradients stay pale. This branch is stacked on it, so the diff here isdark.css,Theme.phpand one flag.loadVariant()carries the identicalDb::insert()defect three lines below the one fixed here. It is left alone deliberately: this branch neither enables nor exercises variants, and shipping a fix I cannot verify is worse than recording a known one.Part 2 of wave 5 of the #7933 split.
Issues References (Fixes|Related|Closes)
Related #7933