From: Vincent Vanwaelscappel Date: Tue, 10 Oct 2023 17:02:14 +0000 (+0200) Subject: wip #6381 @0.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=ba46219c70ee989938251563dedf1cf2b36ba3b6;p=fluidbook-toolbox.git wip #6381 @0.5 --- diff --git a/app/Elearning/QuizCompiler.php b/app/Elearning/QuizCompiler.php index 2dbbefab6..72c657976 100644 --- a/app/Elearning/QuizCompiler.php +++ b/app/Elearning/QuizCompiler.php @@ -136,6 +136,7 @@ class QuizCompiler extends Base { // Main texts color $this->sassVariables['texts-color'] = $this->theme->getTextsColor(); + $this->sassVariables['opposite-texts-color'] = $this->theme->getTextsColor(true); // Font $this->sassVariables['font'] = $this->_font($this->theme->font); // Colors diff --git a/app/Models/QuizTheme.php b/app/Models/QuizTheme.php index bdee95dd1..d1e1b8b52 100644 --- a/app/Models/QuizTheme.php +++ b/app/Models/QuizTheme.php @@ -144,7 +144,7 @@ class QuizTheme extends ToolboxModel $this->addField('outroFailAnimation', Hidden::class, __('Animation d\'échec'), ['hint' => __('390 x 390px')]); } - public function getTextsColor() + public function getTextsColor($opposite = false) { $darkColor = '#383838'; $lightColor = '#ffffff'; @@ -157,17 +157,28 @@ class QuizTheme extends ToolboxModel $distBlack = $neutral->distance($black); $distWhite = $neutral->distance($white); if ($distWhite > $distBlack) { - return $lightColor; + $res = $lightColor; } else { - return $darkColor; + $res = $darkColor; } + } else { + $res = match ($this->textColor) { + 'dark' => $darkColor, + '#000000' => $darkColor, + '#ffffff' => $lightColor, + 'light' => $lightColor, + }; + } + + if (!$opposite) { + return $res; + } + + if ($res === $darkColor) { + return $lightColor; + } else { + return $darkColor; } - return match ($this->textColor) { - 'dark' => $darkColor, - '#000000' => $darkColor, - '#ffffff' => $lightColor, - 'light' => $lightColor, - }; } /**