Skip to content

Commit

Permalink
Expose core background image
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <jus@bitgrid.net>
  • Loading branch information
juliushaertl committed Aug 18, 2022
1 parent f17a342 commit 7269c7a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
3 changes: 2 additions & 1 deletion apps/dashboard/src/DashboardApp.vue
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,9 @@ export default {
|| this.background.match(/#[0-9A-Fa-f]{6}/g)) {
return null
}
return {
backgroundImage: `url(${this.backgroundImage})`,
backgroundImage: this.background === 'default' ? 'var(--image-main-background)' : `url(${this.backgroundImage})`,
}
},
Expand Down
10 changes: 7 additions & 3 deletions apps/theming/lib/Themes/DefaultTheme.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,26 +192,30 @@ public function getCSSVariables(): array {
'--primary-invert-if-bright' => $this->util->invertTextColor($this->primaryColor) ? 'invert(100%)' : 'no',
'--background-invert-if-dark' => 'no',
'--background-invert-if-bright' => 'invert(100%)',

'--image-main-background' => "url('" . $this->urlGenerator->imagePath('core', 'app-background.jpg') . "')",
];

$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)) {
$imageUrl = $this->imageManager->getImageUrl($image);
if ($image === 'background') {
// If background deleted is set, ignoring variable
if ($backgroundDeleted) {
continue;
}
}
$variables['--image-background-size'] = 'cover';
$variables['--image-main-background'] = "url('" . $imageUrl . "')";
}
$variables["--image-$image"] = "url('".$this->imageManager->getImageUrl($image)."')";
$variables["--image-$image"] = "url('" . $imageUrl . "')";
}
}

Expand Down
Binary file added core/img/app-background.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7269c7a

Please sign in to comment.