From c6182a8fb4c1916da79daa5e064fbae08eb57732 Mon Sep 17 00:00:00 2001 From: albertlast Date: Wed, 9 Sep 2026 05:56:27 +0200 Subject: [PATCH] Loads the stylesheet a theme variant is recoloured with A theme has two ways to recolour a variant. One is a single variants.css holding :root[data-variant="..."] blocks, which loadVariant() already loads. The other is a whole stylesheet per variant, sitting on top of index.css, which the default theme documents in index.template.php: Define the theme variants. Each variant has its own CSS file. Example: - index_red.css is loaded when the user selects the `red` variant. Nothing loaded it. The file goes in at order_pos 2, after index.css and beside dark.css, so it overrides the base sheet. The 'default' variant is the base sheet by itself and has no file to load; for any other variant the file is validated before it is queued, so a theme that recolours through variants.css instead is unaffected. Co-Authored-By: Claude Opus 5 Signed-off-by: albertlast --- Sources/Theme.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Sources/Theme.php b/Sources/Theme.php index 3a11fde8d8..0a1f4a24b1 100644 --- a/Sources/Theme.php +++ b/Sources/Theme.php @@ -2285,6 +2285,17 @@ protected function loadVariant(): void if (Utils::$context['theme_variant'] == '' || !\in_array(Utils::$context['theme_variant'], $this->settings['theme_variants'])) { Utils::$context['theme_variant'] = !empty($this->settings['default_variant']) && \in_array($this->settings['default_variant'], $this->settings['theme_variants']) ? $this->settings['default_variant'] : $this->settings['theme_variants'][0]; } + + /* + * The other way to recolour a variant is a whole stylesheet of its + * own, sitting on top of index.css. The 'default' variant is the base + * sheet by itself, so it has no file of its own to load, and a theme + * that recolours through variants.css above has none either - the + * file is validated, so a missing one is simply not loaded. + */ + if (Utils::$context['theme_variant'] !== 'default') { + self::loadCSSFile('index_' . Utils::$context['theme_variant'] . '.css', ['order_pos' => 2], 'smf_index_' . Utils::$context['theme_variant']); + } } }