Skip to content

Commit e911a3e

Browse files
committed
fix(theming): Theme specific variables must be set on the root node
Signed-off-by: Ferdinand Thiessen <rpm@fthiessen.de>
1 parent d7bd763 commit e911a3e

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

apps/theming/lib/Controller/ThemingController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ public function getThemeStylesheet(string $themeId, bool $plain = false, bool $w
370370
} else {
371371
// If not set, we'll rely on the body class
372372
$compiler = new Compiler();
373-
$compiledCss = $compiler->compileString("[data-theme-$themeId] { $variables $customCss }");
373+
$compiledCss = $compiler->compileString(":root[data-theme-$themeId], [data-theme-$themeId] { $variables $customCss }");
374374
$css = $compiledCss->getCss();;
375375
}
376376

apps/theming/src/UserThemes.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,13 +242,13 @@ export default {
242242
const enabledFontsIDs = this.fonts.filter(font => font.enabled === true).map(font => font.id)
243243
244244
this.themes.forEach(theme => {
245-
document.body.toggleAttribute(`data-theme-${theme.id}`, theme.enabled)
245+
document.documentElement.toggleAttribute(`data-theme-${theme.id}`, theme.enabled)
246246
})
247247
this.fonts.forEach(font => {
248-
document.body.toggleAttribute(`data-theme-${font.id}`, font.enabled)
248+
document.documentElement.toggleAttribute(`data-theme-${font.id}`, font.enabled)
249249
})
250250
251-
document.body.setAttribute('data-themes', [...enabledThemesIDs, ...enabledFontsIDs].join(','))
251+
document.documentElement.setAttribute('data-themes', [...enabledThemesIDs, ...enabledFontsIDs].join(','))
252252
},
253253
254254
/**

core/templates/layout.user.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
}
1414

1515
?><!DOCTYPE html>
16-
<html class="ng-csp" data-placeholder-focus="false" lang="<?php p($_['language']); ?>" data-locale="<?php p($_['locale']); ?>" translate="no" >
16+
<html class="ng-csp" data-placeholder-focus="false" lang="<?php p($_['language']); ?>" data-locale="<?php p($_['locale']); ?>" translate="no"
17+
<?php foreach ($_['enabledThemes'] as $themeId) {
18+
p("data-theme-$themeId ");
19+
}?> data-themes=<?php p(join(',', $_['enabledThemes'])) ?>>
1720
<head data-user="<?php p($_['user_uid']); ?>" data-user-displayname="<?php p($_['user_displayname']); ?>" data-requesttoken="<?php p($_['requesttoken']); ?>">
1821
<meta charset="utf-8">
1922
<title>
@@ -42,9 +45,7 @@
4245
<?php emit_script_loading_tags($_); ?>
4346
<?php print_unescaped($_['headers']); ?>
4447
</head>
45-
<body id="<?php p($_['bodyid']);?>" <?php foreach ($_['enabledThemes'] as $themeId) {
46-
p("data-theme-$themeId ");
47-
}?> data-themes=<?php p(join(',', $_['enabledThemes'])) ?>>
48+
<body id="<?php p($_['bodyid']);?>">
4849
<?php include 'layout.noscript.warning.php'; ?>
4950

5051
<?php foreach ($_['initialStates'] as $app => $initialState) { ?>

0 commit comments

Comments
 (0)