Skip to content

Commit 7d257eb

Browse files
committed
Fix background removal not applying to user default theming
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
1 parent dc9d88e commit 7d257eb

File tree

14 files changed

+103
-38
lines changed

14 files changed

+103
-38
lines changed

apps/theming/lib/Themes/CommonThemeTrait.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,17 @@ protected function generateUserBackgroundVariables(): array {
127127
if ($user !== null
128128
&& !$this->themingDefaults->isUserThemingDisabled()
129129
&& $this->appManager->isEnabledForUser(Application::APP_ID)) {
130+
$adminBackgroundDeleted = $this->config->getAppValue(Application::APP_ID, 'backgroundMime', '') === 'backgroundColor';
130131
$backgroundImage = $this->config->getUserValue($user->getUID(), Application::APP_ID, 'background_image', BackgroundService::BACKGROUND_DEFAULT);
131132
$currentVersion = (int)$this->config->getUserValue($user->getUID(), Application::APP_ID, 'userCacheBuster', '0');
132-
$isPrimaryBright = $this->util->invertTextColor($this->primaryColor);
133+
$isPrimaryBright = $this->util->invertTextColor($this->themingDefaults->getColorPrimary());
133134

134135
// The user removed the background
135136
if ($backgroundImage === BackgroundService::BACKGROUND_DISABLED) {
136137
return [
137-
'--image-background' => 'no',
138-
'--color-background-plain' => $this->primaryColor,
138+
// Might be defined already by admin theming, needs to be overridden
139+
'--image-background' => 'none',
140+
'--color-background-plain' => $this->themingDefaults->getColorPrimary(),
139141
// If no background image is set, we need to check against the shown primary colour
140142
'--background-image-invert-if-bright' => $isPrimaryBright ? 'invert(100%)' : 'no',
141143
];
@@ -150,6 +152,15 @@ protected function generateUserBackgroundVariables(): array {
150152
];
151153
}
152154

155+
// The user is using the default background and admin removed the background image
156+
if ($backgroundImage === BackgroundService::BACKGROUND_DEFAULT && $adminBackgroundDeleted) {
157+
return [
158+
// --image-background is not defined in this case
159+
'--color-background-plain' => $this->themingDefaults->getColorPrimary(),
160+
'--background-image-invert-if-bright' => $isPrimaryBright ? 'invert(100%)' : 'no',
161+
];
162+
}
163+
153164
// The user picked a shipped background
154165
if (isset(BackgroundService::SHIPPED_BACKGROUNDS[$backgroundImage])) {
155166
return [

apps/theming/lib/Themes/DefaultTheme.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function __construct(Util $util,
7070
$this->defaultPrimaryColor = $this->themingDefaults->getDefaultColorPrimary();
7171
$this->primaryColor = $this->themingDefaults->getColorPrimary();
7272

73-
// Override default defaultPrimaryColor if set to improve accessibility
73+
// Override primary colors (if set) to improve accessibility
7474
if ($this->primaryColor === BackgroundService::DEFAULT_COLOR) {
7575
$this->primaryColor = BackgroundService::DEFAULT_ACCESSIBLE_COLOR;
7676
}

apps/theming/lib/ThemingDefaults.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,9 @@ public function getColorPrimary(): string {
255255
public function getDefaultColorPrimary(): string {
256256
$color = $this->config->getAppValue(Application::APP_ID, 'color', '');
257257
if (!preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $color)) {
258-
$color = '#0082c9';
258+
return BackgroundService::DEFAULT_COLOR;
259259
}
260+
260261
return $color;
261262
}
262263

apps/theming/src/AdminTheming.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,12 +297,12 @@ export default {
297297
/* This is basically https://github.com/nextcloud/server/blob/master/core/css/guest.css
298298
But without the user variables. That way the admin can preview the render as guest*/
299299
/* As guest, there is no user color color-background-plain */
300-
background-color: var(--color-primary-element-default, #0082c9);
300+
background-color: var(--color-primary-element-default);
301301
/* As guest, there is no user background (--image-background)
302302
1. Empty background if defined
303303
2. Else default background
304304
3. Finally default gradient (should not happened, the background is always defined anyway) */
305-
background-image: var(--image-background-plain, var(--image-background-default, linear-gradient(40deg, #0082c9 0%, #30b6ff 100%)));
305+
background-image: var(--image-background-plain, var(--image-background-default));
306306
307307
&-logo {
308308
width: 20%;

core/css/apps.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/css/apps.css.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/css/apps.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ html {
4848
body {
4949
// color-background-plain should always be defined. It is the primary user colour
5050
background-color: var(--color-background-plain, var(--color-main-background));
51-
// image-background-plain means the admin has disabled the background image
52-
background-image: var(--image-background, var(--image-background-default));
51+
// user background, or plain colour and finally default admin background
52+
background-image: var(--image-background, var(--image-background-plain, var(--image-background-default)));
5353
background-size: cover;
5454
background-position: center;
5555
position: fixed;

core/css/server.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)