Skip to content

Commit 317e366

Browse files
committed
Use brand color for background only and keep accessible color as color primary
Signed-off-by: Christopher Ng <chrng8@gmail.com>
1 parent 38033b1 commit 317e366

10 files changed

Lines changed: 25 additions & 16 deletions

File tree

apps/theming/css/default.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
:root {
22
--color-main-background: #ffffff;
3+
--color-main-background-plain-preview: #0082c9;
34
--color-main-background-rgb: 255,255,255;
45
--color-main-background-translucent: rgba(var(--color-main-background-rgb), .97);
56
--color-main-background-blur: rgba(var(--color-main-background-rgb), .8);

apps/theming/css/settings-admin.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.

apps/theming/css/settings-admin.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
margin-top: 10px;
101101
margin-bottom: 20px;
102102
cursor: pointer;
103-
background-color: var(--color-primary);
103+
background-color: var(--color-main-background-plain-preview, var(--color-primary));
104104
background-image: var(--image-background, var(--image-background-plain, url('../../../core/img/app-background.jpg'), linear-gradient(40deg, #0082c9 0%, #30b6ff 100%)));
105105

106106
#theming-preview-logo {
@@ -145,4 +145,4 @@
145145
svg, img {
146146
transition: 500ms filter linear;
147147
}
148-
}
148+
}

apps/theming/lib/Service/BackgroundService.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
class BackgroundService {
4545
// true when the background is bright and need dark icons
4646
public const THEMING_MODE_DARK = 'dark';
47+
public const DEFAULT_COLOR = '#0082c9';
48+
public const DEFAULT_ACCESSIBLE_COLOR = '#00639a';
4749

4850
public const SHIPPED_BACKGROUNDS = [
4951
'anatoly-mikhaltsov-butterfly-wing-scale.jpg' => [
@@ -90,8 +92,8 @@ class BackgroundService {
9092
'kamil-porembinski-clouds.jpg' => [
9193
'attribution' => 'Clouds (Kamil Porembiński, CC BY-SA)',
9294
'attribution_url' => 'https://www.flickr.com/photos/paszczak000/8715851521/',
93-
// Originally #0082c9 but adjusted for accessibility
94-
'primary_color' => '#00639a',
95+
// Originally used the default color but adjusted for accessibility
96+
'primary_color' => self::DEFAULT_ACCESSIBLE_COLOR,
9597
],
9698
'bernard-spragg-new-zealand-fern.jpg' => [
9799
'attribution' => 'New zealand fern (Bernard Spragg, CC0)',

apps/theming/lib/Themes/DefaultTheme.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function __construct(Util $util,
6565
$this->config = $config;
6666
$this->l = $l;
6767

68-
$this->primaryColor = $this->themingDefaults->getColorPrimary();
68+
$this->primaryColor = $this->themingDefaults->getColorPrimary(true);
6969
}
7070

7171
public function getId(): string {
@@ -105,6 +105,7 @@ public function getCSSVariables(): array {
105105

106106
$variables = [
107107
'--color-main-background' => $colorMainBackground,
108+
'--color-main-background-plain-preview' => $this->themingDefaults->getColorPrimary(),
108109
'--color-main-background-rgb' => $colorMainBackgroundRGB,
109110
'--color-main-background-translucent' => 'rgba(var(--color-main-background-rgb), .97)',
110111
'--color-main-background-blur' => 'rgba(var(--color-main-background-rgb), .8)',
@@ -235,7 +236,7 @@ public function getCSSVariables(): array {
235236
$variables['--image-main-background'] = "url('" . $this->urlGenerator->linkTo(Application::APP_ID, "/img/background/$themingBackground") . "')";
236237
} elseif (substr($themingBackground, 0, 1) === '#') {
237238
unset($variables['--image-main-background']);
238-
$variables['--color-main-background-plain'] = $this->primaryColor;
239+
$variables['--color-main-background-plain'] = $this->themingDefaults->getColorPrimary();
239240
}
240241
}
241242

apps/theming/lib/ThemingDefaults.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,27 +215,32 @@ public function getShortFooter() {
215215
/**
216216
* Color that is used for the header as well as for mail headers
217217
*
218+
* @param bool $accessible Set to `true` to return the accessible color variant
219+
*
218220
* @return string
219221
*/
220-
public function getColorPrimary() {
222+
public function getColorPrimary($accessible = false) {
221223
$user = $this->userSession->getUser();
222224
$color = $this->config->getAppValue(Application::APP_ID, 'color', '');
223225

224226
if ($color === '' && !empty($user)) {
225227
$themingBackground = $this->config->getUserValue($user->getUID(), Application::APP_ID, 'background', 'default');
226228
if (isset(BackgroundService::SHIPPED_BACKGROUNDS[$themingBackground]['primary_color'])) {
227229
$this->increaseCacheBuster();
228-
return BackgroundService::SHIPPED_BACKGROUNDS[$themingBackground]['primary_color'];
230+
$color = BackgroundService::SHIPPED_BACKGROUNDS[$themingBackground]['primary_color'];
229231
} else if ($themingBackground === 'default') {
230232
$this->increaseCacheBuster();
231-
return BackgroundService::SHIPPED_BACKGROUNDS['kamil-porembinski-clouds.jpg']['primary_color'];
233+
$color = BackgroundService::DEFAULT_COLOR;
232234
}
233235
}
234236

235237
if (!preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $color)) {
236-
return BackgroundService::SHIPPED_BACKGROUNDS['kamil-porembinski-clouds.jpg']['primary_color'];
238+
$color = BackgroundService::DEFAULT_COLOR;
237239
}
238240

241+
if ($accessible && $color === BackgroundService::DEFAULT_COLOR) {
242+
return BackgroundService::DEFAULT_ACCESSIBLE_COLOR;
243+
}
239244
return $color;
240245
}
241246

apps/theming/src/components/BackgroundSettings.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ export default {
171171
}
172172
173173
&.color {
174-
background-color: var(--color-primary);
174+
background-color: var(--color-main-background-plain-preview, var(--color-primary));
175175
color: var(--color-primary-text);
176176
}
177177

core/css/guest.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ body {
2323
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
2424
color: var(--color-text);
2525
text-align: center;
26-
background-color: var(--color-primary);
26+
background-color: var(--color-main-background-plain-preview, var(--color-primary));
2727
background-image: var(--image-background, var(--image-background-plain, url('../../../core/img/app-background.jpg'), linear-gradient(40deg, #0082c9 0%, #30b6ff 100%)));
2828
background-attachment: fixed;
2929
min-height: 100%; /* fix sticky footer */

dist/theming-theming-settings.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/theming-theming-settings.js.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.

0 commit comments

Comments
 (0)