Don't support dark/light mode for IE

This commit is contained in:
Eric Lippmann 2022-02-09 21:32:50 +01:00
parent f1c984cd65
commit baeca33789
4 changed files with 28 additions and 12 deletions

View File

@ -56,10 +56,12 @@ if (in_array($path, $special)) {
switch ($path) { switch ($path) {
case 'css/icinga.css': case 'css/icinga.css':
Stylesheet::send(); $forIe11 = (bool) preg_match('/Trident\/7.0;.*rv:11/', $_SERVER['HTTP_USER_AGENT']);
Stylesheet::send(false, $forIe11);
exit; exit;
case 'css/icinga.min.css': case 'css/icinga.min.css':
Stylesheet::send(true); $forIe11 = (bool) preg_match('/Trident\/7.0;.*rv:11/', $_SERVER['HTTP_USER_AGENT']);
Stylesheet::send(true, $forIe11);
exit; exit;
case 'js/icinga.dev.js': case 'js/icinga.dev.js':

View File

@ -14,11 +14,17 @@ require_once 'lessphp/lessc.inc.php';
class LessParser extends lessc class LessParser extends lessc
{ {
public function __construct() /**
* @param bool $disableModes Disable replacing compiled Less colors with CSS var() function calls and don't inject
* light mode calls
*/
public function __construct($disableModes = false)
{ {
$this->registerFunction('extract-variable-default', [$this, 'extractVariableDefault']); $this->registerFunction('extract-variable-default', [$this, 'extractVariableDefault']);
if (! $disableModes) {
$this->setOption('plugins', [new Visitor()]); $this->setOption('plugins', [new Visitor()]);
} }
}
/** /**
* Extract default from given variable call * Extract default from given variable call

View File

@ -58,10 +58,13 @@ class LessCompiler
/** /**
* Create a new LESS compiler * Create a new LESS compiler
*
* @param bool $disableModes Disable replacing compiled Less colors with CSS var() function calls and don't inject
* light mode calls
*/ */
public function __construct() public function __construct($disableModes = false)
{ {
$this->lessc = new LessParser(); $this->lessc = new LessParser($disableModes);
// Discourage usage of import because we're caching based on an explicit list of LESS files to compile // Discourage usage of import because we're caching based on an explicit list of LESS files to compile
$this->lessc->importDisabled = true; $this->lessc->importDisabled = true;
} }

View File

@ -113,12 +113,15 @@ class StyleSheet
/** /**
* Create the StyleSheet * Create the StyleSheet
*
* @param bool $disableModes Disable replacing compiled Less colors with CSS var() function calls and don't inject
* light mode calls
*/ */
public function __construct() public function __construct($disableModes = false)
{ {
$app = Icinga::app(); $app = Icinga::app();
$this->app = $app; $this->app = $app;
$this->lessCompiler = new LessCompiler(); $this->lessCompiler = new LessCompiler($disableModes);
$this->pubPath = $app->getBaseDir('public'); $this->pubPath = $app->getBaseDir('public');
$this->collect(); $this->collect();
} }
@ -222,10 +225,12 @@ class StyleSheet
* Does not cache the stylesheet if the HTTP header Cache-Control or Pragma is set to no-cache. * Does not cache the stylesheet if the HTTP header Cache-Control or Pragma is set to no-cache.
* *
* @param bool $minified Whether to compress the stylesheet * @param bool $minified Whether to compress the stylesheet
* @param bool $disableModes Disable replacing compiled Less colors with CSS var() function calls and don't inject
* light mode calls
*/ */
public static function send($minified = false) public static function send($minified = false, $disableModes = false)
{ {
$styleSheet = new self(); $styleSheet = new self($disableModes);
$request = $styleSheet->app->getRequest(); $request = $styleSheet->app->getRequest();
$response = $styleSheet->app->getResponse(); $response = $styleSheet->app->getResponse();