mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
Merge pull request #32681 from nextcloud/backport/32510/stable22
[stable22] Properly calculate primary element based on background luminance
This commit is contained in:
commit
6509c841b3
4 changed files with 20 additions and 6 deletions
|
|
@ -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';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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') {
|
||||
|
|
|
|||
|
|
@ -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 [];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
];
|
||||
|
|
|
|||
Loading…
Reference in a new issue