]> _ Git - ccv-wordpress.git/commitdiff
WIP #3053 @8
authorStephen Cameron <stephen@cubedesigners.com>
Tue, 21 Apr 2020 16:12:17 +0000 (18:12 +0200)
committerStephen Cameron <stephen@cubedesigners.com>
Tue, 21 Apr 2020 16:12:17 +0000 (18:12 +0200)
13 files changed:
wp-content/mu-plugins/cube/src/Elementor/Widgets/BackgroundImage.php
wp-content/mu-plugins/cube/src/Forms/Consultation.php
wp-content/themes/CCV/package.json
wp-content/themes/CCV/resources/assets/styles/common/admin.styl
wp-content/themes/CCV/resources/assets/styles/common/global.styl
wp-content/themes/CCV/resources/assets/styles/components/lity-lightbox.styl [new file with mode: 0644]
wp-content/themes/CCV/resources/assets/styles/widgets/background-image.styl
wp-content/themes/CCV/resources/assets/styles/widgets/header-slideshow.styl
wp-content/themes/CCV/resources/assets/styles/widgets/text-block.styl
wp-content/themes/CCV/resources/assets/styles/widgets/timeline-horizontal.styl
wp-content/themes/CCV/resources/views/forms/consultation.blade.php
wp-content/themes/CCV/webpack.mix.js
wp-content/themes/CCV/yarn.lock

index 7bf2b64c2435d55a38ba1b41c546d64b6bde9987..a46dc854928420618540f9fe57d44204fba45415 100644 (file)
@@ -3,6 +3,7 @@
 namespace Cube\Elementor\Widgets;
 
 use Elementor\Controls_Manager;
+use Elementor\Embed;
 use Elementor\Utils;
 
 
@@ -80,6 +81,19 @@ class BackgroundImage extends _Base {
                 ],
             ]
         );
+
+        $this->add_control(
+            'link',
+            [
+                'label' => __('Lien', 'cube'),
+                'type' => Controls_Manager::URL,
+                'default' => [
+                    'url' => '',
+                    'is_external' => false,
+                ],
+                'show_external' => true
+            ]
+        );
         
         $this->end_controls_section();
 
@@ -96,6 +110,10 @@ class BackgroundImage extends _Base {
 
         $image = $this->get_settings('image');
         $bg_position = $this->get_settings('background_position');
+        $link = $this->get_settings('link');
+        $tag = 'div'; // Default tag for widget - will change when we need a non-lightbox link
+        $attributes = '';
+        $class = '';
 
         if (is_numeric($image['id'])) {
             $meta = wp_get_attachment_metadata($image['id']);
@@ -106,7 +124,57 @@ class BackgroundImage extends _Base {
             $ratio = '80%';
         }
 
-        echo '<div class="bg-image" style="background-image: url('. $image['url'] .'); background-position: '. $bg_position .'"><div class="bg-image-sizer" style="padding-bottom: '. $ratio .'"></div></div>';
+        // Handle links / video
+        if (!empty( $link['url'])) {
+
+            // If the link is to a youtube video, we want this to open in a lightbox instead
+            // For now only supporting links that start with https://www.youtube.com or https://youtu.be...
+            if (strpos($link['url'], 'https://www.youtube.com') === 0 || strpos($link['url'], 'https://youtu.be') === 0) {
+
+                $attributes  = "data-elementor-lightbox='". $this->lightbox($link['url'], $this->get_id()) ."'";
+                $attributes .= ' data-elementor-open-lightbox="yes"';
+                $class = 'cursor-pointer';
+
+            } else { // Normal link
+
+                $tag = 'a';
+                $attributes = 'href="'. $link['url'] .'"';
+
+                if ($link['is_external']) {
+                    $attributes .= ' target="_blank"';
+                }
+
+                if ($link['nofollow']) {
+                    $attributes .= ' rel="nofollow"';
+                }
+            }
+
+        }
+
+        echo '<'. $tag .' class="bg-image '. $class .'" '. $attributes .' style="background-image: url('. $image['url'] .'); background-position: '. $bg_position .'"><div class="bg-image-sizer" style="padding-bottom: '. $ratio .'"></div></'. $tag .'>';
+
+    }
+
+
+    // Generate Elementor lightbox settings
+    public static function lightbox($url, $element_ID) {
+
+        // Video settings for lightbox embed
+        $embed_params = [
+            'rel' => 0, // Don't show related videos at the end of playback
+            'showinfo' => 0 // Hide info
+        ];
+
+        $lightbox_options = [
+            'type'         => 'video',
+            'url'          => Embed::get_embed_url($url, $embed_params),
+            'modalOptions' => [
+                'id'                => 'elementor-lightbox-' . $element_ID,
+                'entranceAnimation' => 'zoomIn',
+                'videoAspectRatio'  => '169',
+            ],
+        ];
 
+        return wp_json_encode($lightbox_options);
     }
 }
