mirror of
https://github.com/nextcloud/server.git
synced 2025-07-22 18:25:45 +00:00
fix(theming): Correctly generate CSS for font themes
Fixes a regression from dropping the SCSS compiler that broke
font themes like OpenDyslexic. The old code relied on the SCSS
compiler to automatically correct the order of the CSS rules,
ensuring the @font-face declaration was always valid.
The server now correctly generates the `@font-face` rule at
the top level of the stylesheet, fixing the previously invalid nested CSS.
Introduced in : f1448fcf07
Signed-off-by: nfebe <fenn25.fn@gmail.com>
This commit is contained in:
@ -401,7 +401,17 @@ class ThemingController extends Controller {
|
||||
$css = ":root { $variables } " . $customCss;
|
||||
} else {
|
||||
// If not set, we'll rely on the body class
|
||||
$css = "[data-theme-$themeId] { $variables $customCss }";
|
||||
// We need to separate @-rules from normal selectors, as they can't be nested
|
||||
// This is a replacement for the SCSS compiler that did this automatically before f1448fcf0777db7d4254cb0a3ef94d63be9f7a24
|
||||
// We need a better way to handle this, but for now we just remove comments and split the at-rules
|
||||
// from the rest of the CSS.
|
||||
$customCssWithoutComments = preg_replace('!/\*.*?\*/!s', '', $customCss);
|
||||
$customCssWithoutComments = preg_replace('!//.*!', '', $customCssWithoutComments);
|
||||
preg_match_all('/(@[^{]+{(?:[^{}]*|(?R))*})/', $customCssWithoutComments, $atRules);
|
||||
$atRulesCss = implode('', $atRules[0]);
|
||||
$scopedCss = preg_replace('/(@[^{]+{(?:[^{}]*|(?R))*})/', '', $customCssWithoutComments);
|
||||
|
||||
$css = "$atRulesCss [data-theme-$themeId] { $variables $scopedCss }";
|
||||
}
|
||||
|
||||
try {
|
||||
|
Reference in New Issue
Block a user