summaryrefslogtreecommitdiffstats
path: root/apps/theming/lib/Util.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/theming/lib/Util.php')
-rw-r--r--apps/theming/lib/Util.php17
1 files changed, 13 insertions, 4 deletions
diff --git a/apps/theming/lib/Util.php b/apps/theming/lib/Util.php
index d3c0043b2a3..5df132f382c 100644
--- a/apps/theming/lib/Util.php
+++ b/apps/theming/lib/Util.php
@@ -76,14 +76,23 @@ class Util {
/**
* get color for on-page elements:
* theme color by default, grey if theme color is to bright
- * @param $color
+ * @param string $color
+ * @param bool $brightBackground
* @return string
*/
- public function elementColor($color) {
- $l = $this->calculateLuminance($color);
- if ($l>0.8) {
+ public function elementColor($color, bool $brightBackground = true) {
+ $luminance = $this->calculateLuminance($color);
+
+ if ($brightBackground && $luminance > 0.8) {
+ // If the color is too bright in bright mode, we fall back to a darker gray
return '#aaaaaa';
}
+
+ if (!$brightBackground && $luminance < 0.2) {
+ // If the color is too dark in dark mode, we fall back to a brighter gray
+ return '#555555';
+ }
+
return $color;
}