index d079510d9236029499d4c007be17694e64cfa3a4..92ff4eee4565e18ef5905182a1eaebbb15e815d5 100644 (file)
@@ -10,13 +10,9 @@ class Consultation extends Base
 
         parent::register_scripts();
 
-        wp_enqueue_script(
-            'ccv-consultation',
-            asset('scripts/consultation.js'),
-            ['jquery'], // Dependencies
-            null, // Version
-            true // In footer?
-        );
+        wp_enqueue_script('ccv-consultation', asset('scripts/consultation.js'), ['jquery'], null, true);
+        wp_enqueue_script('lity', asset('scripts/lity.js'), ['jquery'], null, true);
+        wp_enqueue_style('lity-css', asset('styles/lity.min.css'));
     }
 
 
index 915a58dd4cd3ff49c4fd5f448427bdae2217846d..88e8d1d0e9d8d390f65601b2157ff751bd1d6f17 100644 (file)
@@ -26,6 +26,7 @@
     "flatpickr": "^4.6.3",
     "laravel-mix": "^5.0.4",
     "laravel-mix-purgecss": "^4.2.0",
+    "lity": "^2.4.0",
     "lodash.debounce": "^4.0.8",
     "lost": "^8.3.1",
     "mix-tailwindcss": "^1.0.2",
index 9d6db74c3b202560bbf6326ab93fc6d804c738c6..51dd41cb60fdb1092c521c73b88aaf14293eb6c2 100644 (file)
   // visible while editing...
   ul
     margin-left: 1.3em
+
+//===== Admin bar tweaks
+$breakpoint-admin-bar = 783px
+$admin-bar-height = 32px
+$admin-bar-height-mobile = 46px
+
+#wpadminbar
+  overflow: hidden
+
+#wp-toolbar
+  display: flex
+  justify-content: space-between
+
+  > *
+    display: flex
+    white-space: nowrap
+
+  // Wrap/hide extra toolbar items on the left when there's not enough space
+  #wp-admin-bar-root-default
+    flex-wrap: wrap
+
+  #wp-admin-bar-top-secondary
+    flex-shrink: 0
+
+body.admin-bar
+  +above($breakpoint-admin-bar)
+    position: relative
+
+    #mobile-menu, .lity-close
+      top: $admin-bar-height
+
+  +below($breakpoint-admin-bar)
+    #mobile-menu
+      top: $admin-bar-height-mobile
+
+    .mobile-menu-trigger
+      top: 30px + $admin-bar-height-mobile
index fec93e3dbc2e6c45319724069390e97fc63be04d..36c168c9bd4ead5a8df8875d48bec2a0d199ef39 100644 (file)
@@ -20,3 +20,7 @@ body
 .wrapper
   @apply mx-auto
   max-width: $content-max-width
