Skip to content

Commit aededaf

Browse files
susnuxemoral435
authored andcommitted
fix(theming): Adjust primary text color calculation to also work with high contrast themes
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent 4fcb29e commit aededaf

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

apps/theming/css/default.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@
7777
--color-primary-light-text: #00293f;
7878
--color-primary-light-hover: #dbe4ea;
7979
--color-primary-element: #00679e;
80-
--color-primary-element-hover: #1070a4;
80+
--color-primary-element-hover: #005a8a;
8181
--color-primary-element-text: #ffffff;
82-
--color-primary-element-text-dark: #f0f0f0;
82+
--color-primary-element-text-dark: #f5f5f5;
8383
--color-primary-element-light: #e5eff5;
8484
--color-primary-element-light-hover: #dbe4ea;
8585
--color-primary-element-light-text: #00293f;

apps/theming/lib/Themes/CommonThemeTrait.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ protected function generatePrimaryVariables(string $colorMainBackground, string
4343
$colorPrimaryElement = $this->util->elementColor($this->primaryColor, $isBrightColor, $colorMainBackground);
4444
$colorPrimaryLight = $this->util->mix($colorPrimaryElement, $colorMainBackground, -80);
4545
$colorPrimaryElementLight = $this->util->mix($colorPrimaryElement, $colorMainBackground, -80);
46+
$invertPrimaryTextColor = $this->util->invertTextColor($colorPrimaryElement);
4647

4748
// primary related colours
4849
return [
@@ -66,10 +67,10 @@ protected function generatePrimaryVariables(string $colorMainBackground, string
6667

6768
// used for buttons, inputs...
6869
'--color-primary-element' => $colorPrimaryElement,
69-
'--color-primary-element-hover' => $this->util->mix($colorPrimaryElement, $colorMainBackground, 87),
70-
'--color-primary-element-text' => $this->util->invertTextColor($colorPrimaryElement) ? '#000000' : '#ffffff',
70+
'--color-primary-element-hover' => $invertPrimaryTextColor ? $this->util->lighten($colorPrimaryElement, 4) : $this->util->darken($colorPrimaryElement, 4),
71+
'--color-primary-element-text' => $invertPrimaryTextColor ? '#000000' : '#ffffff',
7172
// mostly used for disabled states
72-
'--color-primary-element-text-dark' => $this->util->darken($this->util->invertTextColor($colorPrimaryElement) ? '#000000' : '#ffffff', 6),
73+
'--color-primary-element-text-dark' => $invertPrimaryTextColor ? $this->util->lighten('#000000', 4) : $this->util->darken('#ffffff', 4),
7374

7475
// used for hover/focus states
7576
'--color-primary-element-light' => $colorPrimaryElementLight,

apps/theming/tests/Themes/AccessibleThemeTestCase.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ public function dataAccessibilityPairs() {
4747
3.0,
4848
],
4949
'primary-element-text' => [
50-
['--color-primary-element-text'],
50+
[
51+
'--color-primary-element-text',
52+
'--color-primary-element-text-dark',
53+
],
5154
[
5255
'--color-primary-element',
5356
'--color-primary-element-hover',

0 commit comments

Comments
 (0)