Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔢 Add css variables for blur background #33610

Merged
merged 5 commits into from
Aug 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions 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 Expand Up @@ -426,8 +427,6 @@ export default {
background-repeat: no-repeat;
background-attachment: fixed;
background-color: var(--color-primary);
--color-background-translucent: rgba(var(--color-main-background-rgb), 0.8);
--background-blur: blur(10px);

> h2 {
color: var(--color-primary-text);
Expand All @@ -453,9 +452,9 @@ export default {
width: 320px;
max-width: 100%;
margin: 16px;
background-color: var(--color-background-translucent);
-webkit-backdrop-filter: var(--background-blur);
backdrop-filter: var(--background-blur);
background-color: var(--color-main-background-blur);
-webkit-backdrop-filter: var(--filter-background-blur);
backdrop-filter: var(--filter-background-blur);
border-radius: var(--border-radius-large);

#body-user.theme--highcontrast & {
Expand Down Expand Up @@ -556,9 +555,9 @@ export default {
.edit-panels,
.statuses ::v-deep .action-item .action-item__menutoggle,
.statuses ::v-deep .action-item.action-item--open .action-item__menutoggle {
background-color: var(--color-background-translucent);
-webkit-backdrop-filter: var(--background-blur);
backdrop-filter: var(--background-blur);
background-color: var(--color-main-background-blur);
-webkit-backdrop-filter: var(--filter-background-blur);
backdrop-filter: var(--filter-background-blur);
opacity: 1 !important;

&:hover,
Expand Down
3 changes: 3 additions & 0 deletions apps/theming/css/default.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
--color-main-background: #ffffff;
--color-main-background-rgb: 255,255,255;
--color-main-background-translucent: rgba(var(--color-main-background-rgb), .97);
--color-main-background-blur: rgba(var(--color-main-background-rgb), .8);
--filter-background-blur: blur(25px);
--gradient-main-background: var(--color-main-background) 0%, var(--color-main-background-translucent) 85%, transparent 100%;
--color-background-hover: #f5f5f5;
--color-background-dark: #ededed;
Expand Down Expand Up @@ -59,4 +61,5 @@
--primary-invert-if-bright: no;
--background-invert-if-dark: no;
--background-invert-if-bright: invert(100%);
--image-main-background: url('/core/img/app-background.jpg');
}
12 changes: 9 additions & 3 deletions apps/theming/lib/Themes/DefaultTheme.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ public function getCSSVariables(): array {
'--color-main-background' => $colorMainBackground,
'--color-main-background-rgb' => $colorMainBackgroundRGB,
'--color-main-background-translucent' => 'rgba(var(--color-main-background-rgb), .97)',
'--color-main-background-blur' => 'rgba(var(--color-main-background-rgb), .8)',
'--filter-background-blur' => 'blur(25px)',

// to use like this: background-image: linear-gradient(0, var('--gradient-main-background));
'--gradient-main-background' => 'var(--color-main-background) 0%, var(--color-main-background-translucent) 85%, transparent 100%',
Expand Down Expand Up @@ -190,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') . "')",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we customize that?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be overwriten further down with the theming image. Taking the customised dashboard image into account will be a follow up.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah right I get it now!
Could use a tad more comments 😉

];

$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 . "')";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate of the line 216, no?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, --image-main-background has a fallback to the cloud image, while the other one --image-background only represents just the theming image.

}
}

Expand Down
3 changes: 3 additions & 0 deletions apps/theming/lib/Themes/HighContrastTheme.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ public function getCSSVariables(): array {
$variables['--color-background-dark'] = $this->util->darken($colorMainBackground, 30);
$variables['--color-background-darker'] = $this->util->darken($colorMainBackground, 30);

$variables['--color-main-background-blur'] = $colorMainBackground;
$variables['--filter-background-blur'] = 'none';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!


$variables['--color-placeholder-light'] = $this->util->darken($colorMainBackground, 30);
$variables['--color-placeholder-dark'] = $this->util->darken($colorMainBackground, 45);

Expand Down
7 changes: 7 additions & 0 deletions apps/theming/tests/Themes/DefaultThemeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ protected function setUp(): void {
return vsprintf($text, $parameters);
});

$this->urlGenerator
->expects($this->any())
->method('imagePath')
->willReturnCallback(function ($app = 'core', $filename = '') {
return "/$app/img/$filename";
});

$this->defaultTheme = new DefaultTheme(
$util,
$this->themingDefaults,
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.
4 changes: 2 additions & 2 deletions dist/dashboard-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/dashboard-main.js.map

Large diffs are not rendered by default.