+
+//-- Elementor Lightbox customisations
+.dialog-type-lightbox
+  background-color: rgba(#2E2C40, 0.8)
diff --git a/wp-content/themes/CCV/resources/assets/styles/components/lity-lightbox.styl b/wp-content/themes/CCV/resources/assets/styles/components/lity-lightbox.styl
new file mode 100644 (file)
index 0000000..6dfa755
--- /dev/null
@@ -0,0 +1,8 @@
+//=== Lity Lightbox customisations
+.lity
+  background-color: rgba(#2E2C40, 0.8)
+
+// Prevent scrolling in background when lightbox is open
+.lity-active body
+  overflow: hidden
+  height: 100vw
index 24955f2ff709853b6b93e90040c1e11a9d492469..09bdaaacb36a51757ba4d4a3b48d687dc2300a7a 100644 (file)
@@ -1,4 +1,5 @@
 .bg-image
+  display: block
   background-size: cover
   background-repeat: no-repeat
   background-position: center
index 35c7ce47e3dd3b8b58cc045c609040bbfc5f160b..4bb4d4479ae8ff2dd178a7e3bc221fd3b25e103c 100644 (file)
@@ -14,7 +14,8 @@ $title_bg = rgba(#fff, 0.88)
         left: 0
         width: 100%
         height: 100%
-        background-image: linear-gradient(to bottom, #fff 10%, transparent 50%)
+        //background-image: linear-gradient(to bottom, #fff 10%, transparent 50%)
+        //background-image: linear-gradient(180deg, rgba(255,255,255,1) -5%,rgba(255,255,255,0.9) 17%, transparent 55%)
         z-index: 5
 
     // Change to portrait oriented images for small screens
index ba3e70ce1583e23495c75646045966dafcc216a1..9e2ec587eace7e2fdcee54ee68be6cc3a83cb258 100644 (file)
@@ -15,6 +15,8 @@
 .text-block
   .text-block-align-center &
     text-align: center
+    margin-left: auto
+    margin-right: auto
 
   > * + * // Automatic spacing between direct child elements
     margin-top: 1.5em
index e72d7ce357d0b32d74db4d735ba8b50bfbb96490..bdba007b5b82c30bda31aad5dc79f42623200da3 100644 (file)
@@ -2,7 +2,7 @@ $breakpoint-timeline-horizontal = 900px // When timeline changes to mobile view
 
 .timeline-horizontal
   +below($breakpoint-timeline-horizontal)
-    @apply flex flex-row-reverse
+    @apply flex flex-row
 
     // Scale all em children
     font-size: 22px fixed
@@ -66,7 +66,7 @@ $breakpoint-timeline-horizontal = 900px // When timeline changes to mobile view
     &-mobile
       width: 100%
       max-width: 250px !important;
-      padding-right: 2em;
+      padding-left: 2em;
 
       +above($breakpoint-timeline-horizontal)
         display: none
index bcbce1073fcb14e469156e6ce5eb3b288627fd5e..3f81f070376833c05bafe650dd38a11601ab9a49 100644 (file)
           {{ __('Vos images sont sur un CD ?', 'ccv') }}
         </div>
         <p>
-          {{ __("Envoyez-nous l'ensemble des fichiers contenus sur votre CD en cliquant sur le lien ci-dessous :", "ccv") }}
+          {{ __("Envoyez-nous l'ensemble des fichiers contenus sur votre CD :", "ccv") }}
         </p>
 
-        <a href="javascript://" class="btn mt-6" data-update-imagery-type>{{ __('Envoyer vos fichiers', 'ccv') }}</a>
+        <a href="https://uploader.purview.net/client/scmgeneste/" target="_blank" class="btn mt-6" data-lity data-update-imagery-type>{{ __('Parcourir', 'ccv') }}</a>
       </div>
     </div>
 
           {{ __('Vous remplissez cette demande depuis votre téléphone ?', 'ccv') }}
         </div>
         <p>
-          {{ __('Prenez vos images en photo et envoyez-les directement depuis votre téléphone.', 'ccv') }}
+          {{ __('Prenez vos images en photo et envoyez-les directement depuis votre téléphone :', 'ccv') }}
         </p>
         <a href="javascript://" class="btn mt-6" data-update-imagery-type>{{ __('Parcourir') }}</a>
       </div>
index 5d6d3e2c11bf12f7e7d530c0cd80f7933303cc07..6b84e37de2d7e3a52b507f5094b858c566a32831 100644 (file)
@@ -60,6 +60,10 @@ mix.js(src`scripts/app.js`, 'scripts')
    .js(src`scripts/customizer.js`, 'scripts')
    .extract(['mmenu-light']); // Extract any libraries that will rarely change to a vendor.js file
 
+// Lity lightbox
+mix.copy('node_modules/lity/dist/lity.js', publicPath`scripts`);
+mix.copy('node_modules/lity/dist/lity.min.css', publicPath`styles`);
+
 // Assets
 mix.copyDirectory(src`images`, publicPath`images`)
    .copyDirectory(src`fonts`, publicPath`fonts`);
index 32e583dfb43d575cca5096dffe68413524724c1c..03938365104649b8901fed64c60f19eb4f342c10 100644 (file)
@@ -4838,6 +4838,11 @@ limiter@^1.0.5:
   resolved "https://registry.yarnpkg.com/limiter/-/limiter-1.1.4.tgz#87c9c3972d389fdb0ba67a45aadbc5d2f8413bc1"
   integrity sha512-XCpr5bElgDI65vVgstP8TWjv6/QKWm9GU5UG0Pr5sLQ3QLo8NVKsioe+Jed5/3vFOe3IQuqE7DKwTvKQkjTHvg==
 
+lity@^2.4.0:
+  version "2.4.0"
+  resolved "https://registry.yarnpkg.com/lity/-/lity-2.4.0.tgz#af7eb0c33efe3b21c31ab22848e608eca432e819"
+  integrity sha512-6sj/IjJ6bDWdWcvo15r12erzVkVQFx8xA5dWT3WjuJxCns8o7PEkDAjfTjaoy6wbR2KDxAfxBWqY9YNnpAUWPQ==
+
 load-json-file@^1.0.0:
   version "1.1.0"
   resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-1.1.0.tgz#956905708d58b4bab4c2261b04f59f31c99374c0"