Skip to content

Commit 9eccd3a

Browse files
committed
try to fix too dark or bright themed icons
Signed-off-by: Simon L <[email protected]>
1 parent fc07627 commit 9eccd3a

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

apps/theming/lib/IconBuilder.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,13 @@ public function colorSvg($app, $image) {
234234
}
235235
$svg = file_get_contents($imageFile);
236236
if ($svg !== false && $svg !== "") {
237-
$color = $this->util->elementColor($this->themingDefaults->getColorPrimary());
237+
$primaryColor = $this->themingDefaults->getColorPrimary();
238+
$luminance = $this->util->calculateLuminance($primaryColor);
239+
$isBrightColor = false;
240+
if ($luminance > 0.8) {
241+
$isBrightColor = true;
242+
}
243+
$color = $this->util->elementColor($primaryColor, $isBrightColor);
238244
$svg = $this->util->colorizeSvg($svg, $color);
239245
return $svg;
240246
} else {

apps/theming/lib/Util.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,12 @@ public function elementColor($color, bool $brightBackground = true) {
8686

8787
if ($brightBackground && $luminance > 0.8) {
8888
// If the color is too bright in bright mode, we fall back to a darker gray
89-
return '#aaaaaa';
89+
return $this->darken($color, 20);
9090
}
9191

9292
if (!$brightBackground && $luminance < 0.2) {
9393
// If the color is too dark in dark mode, we fall back to a brighter gray
94-
return '#8c8c8c';
94+
return $this->lighten($color, 20);
9595
}
9696

9797
return $color;

0 commit comments

Comments
 (0)