29 lines
1.0 KiB
PHP
29 lines
1.0 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Colore d'azione delle dashboard (prossima lezione, pulsanti, barre).
|
|
*
|
|
* Usa il colore principale della scuola (option.theme_primary) solo se è
|
|
* abbastanza scuro da reggere il testo bianco (contrasto >= 4.5:1).
|
|
* Altrimenti resta il teal YogiBook definito in yb-dashboard.css.
|
|
* In questo modo le dashboard non ereditano il blu-viola di default del template.
|
|
*
|
|
* Da includere nel <head>, DOPO il link a yb-dashboard.css.
|
|
*/
|
|
$__acc = strtoupper(trim((string) SchoolSettings::get('theme_primary', '')));
|
|
|
|
if (preg_match('/^#[0-9A-F]{6}$/', $__acc)) {
|
|
$__lin = function (int $c): float {
|
|
$c = $c / 255;
|
|
return $c <= 0.03928 ? $c / 12.92 : (($c + 0.055) / 1.055) ** 2.4;
|
|
};
|
|
$__lum = 0.2126 * $__lin(hexdec(substr($__acc, 1, 2)))
|
|
+ 0.7152 * $__lin(hexdec(substr($__acc, 3, 2)))
|
|
+ 0.0722 * $__lin(hexdec(substr($__acc, 5, 2)));
|
|
|
|
if (1.05 / ($__lum + 0.05) >= 4.5) {
|
|
echo '<style>:root { --db-accent: ' . $__acc . '; }</style>';
|
|
}
|
|
}
|
|
unset($__acc, $__lin, $__lum);
|