diff options
author | John Molakvoæ <skjnldsv@users.noreply.github.com> | 2021-12-03 11:55:42 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-03 11:55:42 +0100 |
commit | b067ae78c5a8044e8066fe742d61c712387e7aa5 (patch) | |
tree | 4ce0140c5160f03c9ddc09bf8befe69b1c872fde | |
parent | 510031067abf8c9f62a518f7f7ad8eb644de1721 (diff) | |
parent | dfb569f097119ac8b5722607a86cc77e97bff3af (diff) | |
download | nextcloud-server-b067ae78c5a8044e8066fe742d61c712387e7aa5.tar.gz nextcloud-server-b067ae78c5a8044e8066fe742d61c712387e7aa5.zip |
Merge pull request #30034 from nextcloud/fix/bump-scssphp/scssphp-to-1.8.1
m--------- | 3rdparty | 0 | ||||
-rw-r--r-- | apps/theming/lib/Util.php | 44 | ||||
-rw-r--r-- | lib/private/Template/SCSSCacher.php | 5 |
3 files changed, 42 insertions, 7 deletions
diff --git a/3rdparty b/3rdparty -Subproject 1269091e96a2a550912db37c0d2b29ed5c0aa60 +Subproject 108a384f119a8bdad65210e7231a287f46ede73 diff --git a/apps/theming/lib/Util.php b/apps/theming/lib/Util.php index 70b5a00f9ea..208cd42934e 100644 --- a/apps/theming/lib/Util.php +++ b/apps/theming/lib/Util.php @@ -34,7 +34,6 @@ use OCP\Files\IAppData; use OCP\Files\NotFoundException; use OCP\Files\SimpleFS\ISimpleFile; use OCP\IConfig; -use ScssPhp\ScssPhp\Compiler; class Util { @@ -97,14 +96,51 @@ class Util { } /** + * Convert RGB to HSL + * + * Copied from cssphp, copyright Leaf Corcoran, licensed under MIT + * + * @param integer $red + * @param integer $green + * @param integer $blue + * + * @return array + */ + public function toHSL($red, $green, $blue) { + $min = min($red, $green, $blue); + $max = max($red, $green, $blue); + $l = $min + $max; + $d = $max - $min; + + if ((int) $d === 0) { + $h = $s = 0; + } else { + if ($l < 255) { + $s = $d / $l; + } else { + $s = $d / (510 - $l); + } + + if ($red == $max) { + $h = 60 * ($green - $blue) / $d; + } elseif ($green == $max) { + $h = 60 * ($blue - $red) / $d + 120; + } else { + $h = 60 * ($red - $green) / $d + 240; + } + } + + return [fmod($h, 360), $s * 100, $l / 5.1]; + } + + /** * @param string $color rgb color value * @return float */ public function calculateLuminance($color) { [$red, $green, $blue] = $this->hexToRGB($color); - $compiler = new Compiler(); - $hsl = $compiler->toHSL($red, $green, $blue); - return $hsl[3] / 100; + $hsl = $this->toHSL($red, $green, $blue); + return $hsl[2] / 100; } /** diff --git a/lib/private/Template/SCSSCacher.php b/lib/private/Template/SCSSCacher.php index 0543427f997..536557e7a3d 100644 --- a/lib/private/Template/SCSSCacher.php +++ b/lib/private/Template/SCSSCacher.php @@ -45,7 +45,6 @@ use OCP\ILogger; use OCP\IMemcache; use OCP\IURLGenerator; use ScssPhp\ScssPhp\Compiler; -use ScssPhp\ScssPhp\Exception\ParserException; use ScssPhp\ScssPhp\OutputStyle; class SCSSCacher { @@ -340,7 +339,7 @@ class SCSSCacher { '@import "variables.scss";' . '@import "functions.scss";' . '@import "' . $fileNameSCSS . '";'); - } catch (ParserException $e) { + } catch (\Exception $e) { $this->logger->logException($e, ['app' => 'scss_cacher']); return false; @@ -431,7 +430,7 @@ class SCSSCacher { $scss = new Compiler(); $scss->compile($variables); $this->injectedVariables = $variables; - } catch (ParserException $e) { + } catch (\Exception $e) { $this->logger->logException($e, ['app' => 'scss_cacher']); } |