aboutsummaryrefslogtreecommitdiffstats
path: root/apps/theming/lib/Util.php
diff options
context:
space:
mode:
authorFerdinand Thiessen <opensource@fthiessen.de>2023-12-16 14:04:53 +0100
committerEduardo Morales <emoral435@gmail.com>2023-12-19 10:20:33 -0600
commit74f6995bdb6fa85426048ac87cea7ed94902686f (patch)
treed5942987822f11324d1de2f93e13ff0c201ab8bf /apps/theming/lib/Util.php
parent94a5e6c7b37765a4e8079ad945801a0a892dba04 (diff)
downloadnextcloud-server-74f6995bdb6fa85426048ac87cea7ed94902686f.tar.gz
nextcloud-server-74f6995bdb6fa85426048ac87cea7ed94902686f.zip
fix(theming): Adjust dark high contrast to fulfill WCAG 2.1 AAA contrast
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Diffstat (limited to 'apps/theming/lib/Util.php')
-rw-r--r--apps/theming/lib/Util.php6
1 files changed, 4 insertions, 2 deletions
diff --git a/apps/theming/lib/Util.php b/apps/theming/lib/Util.php
index c4f0123460e..71ab0a6dc6c 100644
--- a/apps/theming/lib/Util.php
+++ b/apps/theming/lib/Util.php
@@ -81,7 +81,7 @@ class Util {
* @param ?bool $brightBackground
* @return string
*/
- public function elementColor($color, ?bool $brightBackground = null, ?string $backgroundColor = null) {
+ public function elementColor($color, ?bool $brightBackground = null, ?string $backgroundColor = null, bool $highContrast = false) {
if ($backgroundColor !== null) {
$brightBackground = $brightBackground ?? $this->isBrightColor($backgroundColor);
// Minimal amount that is possible to change the luminance
@@ -93,7 +93,9 @@ class Util {
$contrast = $this->colorContrast($color, $blurredBackground);
// Min. element contrast is 3:1 but we need to keep hover states in mind -> min 3.2:1
- while ($contrast < 3.2 && $iteration++ < 100) {
+ $minContrast = $highContrast ? 5.5 : 3.2;
+
+ while ($contrast < $minContrast && $iteration++ < 100) {
$hsl = Color::hexToHsl($color);
$hsl['L'] = max(0, min(1, $hsl['L'] + ($brightBackground ? -$epsilon : $epsilon)));
$color = '#' . Color::hslToHex($hsl);