Closed julio1501 closed 6 years ago
Hello julio1501,
I played a bit with the luminance calculation based on the luminance code snipped from https://hacks.mozilla.org/2018/07/dark-theme-darkening-better-theming-for-firefox-quantum/ over the weekend.
Open following file in a text editor ./dashboard/lib/Controller/CalendarController.php
and replace the whole foreach loop code (line number 138 until line number 150) with following code:
foreach ($calendars as $calendar) {
// luminance threshold source: https://hacks.mozilla.org/2018/07/dark-theme-darkening-better-theming-for-firefox-quantum/
$lum = 141.0000;
$lumThreshold = 140.0000;
$calBackgroundColor = $calendar['{http://apple.com/ns/ical/}calendar-color'];
if(!isset($calBackgroundColor)) {
$calBackgroundColor = '#3A87AD'; // standard background color of private events
}
// six digit hex notation?
if (preg_match('/^[#]([0-9A-F]){6}$/i', $calBackgroundColor) === 1) {
$rColorInt = hexdec(substr($calBackgroundColor, 1, 2));
$gColorInt = hexdec(substr($calBackgroundColor, 3, 2));
$bColorInt = hexdec(substr($calBackgroundColor, 5, 2));
$lum = (0.2125 * $rColorInt) + (0.7154 * $gColorInt) + (0.0721 * $bColorInt);
}
$textColor = '#FFFFFF'; // white font color
// $lum values over 140 will be classified as bright background color
if ($lum > $lumThreshold) {
$textColor = '#000000'; // black font color
}
$eventSources[] = [
'url' => $this->urlGenerator->linkToRoute(
'dashboard.calendar.get_events',
['calendarid' => $calendar['id']]
),
'backgroundColor' => $calendar['{http://apple.com/ns/ical/}calendar-color'],
'borderColor' => '#888',
'textColor' => $textColor,
'cache' => true,
];
}
I increased the overall threshold value from 110 to 140. Tune the overall value if it doesn't hit your taste, or experiment with the rgb multipier values.
Hello @tuxedo-rb ,
thanks! It´s perfect
fixed using tuxedo-rb's patch
Font color on the calender always stays white, even if the background is bright