Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@protonmail.com>2022-05-20 10:06:29 +0300
committerbackportbot-nextcloud[bot] <backportbot-nextcloud[bot]@users.noreply.github.com>2022-06-01 10:00:24 +0300
commit3d9e84fd3ab947697286fb5bfef25a0145117887 (patch)
treee15552f32eb99ac2de5db5e39361709ca603521e
parent75df236ed0f60410d4e1793eba5d3bdc9076b2b5 (diff)
Properly calculate primary element based on background luminancebackport/32510/stable22
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
-rw-r--r--apps/accessibility/lib/Controller/AccessibilityController.php16
-rw-r--r--apps/theming/lib/ThemingDefaults.php4
-rw-r--r--lib/private/legacy/OC_Defaults.php4
-rw-r--r--themes/example/defaults.php2
4 files changed, 20 insertions, 6 deletions
diff --git a/apps/accessibility/lib/Controller/AccessibilityController.php b/apps/accessibility/lib/Controller/AccessibilityController.php
index 7a5a82085dc..857aaf8b90f 100644
--- a/apps/accessibility/lib/Controller/AccessibilityController.php
+++ b/apps/accessibility/lib/Controller/AccessibilityController.php
@@ -248,7 +248,7 @@ class AccessibilityController extends Controller {
return $this->injectedVariables;
}
$variables = '';
- foreach ($this->defaults->getScssVariables() as $key => $value) {
+ foreach ($this->defaults->getScssVariables(!$this->isDarkThemeEnabled()) as $key => $value) {
$variables .= '$' . $key . ': ' . $value . ';';
}
@@ -267,4 +267,18 @@ class AccessibilityController extends Controller {
}
return $variables;
}
+
+ /**
+ * Return true if the dark theme is enabled for the current user
+ */
+ private function isDarkThemeEnabled(): bool {
+ if (!$this->userSession->isLoggedIn()) {
+ return false;
+ }
+ $user = $this->userSession->getUser();
+ if (!$user) {
+ return false;
+ }
+ return $this->config->getUserValue($user->getUID(), $this->appName, 'theme', false) === 'dark';
+ }
}
diff --git a/apps/theming/lib/ThemingDefaults.php b/apps/theming/lib/ThemingDefaults.php
index a5b6b8fd887..798f48ee52f 100644
--- a/apps/theming/lib/ThemingDefaults.php
+++ b/apps/theming/lib/ThemingDefaults.php
@@ -301,7 +301,7 @@ class ThemingDefaults extends \OC_Defaults {
/**
* @return array scss variables to overwrite
*/
- public function getScssVariables() {
+ public function getScssVariables(bool $brightBackground = true) {
$cacheBuster = $this->config->getAppValue('theming', 'cachebuster', '0');
$cache = $this->cacheFactory->createDistributed('theming-' . $cacheBuster . '-' . $this->urlGenerator->getBaseUrl());
if ($value = $cache->get('getScssVariables')) {
@@ -325,7 +325,7 @@ class ThemingDefaults extends \OC_Defaults {
if ($this->config->getAppValue('theming', 'color', '') !== '') {
$variables['color-primary'] = $this->getColorPrimary();
$variables['color-primary-text'] = $this->getTextColorPrimary();
- $variables['color-primary-element'] = $this->util->elementColor($this->getColorPrimary());
+ $variables['color-primary-element'] = $this->util->elementColor($this->getColorPrimary(), $brightBackground);
}
if ($this->config->getAppValue('theming', 'backgroundMime', '') === 'backgroundColor') {
diff --git a/lib/private/legacy/OC_Defaults.php b/lib/private/legacy/OC_Defaults.php
index fa90dff2edf..2674a088e11 100644
--- a/lib/private/legacy/OC_Defaults.php
+++ b/lib/private/legacy/OC_Defaults.php
@@ -297,9 +297,9 @@ class OC_Defaults {
/**
* @return array scss variables to overwrite
*/
- public function getScssVariables() {
+ public function getScssVariables(bool $brightBackground = true) {
if ($this->themeExist('getScssVariables')) {
- return $this->theme->getScssVariables();
+ return $this->theme->getScssVariables($brightBackground);
}
return [];
}
diff --git a/themes/example/defaults.php b/themes/example/defaults.php
index 87d60de2ba7..a061ce1701d 100644
--- a/themes/example/defaults.php
+++ b/themes/example/defaults.php
@@ -119,7 +119,7 @@ class OC_Theme {
* Returns variables to overload defaults from core/css/variables.scss
* @return array
*/
- public function getScssVariables() {
+ public function getScssVariables(bool $brightBackground) {
return [
'color-primary' => '#745bca'
];