]> _ Git - fluidbook-toolbox.git/commitdiff
wait #6336 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 5 Oct 2023 16:30:57 +0000 (18:30 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 5 Oct 2023 16:30:57 +0000 (18:30 +0200)
app/Elearning/QuizCompiler.php
app/Models/QuizTheme.php

index ae7f7fe1510956eac6dc1b7e43a3160843272b02..b7e5a6f623eb1444e10f0bc96b11f74f3c77a806 100644 (file)
@@ -139,7 +139,7 @@ class QuizCompiler extends Base
         // Font
         $this->sassVariables['font'] = $this->_font($this->theme->font);
         // Colors
-        $this->sassVariables['accent-color']=$this->theme->mainColor;
+        $this->sassVariables['accent-color'] = $this->theme->mainColor;
         $this->sassVariables['neutral-color'] = $this->theme->neutralColor;
         $this->sassVariables['ok-color'] = $this->theme->okColor;
         $this->sassVariables['nok-color'] = $this->theme->nokColor;
@@ -155,64 +155,39 @@ class QuizCompiler extends Base
 
         // Main background
         $this->sassVariables['background-color'] = Color::colorToCSS($this->theme->backgroundColor);
-        $this->sassVariables['background-custom'] = $this->theme->backgroundCustom ? 'true' : 'false';
 
-        $this->data->set('mainBackground', '');
-        $this->data->set('mainBackgroundMobile', '');
+        $this->_addBackgrounds('background');
+        $this->_addBackgrounds('intro');
 
