Skip to content

Commit c6f98e2

Browse files
Pytalblizzz
authored andcommitted
Use brand color for background only and keep accessible color as color primary
Signed-off-by: Christopher Ng <chrng8@gmail.com>
1 parent 4485430 commit c6f98e2

File tree

12 files changed

+45
-19
lines changed

12 files changed

+45
-19
lines changed

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-not-plain: #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-not-plain, 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: 3 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,7 @@ 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+
'primary_color' => self::DEFAULT_COLOR,
9596
],
9697
'bernard-spragg-new-zealand-fern.jpg' => [
9798
'attribution' => 'New zealand fern (Bernard Spragg, CC0)',

apps/theming/lib/Themes/DefaultTheme.php

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

68-
$this->primaryColor = $this->themingDefaults->getColorPrimary();
68+
$initialPrimaryColor = $this->themingDefaults->getColorPrimary();
69+
// Override default color if set to improve accessibility
70+
$this->primaryColor = $initialPrimaryColor === BackgroundService::DEFAULT_COLOR ? BackgroundService::DEFAULT_ACCESSIBLE_COLOR : $initialPrimaryColor;
6971
}
7072

7173
public function getId(): string {
@@ -105,6 +107,7 @@ public function getCSSVariables(): array {
105107

106108
$variables = [
107109
'--color-main-background' => $colorMainBackground,
110+
'--color-main-background-not-plain' => $this->themingDefaults->getColorPrimary(),
108111
'--color-main-background-rgb' => $colorMainBackgroundRGB,
109112
'--color-main-background-translucent' => 'rgba(var(--color-main-background-rgb), .97)',
110113
'--color-main-background-blur' => 'rgba(var(--color-main-background-rgb), .8)',
@@ -235,7 +238,7 @@ public function getCSSVariables(): array {
235238
$variables['--image-main-background'] = "url('" . $this->urlGenerator->linkTo(Application::APP_ID, "/img/background/$themingBackground") . "')";
236239
} elseif (substr($themingBackground, 0, 1) === '#') {
237240
unset($variables['--image-main-background']);
238-
$variables['--color-main-background-plain'] = $this->primaryColor;
241+
$variables['--color-main-background-plain'] = $this->themingDefaults->getColorPrimary();
239242
}
240243
}
241244

apps/theming/lib/ThemingDefaults.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,17 +223,17 @@ public function getColorPrimary() {
223223

224224
if ($color === '' && !empty($user)) {
225225
$themingBackground = $this->config->getUserValue($user->getUID(), Application::APP_ID, 'background', 'default');
226-
if (isset(BackgroundService::SHIPPED_BACKGROUNDS[$themingBackground]['primary_color'])) {
226+
if ($themingBackground === 'default') {
227227
$this->increaseCacheBuster();
228-
return BackgroundService::SHIPPED_BACKGROUNDS[$themingBackground]['primary_color'];
229-
} else if ($themingBackground === 'default') {
228+
return BackgroundService::DEFAULT_COLOR;
229+
} else if (isset(BackgroundService::SHIPPED_BACKGROUNDS[$themingBackground]['primary_color'])) {
230230
$this->increaseCacheBuster();
231-
return BackgroundService::SHIPPED_BACKGROUNDS['kamil-porembinski-clouds.jpg']['primary_color'];
231+
return BackgroundService::SHIPPED_BACKGROUNDS[$themingBackground]['primary_color'];
232232
}
233233
}
234234

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

239239
return $color;

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-not-plain, 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-not-plain, 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)