diff options
author | Christopher Ng <chrng8@gmail.com> | 2022-09-29 01:38:23 +0000 |
---|---|---|
committer | Christopher Ng <chrng8@gmail.com> | 2022-10-05 06:19:08 +0000 |
commit | 7044191eb69bb1e2aa4c3edaf03ce73c77971793 (patch) | |
tree | 6d9d6bb8ed5e17ba8ded049fd521024d4d900b01 /apps/theming | |
parent | e962d3fba4430f3a13cda70db9009784fc24112a (diff) | |
download | nextcloud-server-7044191eb69bb1e2aa4c3edaf03ce73c77971793.tar.gz nextcloud-server-7044191eb69bb1e2aa4c3edaf03ce73c77971793.zip |
Use brand color for background only and keep accessible color as color primary
Signed-off-by: Christopher Ng <chrng8@gmail.com>
Diffstat (limited to 'apps/theming')
-rw-r--r-- | apps/theming/css/default.css | 1 | ||||
-rw-r--r-- | apps/theming/css/settings-admin.css | 2 | ||||
-rw-r--r-- | apps/theming/css/settings-admin.scss | 4 | ||||
-rw-r--r-- | apps/theming/lib/Service/BackgroundService.php | 5 | ||||
-rw-r--r-- | apps/theming/lib/Themes/DefaultTheme.php | 7 | ||||
-rw-r--r-- | apps/theming/lib/ThemingDefaults.php | 10 | ||||
-rw-r--r-- | apps/theming/src/components/BackgroundSettings.vue | 2 |
7 files changed, 18 insertions, 13 deletions
diff --git a/apps/theming/css/default.css b/apps/theming/css/default.css index 56c2e41781f..19d02a53f9b 100644 --- a/apps/theming/css/default.css +++ b/apps/theming/css/default.css @@ -1,5 +1,6 @@ :root { --color-main-background: #ffffff; + --color-main-background-not-plain: #0082c9; --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); diff --git a/apps/theming/css/settings-admin.css b/apps/theming/css/settings-admin.css index bb154de2737..2b91404ec3b 100644 --- a/apps/theming/css/settings-admin.css +++ b/apps/theming/css/settings-admin.css @@ -89,7 +89,7 @@ margin-top: 10px; margin-bottom: 20px; cursor: pointer; - background-color: var(--color-primary); + background-color: var(--color-main-background-not-plain, var(--color-primary)); background-image: var(--image-background, var(--image-background-plain, url("../../../core/img/app-background.jpg"), linear-gradient(40deg, #0082c9 0%, #30b6ff 100%))); } #theming #theming-preview #theming-preview-logo { diff --git a/apps/theming/css/settings-admin.scss b/apps/theming/css/settings-admin.scss index 6b37a48622e..706bd37f495 100644 --- a/apps/theming/css/settings-admin.scss +++ b/apps/theming/css/settings-admin.scss @@ -100,7 +100,7 @@ margin-top: 10px; margin-bottom: 20px; cursor: pointer; - background-color: var(--color-primary); + background-color: var(--color-main-background-not-plain, var(--color-primary)); background-image: var(--image-background, var(--image-background-plain, url('../../../core/img/app-background.jpg'), linear-gradient(40deg, #0082c9 0%, #30b6ff 100%))); #theming-preview-logo { @@ -145,4 +145,4 @@ svg, img { transition: 500ms filter linear; } -}
\ No newline at end of file +} diff --git a/apps/theming/lib/Service/BackgroundService.php b/apps/theming/lib/Service/BackgroundService.php index bbf7bde9e5f..0614fe00357 100644 --- a/apps/theming/lib/Service/BackgroundService.php +++ b/apps/theming/lib/Service/BackgroundService.php @@ -44,6 +44,8 @@ use OCP\PreConditionNotMetException; class BackgroundService { // true when the background is bright and need dark icons public const THEMING_MODE_DARK = 'dark'; + public const DEFAULT_COLOR = '#0082c9'; + public const DEFAULT_ACCESSIBLE_COLOR = '#00639a'; public const SHIPPED_BACKGROUNDS = [ 'anatoly-mikhaltsov-butterfly-wing-scale.jpg' => [ @@ -90,8 +92,7 @@ class BackgroundService { 'kamil-porembinski-clouds.jpg' => [ 'attribution' => 'Clouds (Kamil PorembiĆski, CC BY-SA)', 'attribution_url' => 'https://www.flickr.com/photos/paszczak000/8715851521/', - // Originally #0082c9 but adjusted for accessibility - 'primary_color' => '#00639a', + 'primary_color' => self::DEFAULT_COLOR, ], 'bernard-spragg-new-zealand-fern.jpg' => [ 'attribution' => 'New zealand fern (Bernard Spragg, CC0)', diff --git a/apps/theming/lib/Themes/DefaultTheme.php b/apps/theming/lib/Themes/DefaultTheme.php index d338c40ac5e..413902d7813 100644 --- a/apps/theming/lib/Themes/DefaultTheme.php +++ b/apps/theming/lib/Themes/DefaultTheme.php @@ -65,7 +65,9 @@ class DefaultTheme implements ITheme { $this->config = $config; $this->l = $l; - $this->primaryColor = $this->themingDefaults->getColorPrimary(); + $initialPrimaryColor = $this->themingDefaults->getColorPrimary(); + // Override default color if set to improve accessibility + $this->primaryColor = $initialPrimaryColor === BackgroundService::DEFAULT_COLOR ? BackgroundService::DEFAULT_ACCESSIBLE_COLOR : $initialPrimaryColor; } public function getId(): string { @@ -105,6 +107,7 @@ class DefaultTheme implements ITheme { $variables = [ '--color-main-background' => $colorMainBackground, + '--color-main-background-not-plain' => $this->themingDefaults->getColorPrimary(), '--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)', @@ -235,7 +238,7 @@ class DefaultTheme implements ITheme { $variables['--image-main-background'] = "url('" . $this->urlGenerator->linkTo(Application::APP_ID, "/img/background/$themingBackground") . "')"; } elseif (substr($themingBackground, 0, 1) === '#') { unset($variables['--image-main-background']); - $variables['--color-main-background-plain'] = $this->primaryColor; + $variables['--color-main-background-plain'] = $this->themingDefaults->getColorPrimary(); } } diff --git a/apps/theming/lib/ThemingDefaults.php b/apps/theming/lib/ThemingDefaults.php index 61001770302..5fa5656d928 100644 --- a/apps/theming/lib/ThemingDefaults.php +++ b/apps/theming/lib/ThemingDefaults.php @@ -223,17 +223,17 @@ class ThemingDefaults extends \OC_Defaults { if ($color === '' && !empty($user)) { $themingBackground = $this->config->getUserValue($user->getUID(), Application::APP_ID, 'background', 'default'); - if (isset(BackgroundService::SHIPPED_BACKGROUNDS[$themingBackground]['primary_color'])) { + if ($themingBackground === 'default') { $this->increaseCacheBuster(); - return BackgroundService::SHIPPED_BACKGROUNDS[$themingBackground]['primary_color']; - } else if ($themingBackground === 'default') { + return BackgroundService::DEFAULT_COLOR; + } else if (isset(BackgroundService::SHIPPED_BACKGROUNDS[$themingBackground]['primary_color'])) { $this->increaseCacheBuster(); - return BackgroundService::SHIPPED_BACKGROUNDS['kamil-porembinski-clouds.jpg']['primary_color']; + return BackgroundService::SHIPPED_BACKGROUNDS[$themingBackground]['primary_color']; } } if (!preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $color)) { - return BackgroundService::SHIPPED_BACKGROUNDS['kamil-porembinski-clouds.jpg']['primary_color']; + return BackgroundService::DEFAULT_COLOR; } return $color; diff --git a/apps/theming/src/components/BackgroundSettings.vue b/apps/theming/src/components/BackgroundSettings.vue index 359723bcf49..39210569689 100644 --- a/apps/theming/src/components/BackgroundSettings.vue +++ b/apps/theming/src/components/BackgroundSettings.vue @@ -171,7 +171,7 @@ export default { } &.color { - background-color: var(--color-primary); + background-color: var(--color-main-background-not-plain, var(--color-primary)); color: var(--color-primary-text); } |