From 5f3229ed6746825cd50710644ee40e984ca4f049 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6?= Date: Tue, 16 Aug 2022 09:39:00 +0200 Subject: Automatically enable plain background if primary colour is set MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ --- apps/theming/lib/Themes/DefaultTheme.php | 19 +++++++++++++------ apps/theming/tests/ImageManagerTest.php | 2 +- 2 files changed, 14 insertions(+), 7 deletions(-) (limited to 'apps/theming') 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'); -- cgit v1.2.3