]> _ Git - fluidbook-toolbox.git/commitdiff
wip #6381 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 11 Oct 2023 09:58:07 +0000 (11:58 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 11 Oct 2023 09:58:07 +0000 (11:58 +0200)
app/Elearning/QuizCompiler.php
app/Elearning/QuizCompiler/Animations.php
app/Models/QuizTheme.php

index 71a413ae6497e1bc2efddc0f38bd9ad2fd39df6b..fe7d0d44ddb86602bfc8d65b0324542c4738bbf5 100644 (file)
@@ -140,6 +140,7 @@ class QuizCompiler extends Base
     {
         // Main texts color
         $this->sassVariables['texts-color'] = $this->theme->getTextsColor();
+        $this->sassVariables['button-texts-color'] = $this->theme->getButtonTextColor();
         $this->sassVariables['opposite-texts-color'] = $this->theme->getTextsColor(true);
         // Font
         $this->sassVariables['font'] = $this->_font($this->theme->font);
index a0edd1b1385679ffc011e742f434a26b8193981a..67ac059d02fff7e749fa76bfbb7e72ba7c4d9034 100644 (file)
@@ -14,8 +14,8 @@ trait Animations
     const OK_COLOR = '#16BFBF';
     const NOK_COLOR = '#D0167C';
     const CONFETTI_COLOR = '#E4FF19';
-
-    const TEXT_COLOR = "#ffffff";
+    const TEXT_COLOR = "#66666F";
+    const BUTTON_TEXT_COLOR = "#33333F";
 
     protected $animations = [];
 
@@ -26,10 +26,11 @@ trait Animations
     protected function writeAnimations()
     {
         $colors = [
+            self::BUTTON_TEXT_COLOR => $this->theme->getButtonTextColor(),
+            self::TEXT_COLOR => $this->theme->getTextsColor(),
             self::OK_COLOR => $this->theme->okColor,
             self::CONFETTI_COLOR => $this->theme->okColor,
             self::NOK_COLOR => $this->theme->nokColor,
-            self::TEXT_COLOR => $this->theme->getTextsColor(),
         ];
         $animationReplace = [];
         $animationPregReplace = [];
index 6d181232ffb966602f1adab1eb2d4c96038b5943..02ea5b65f3038869181719347b4d8be0de9d1d52 100644 (file)
@@ -65,6 +65,7 @@ class QuizTheme extends ToolboxModel
     {
         $this->addField('sectionTexts', FormSection::class, __('Textes'));
         $this->addField('textColor', SelectFromArray::class, __('Couleur des textes'), ['default' => 'auto', 'options' => ['auto' => __('Automatique'), 'light' => __('Blanc'), 'dark' => __('Noir')]]);
+        $this->addField('buttonTextColor', SelectFromArray::class, __('Couleur de texte du bouton principal'), ['default' => 'auto', 'options' => ['auto' => __('Automatique'), 'light' => __('Blanc'), 'dark' => __('Noir')]]);
         $this->addField('font', FluidbookFont::class, __('Police de caractères'), ['default' => 'SourceSans', 'databaseDefault' => 'SourceSans']);
     }
 
@@ -142,13 +143,23 @@ class QuizTheme extends ToolboxModel
     }
 
     public function getTextsColor($opposite = false)
+    {
+        return $this->_getAutoTextColor($this->neutralColor, $this->textColor, $opposite);
+    }
+
+    public function getButtonTextColor($opposite = false)
+    {
+        return $this->_getAutoTextColor($this->mainColor, $this->buttonTextColor, $opposite);
+    }
+
+    protected function _getAutoTextColor($base, $color, $opposite = false)
     {
         $darkColor = '#383838';
         $lightColor = '#ffffff';
 
-        if ($this->textColor == 'auto' || !$this->textColor) {
+        if ($color == 'auto' || !$color) {
             // If auto mode, check between black and white which have the biggest distance (i.e. most contrast) with neutralColor
-            $neutral = new \Cubist\Util\Graphics\Color($this->neutralColor);
+            $neutral = new \Cubist\Util\Graphics\Color($base);
             $black = new \Cubist\Util\Graphics\Color($darkColor);
             $white = new \Cubist\Util\Graphics\Color($lightColor);
             $distBlack = $neutral->distance($black);
@@ -159,7 +170,7 @@ class QuizTheme extends ToolboxModel
                 $res = $darkColor;
             }
         } else {
-            $res = match ($this->textColor) {
+            $res = match ($color) {
                 'dark' => $darkColor,
                 '#000000' => $darkColor,
                 '#ffffff' => $lightColor,