]> _ Git - fluidbook-toolbox.git/commitdiff
wip #6381 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 10 Oct 2023 17:02:14 +0000 (19:02 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 10 Oct 2023 17:02:14 +0000 (19:02 +0200)
app/Elearning/QuizCompiler.php
app/Models/QuizTheme.php

index 2dbbefab66d7f4d043874ff0b877f0717d2e7c2d..72c6579761e78388519a48b46d9e4ed82914fd45 100644 (file)
@@ -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
index bdee95dd198dfcc96874d8894e0567143908efb8..d1e1b8b5298c420034268f0a722e78602f6a5ab7 100644 (file)
@@ -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,
-        };
     }
 
     /**