diff options
author | John Molakvoæ <skjnldsv@protonmail.com> | 2022-08-16 09:39:00 +0200 |
---|---|---|
committer | John Molakvoæ <skjnldsv@protonmail.com> | 2022-08-16 09:39:00 +0200 |
commit | 5f3229ed6746825cd50710644ee40e984ca4f049 (patch) | |
tree | 97f5d619cb57261ad623bf7f60a71eb287fc8f0a /apps/theming | |
parent | 0ea23cad0eefacf2bad73ce3c50bb659480e3f56 (diff) | |
download | nextcloud-server-5f3229ed6746825cd50710644ee40e984ca4f049.tar.gz nextcloud-server-5f3229ed6746825cd50710644ee40e984ca4f049.zip |
Automatically enable plain background if primary colour is set
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/theming')
-rw-r--r-- | apps/theming/lib/Themes/DefaultTheme.php | 19 | ||||
-rw-r--r-- | apps/theming/tests/ImageManagerTest.php | 2 |
2 files changed, 14 insertions, 7 deletions
diff --git a/apps/theming/lib/Themes/DefaultTheme.php b/apps/theming/lib/Themes/DefaultTheme.php index 2908d365a4a..d141a5d3241 100644 --- a/apps/theming/lib/Themes/DefaultTheme.php +++ b/apps/theming/lib/Themes/DefaultTheme.php @@ -91,6 +91,7 @@ class DefaultTheme implements ITheme { $colorPrimaryLight = $this->util->mix($this->primaryColor, $colorMainBackground, -80); $hasCustomLogoHeader = $this->imageManager->hasImage('logo') || $this->imageManager->hasImage('logoheader'); + $hasCustomPrimaryColour = !empty($this->config->getAppValue('theming', 'color')); $variables = [ '--color-main-background' => $colorMainBackground, @@ -191,15 +192,21 @@ class DefaultTheme implements ITheme { '--background-invert-if-bright' => 'invert(100%)', ]; - // Register image variables only if custom-defined $backgroundDeleted = $this->config->getAppValue('theming', 'backgroundMime', '') === 'backgroundColor'; + // If primary as background has been request or if we have a custom primary colour + // let's not define the background image + if ($backgroundDeleted || $hasCustomPrimaryColour) { + $variables["--image-background-plain"] = 'true'; + } + + // Register image variables only if custom-defined foreach(['logo', 'logoheader', 'favicon', 'background'] as $image) { if ($this->imageManager->hasImage($image)) { - // If primary as background has been request, let's not define the background image - if ($image === 'background' && $backgroundDeleted) { - $variables["--image-background-plain"] = 'true'; - continue; - } else if ($image === 'background') { + if ($image === 'background') { + // If background deleted is set, ignoring variable + if ($backgroundDeleted) { + continue; + } $variables['--image-background-size'] = 'cover'; } $variables["--image-$image"] = "url('".$this->imageManager->getImageUrl($image)."')"; diff --git a/apps/theming/tests/ImageManagerTest.php b/apps/theming/tests/ImageManagerTest.php index 6a9b77234bb..ead9ca113e6 100644 --- a/apps/theming/tests/ImageManagerTest.php +++ b/apps/theming/tests/ImageManagerTest.php @@ -307,7 +307,7 @@ class ImageManagerTest extends TestCase { foreach ($folders as $index => $folder) { $folder->expects($this->any()) ->method('getName') - ->willReturn($index); + ->willReturn("$index"); } $folders[0]->expects($this->once())->method('delete'); $folders[1]->expects($this->once())->method('delete'); |