-        if ($this->theme->backgroundCustom) {
-            $this->_addBackgroundVariables('background-desktop', 'background', 'mainBackground');
-            if ($this->theme->backgroundCustomMobile) {
-                $this->_addBackgroundVariables('background-mobile', 'background', 'mainBackgroundMobile', 'Mobile');
+        $this->writeSass();
+    }
+
+    protected function _addBackgrounds($dataKey, $sassPrefix = null, $themePrefix = null)
+    {
+        $themePrefix = $themePrefix ?? $dataKey;
+        $sassPrefix = $sassPrefix ?? $dataKey;
+        $this->data->set($dataKey, 'Image');
+        $this->data->set($dataKey . 'ImageMobile', '');
+
+
+        if ($this->theme->{$dataKey . 'Custom'}) {
+            $this->_addBackgroundVariables($sassPrefix . '-desktop', $themePrefix, $dataKey);
+            if ($this->theme->{$dataKey . 'CustomMobile'}) {
+                $this->_addBackgroundVariables($sassPrefix . '-mobile', $themePrefix, $dataKey . 'Mobile', 'Mobile');
             } else {
-                $this->_addBackgroundVariables('background-mobile', 'background', 'mainBackgroundMobile');
+                $this->_addBackgroundVariables($sassPrefix . '-mobile', $themePrefix, $dataKey . 'Mobile');
             }
         }
-
-
-        $this->writeSass();
     }
 
     protected function _addBackgroundVariables($sassPrefix, $themePrefix, $dataKey, $themeSuffix = '')
     {
 
-        $i=$this->data['theme']->{$themePrefix . 'Image' . $themeSuffix};
+        $i = $this->data['theme']->{$themePrefix . 'Image' . $themeSuffix};
         $this->data->set($dataKey, $i);
-        if(stristr($i,'.json')){
-            $this->animations[$i]=file_get_contents($this->theme->getPageData()->getImageFile($themePrefix . 'Image' . $themeSuffix));
+        if (stristr($i, '.json')) {
+            $this->animations[$i] = file_get_contents($this->theme->getPageData()->getImageFile($themePrefix . 'Image' . $themeSuffix));
         }
-
-        switch ($this->data['theme']->{$themePrefix . 'Size' . $themeSuffix}) {
-            case ThemeBackgroundSize::RATIO:
-                $size = 'cover';
-                break;
-            case ThemeBackgroundSize::NONE:
-                $size = 'none';
-                break;
-            default:
-            case ThemeBackgroundSize::STRETCH:
-                $size = 'fill';
-                break;
-
-        }
-
-        $positionx = match ($this->data['theme']->{$themePrefix . 'HorizontalAlign' . $themeSuffix}) {
-            HorizontalAlign::LEFT => '0%',
-            HorizontalAlign::CENTER => '50%',
-            HorizontalAlign::RIGHT => '100%',
-            default => '50%',
-        };
-
-        $positiony = match ($this->data['theme']->{$themePrefix . 'VerticalAlign' . $themeSuffix}) {
-            VerticalAlign::TOP => '0%',
-            VerticalAlign::MIDDLE => '50%',
-            VerticalAlign::BOTTOM => '100%',
-            default => '50%',
-        };
-
-        $this->sassVariables[$sassPrefix . '-size'] = $size;
-        $this->sassVariables[$sassPrefix . '-position-x'] = $positionx;
-        $this->sassVariables[$sassPrefix . '-position-y'] = $positiony;
     }
 
     protected function _font($f)
index eb718abd34efbfee8ef33d77f3fbefc47fd387b9..bb1d48e6ff133008851a0aa5cad75b189ff6c536 100644 (file)
@@ -89,15 +89,15 @@ class QuizTheme extends ToolboxModel
         $this->addField('', FormSeparator::class);
         $this->addField('backgroundCustom', Checkbox::class, __('Définir un fond personnalisé ou animé'));
         $this->addField('backgroundImage', FluidbookThemeImage::class, __('Image ou animation'), ['hint' => __('Taille recommandée : :size', ['size' => '1200 x 680px']), 'when' => ['backgroundCustom' => 1]]);
-        $this->addField('backgroundSize', ThemeBackgroundSize::class, __('Affichage du fond'), ['when' => ['backgroundCustom' => 1]]);
-        $this->addField('backgroundHorizontalAlign', HorizontalAlign::class, __('Alignement horizontal'), ['when' => ['backgroundCustom' => 1]]);
-        $this->addField('backgroundVerticalAlign', VerticalAlign::class, __('Alignement vertical'), ['when' => ['backgroundCustom' => 1]]);
+//        $this->addField('backgroundSize', ThemeBackgroundSize::class, __('Affichage du fond'), ['when' => ['backgroundCustom' => 1]]);
+//        $this->addField('backgroundHorizontalAlign', HorizontalAlign::class, __('Alignement horizontal'), ['when' => ['backgroundCustom' => 1]]);
+//        $this->addField('backgroundVerticalAlign', VerticalAlign::class, __('Alignement vertical'), ['when' => ['backgroundCustom' => 1]]);
         $this->addField('', FormSeparator::class, '', ['when' => ['backgroundCustom' => 1]]);
         $this->addField('backgroundCustomMobile', Checkbox::class, __('Définir un fond spécifique sur mobile'), ['when' => ['backgroundCustom' => 1]]);
         $this->addField('backgroundImageMobile', FluidbookThemeImage::class, __('Image ou animation'), ['hint' => __('Taille recommandée : :size', ['size' => '390 x 844px']), 'when' => ['backgroundCustom' => 1, 'backgroundCustomMobile' => 1]]);
-        $this->addField('backgroundSizeMobile', ThemeBackgroundSize::class, __('Affichage du fond'), ['when' => ['backgroundCustom' => 1, 'backgroundCustomMobile' => 1]]);
-        $this->addField('backgroundHorizontalAlignMobile', HorizontalAlign::class, __('Alignement horizontal'), ['when' => ['backgroundCustom' => 1, 'backgroundCustomMobile' => 1]]);
-        $this->addField('backgroundVerticalAlignMobile', VerticalAlign::class, __('Alignement vertical'), ['when' => ['backgroundCustom' => 1, 'backgroundCustomMobile' => 1]]);
+//        $this->addField('backgroundSizeMobile', ThemeBackgroundSize::class, __('Affichage du fond'), ['when' => ['backgroundCustom' => 1, 'backgroundCustomMobile' => 1]]);
+//        $this->addField('backgroundHorizontalAlignMobile', HorizontalAlign::class, __('Alignement horizontal'), ['when' => ['backgroundCustom' => 1, 'backgroundCustomMobile' => 1]]);
+//        $this->addField('backgroundVerticalAlignMobile', VerticalAlign::class, __('Alignement vertical'), ['when' => ['backgroundCustom' => 1, 'backgroundCustomMobile' => 1]]);
     }