]> _ Git - ccv-wordpress.git/commitdiff
WIP #3053
authorStephen Cameron <stephen@cubedesigners.com>
Thu, 31 Oct 2019 17:35:46 +0000 (18:35 +0100)
committerStephen Cameron <stephen@cubedesigners.com>
Thu, 31 Oct 2019 17:35:46 +0000 (18:35 +0100)
14 files changed:
wp-content/mu-plugins/cube/src/Elementor/Widgets/HeaderSlideshow.php
wp-content/mu-plugins/cube/src/Elementor/Widgets/NewsBanner.php
wp-content/themes/CCV/app/filters.php
wp-content/themes/CCV/resources/assets/scripts/header-slideshow.js
wp-content/themes/CCV/resources/assets/styles/app.styl
wp-content/themes/CCV/resources/assets/styles/components/navigation.styl
wp-content/themes/CCV/resources/assets/styles/components/news.styl
wp-content/themes/CCV/resources/assets/styles/components/sections.styl
wp-content/themes/CCV/resources/assets/styles/widgets/header-slideshow.styl
wp-content/themes/CCV/resources/assets/styles/widgets/link-carousel.styl
wp-content/themes/CCV/resources/views/partials/content-single.blade.php
wp-content/themes/CCV/resources/views/partials/content.blade.php
wp-content/themes/CCV/tailwind.config.js
wp-content/themes/CCV/webpack.mix.js

index 41a8f26e9559d0a637cc8aba25e582281091e716..0ce746e5224d50257ab692a60f4e43a4aea4fba1 100644 (file)
@@ -70,54 +70,36 @@ class HeaderSlideshow extends Widget_Base {
         );
 
         $this->add_control(
-            'title',
+            'content_image',
             [
-                'label' => __( 'Title', 'elementor' ),
-                'type' => Controls_Manager::TEXTAREA,
-                'placeholder' => __( 'Enter your title', 'elementor' ),
-                'default' => '',
+                'label' => __( 'Content Image', 'cube' ),
+                'type' => Controls_Manager::MEDIA,
+                'label_block' => true,
+                'default' => [
+                    'url' => Utils::get_placeholder_image_src(),
+                ],
             ]
         );
 
         $this->add_control(
-            'subtitle',
+            'images_desktop',
             [
-                'label' => __( 'Subtitle', 'cube' ),
-                'type' => Controls_Manager::TEXTAREA,
-                'placeholder' => __( 'Enter your subtitle', 'cube' ),
-                'default' => '',
+                'label' => __( 'Desktop Images (1920px &times; 912px)', 'cube' ),
+                'type' => Controls_Manager::GALLERY,
+                'default' => [],
+                'show_label' => true,
             ]
         );
 
         $this->add_control(
-            'images',
+            'images_mobile',
             [
-                'label' => __( 'Slideshow Images', 'cube' ),
-                'type' => Controls_Manager::REPEATER,
-                'fields' => [
-                    [
-                        'name' => 'desktop',
-                        'label' => __('Desktop image (1920px &times; 912px)', 'cube'),
-                        'label_block' => true,
-                        'type' => Controls_Manager::MEDIA,
-                        'default' => [
-                            'url' => Utils::get_placeholder_image_src(),
-                        ],
-                    ],
-                    [
-                        'name' => 'mobile',
-                        'label' => __('Mobile image (portrait orientation)', 'cube'),
-                        'label_block' => true,
-                        'type' => Controls_Manager::MEDIA,
-                        'default' => [
-                            'url' => Utils::get_placeholder_image_src(),
-                        ],
-                    ],
-                ],
-                'title_field' => '<img src="{{{ desktop.url }}}">',
+                'label' => __( 'Mobile Images (portrait orientation)', 'cube' ),
+                'type' => Controls_Manager::GALLERY,
+                'default' => [],
+                'show_label' => true,
             ]
         );
-
         
         $this->end_controls_section();
     }
@@ -131,14 +113,14 @@ class HeaderSlideshow extends Widget_Base {
     protected function render() {
 
         $id = 'header_slideshow_' . $this->get_id();
-        $title = $this->get_settings('title');
-        $subtitle = $this->get_settings('subtitle');
-        $images = $this->get_settings('images');
+        $content_image = $this->get_settings('content_image');
+        $images_desktop = $this->get_settings('images_desktop');
+        $images_mobile = $this->get_settings('images_mobile');
 
-        if (!$images || count($images) < 1) return false; // Must have images to display
+        if (!$images_desktop || count($images_desktop) < 1) return false; // Must have images to display
 
         // Use first image in gallery to set size of slideshow
-        $image_meta = wp_get_attachment_metadata($images[0]['id']);
+        $image_meta = wp_get_attachment_metadata($images_desktop[0]['id']);
         $image_ratio = round($image_meta['height'] / $image_meta['width'] * 100, 2) . '%';
 
         // When this element is present, add a class to the body so the header can be styled differently (transparent background)
@@ -152,16 +134,18 @@ class HeaderSlideshow extends Widget_Base {
 
         <div class="header-slideshow elementor" id="<?= $id ?>">
 
-            <?php foreach($images as $index => $image): ?>
+            <?php foreach($images_desktop as $index => $desktop_image): ?>
                 <div class="header-slideshow-image<?= $index === 0 ? ' showing' : '' ?>">
 
-                    <?php if ($image['mobile']['id'] > 0): ?>
-                        <div class="header-slideshow-image-mobile" style="background-image:url(<?= wp_get_attachment_image_url($image['mobile']['id'], 'full') ?>);"></div>
-                     <?php endif; ?>
+                    <?php if (isset($images_mobile[$index]['id'])): ?>
+                        <div class="header-slideshow-image-mobile"
+                             style="background-image:url(<?= wp_get_attachment_image_url($images_mobile[$index]['id'], 'full') ?>);">
+                        </div>
+                    <?php endif; ?>
 
-                    <?php if ($image['desktop']['id'] > 0): ?>
-                        <div class="header-slideshow-image-desktop" style="background-image:url(<?= wp_get_attachment_image_url($image['desktop']['id'], 'full') ?>);"></div>
-                     <?php endif; ?>
+                    <div class="header-slideshow-image-desktop"
+                         style="background-image:url(<?= wp_get_attachment_image_url($desktop_image['id'], 'full') ?>);">
+                    </div>
 
                 </div>
             <?php endforeach; ?>
@@ -177,12 +161,14 @@ class HeaderSlideshow extends Widget_Base {
                 */
                 ?>
 
-                <div class="header-slideshow-content mx-2v elementor-element elementor-invisible" data-settings='{"animation":"fadeInRight","animation_delay":0}' data-element_type="section">
-                    <h1 class="header-slideshow-title">
-                        <span class="header-slideshow-title-text"><?= nl2br($title) ?></span>
-                        <span class="header-slideshow-subtitle"><?= $subtitle ?></span>
-                    </h1>
-                </div>
+                <?php if (isset($content_image['id']) && $content_image['id'] > 0): ?>
+
+                    <img src="<?= wp_get_attachment_image_url($content_image['id']) ?>"
+                         class="header-slideshow-content elementor-element elementor-invisible"
+                         data-settings='{"animation":"fadeInRight","animation_delay":0}'
+                         data-element_type="section"
+                         alt="<?= __('Bienvenue au CCV Montpellier - centre de chirurgie vertébrale de Montpellier') ?>">
+                <?php endif; ?>
 
             </div>
         </div>
index 3b1ba3a6b2f3e0082265818513d6a02a5804d632..2d19caa46ee1d4ea05ed6864b1566eb49e900b20 100644 (file)
@@ -88,7 +88,7 @@ class NewsBanner extends Widget_Base {
 
         if ($post && isset($post[0]['post_title'])) {
 
-            echo '<div class="bg-purple-dark text-white px-2v py-4 flex items-center justify-between sm:flex-col sm:items-start">';
+            echo '<div class="bg-purple-dark text-white px-2v py-4 flex items-center justify-between sm:flex-col sm:items-start sm:py-6">';
             echo '<a href="'. get_permalink($post[0]['ID']) .'" class="pr-4 sm:pr-0 sm:mb-4">'. $post[0]['post_title'] .'</a>';
             echo '<a href="'. get_permalink(get_option('page_for_posts')) .'" class="btn whitespace-no-wrap flex-shrink-0">'. __("Voir toute l'actualité", 'cube') .'</a>';
             echo '</div>';
index 0ccd7ec41ec5269c0e6c96fcdbfe8cd672eae531..d017f9452875908277372a179063aff1414280f0 100644 (file)
@@ -6,5 +6,5 @@ namespace App;
  * Add "… Continued" to the excerpt
  */
 add_filter('excerpt_more', function () {
-    return ' &hellip; <a href="' . get_permalink() . '">' . __('Continued', 'sage') . '</a>';
+    return '&hellip;';
 });
index ce5a6689d340cc61eb16ac44ded80f9f4a415d54..d69a895a82fe89c016f662b1345bc64d6b99f0ce 100644 (file)
@@ -12,10 +12,6 @@ import debounce from 'lodash.debounce';
 
       initSlideshow();
 
-      // Todo: handle resizing here for small screens - scale content (origin: bottom left) so it always fits...
-      // Todo: when scaling, set content div to 100% and title element to display inline-block to keep correct appearance.
-
-
       function initSlideshow() {
         let slideshowDots = document.createElement('ul');
         slideshowDots.className = 'header-slideshow-dots';
@@ -36,40 +32,8 @@ import debounce from 'lodash.debounce';
           clearInterval(slideInterval); // Stop autoplay
           showSlide($(this).data('slide'));
         });
-
-        // Handle resizing when window resizes
-        $(window).on('resize', debounce(resizeSlideshow, 100));
-        resizeSlideshow();
-      }
-
-      function resizeSlideshow() {
-        const content = $scope.find('.header-slideshow-content');
-        const title = $scope.find('.header-slideshow-title');
-        const resizeBreakpoint = 1000; // When to start resizing
-        const targetWidth = 650; // The max width of the title block + spacing
-        let windowWidth = $(window).width();
-
-
-        if (windowWidth > resizeBreakpoint) {
-          content.attr('style', '');
-          title.attr('style', '');
-        } else {
-          let scale = Math.min(1, windowWidth / targetWidth);
-
-          content.css({
-            transform: `scale(${scale})`,
-            transformOrigin: 'bottom left',
-            width: '100%',
-            margin: '0'
-          });
-          title.css({
-            display: 'inline-block'
-          })
-        }
-
       }
 
-
       function showSlide(index) {
         $(slides[currentSlide]).removeClass('showing');
         $scope.find(`[data-slide="${currentSlide}"]`).removeClass('active');
index 880820811bd5d48536537c13a95eb95ab875d0dc..19d8eacbc4c003e982265a2dcf1b2fea6926697b 100644 (file)
@@ -2,6 +2,8 @@
 @tailwind base
 @tailwind components
 
+/*! purgecss start ignore */
+
 // Stylus Setup
 @import 'common/setup'
 @import 'common/mixins'
@@ -19,6 +21,8 @@
 @import 'widgets/*'
 //@import 'pages/*'
 
+/*! purgecss end ignore */
+
 // Utilities go last in source order so they can
 // override other classes with the same specificity
 @tailwind utilities
index bb7c0eedc0e18868c8bf649202af8ee4f2f83ad8..d4f85805304e5755d83a8e8ac370704250fb4d1f 100644 (file)
@@ -11,7 +11,7 @@
     @apply border-b-2 border-transparent // Reserve space for active border
     @apply py-1 leading-tight // Adjust active border spacing
 
-    &.current-menu-item
+    &.current-menu-item, &.current-menu-parent
       @apply border-pink
 
     &:last-child
index 29904f8c034748518ee985e145fd451592fb2f1c..d190c764e59b88c353bfbab8002d8627a1bbb1c1 100644 (file)
@@ -4,6 +4,7 @@
     @apply bg-gray-300 bg-cover bg-center
     @apply w-full
     constrain(margin-right, 5vw)
+    constrain(margin-bottom, 5vw)
     max-width: 336px
 
     &-sizer
index 6ae591c12749095c7a536a4ec0b4c3391052d468..c1e8afb5d93090a40c99d4f076e98def3c855204 100644 (file)
@@ -3,8 +3,8 @@
   +below($breakpoint-columns)
     .elementor-column
       width: 100% !important
-      &:not(:last-of-type)
-        margin-bottom: 7.5vw
+      //&:not(:last-of-type)
+      //  margin-bottom: 7.5vw
 
   // There's a toggle in the editor so we can disable
   // this margin between columns when stacking vertically
index 98fa37084f1f4a11738a7b570d7c5f7b573cb1a8..35c7ce47e3dd3b8b58cc045c609040bbfc5f160b 100644 (file)
@@ -19,7 +19,7 @@ $title_bg = rgba(#fff, 0.88)
 
     // Change to portrait oriented images for small screens
     +below($breakpoint-slideshow-images)
-      padding-bottom: 148% !important // Based off mockup: 555px / 375px
+      padding-bottom: 140% !important // Based off mockup: 525px / 375px
 
   &-image
     position: absolute
@@ -61,7 +61,7 @@ $title_bg = rgba(#fff, 0.88)
     z-index: 15
 
     +below($breakpoint-slideshow)
-      bottom: 1em
+      bottom: 1.5em
 
     li
       @apply bg-purple-dark
@@ -77,58 +77,21 @@ $title_bg = rgba(#fff, 0.88)
 
 
   &-content
+    width: 50% // Size ratio for intermediate screens
+    max-width: 620px !important
     z-index: 10
     position: absolute
-    constrain(left, 5vw)
-    constrain(bottom, 10vw)
+    constrain(bottom, 9.2vw)
+    left: 6.4vw // Not using constrain because this shouldn't be capped on lower limits
 
-    .elementor-editor-active &, .elementor-editor-preview &
-      visibility: visible // Animation doesn't trigger in the editor for some reason so just show it
+    +above($content-max-width)
+      left: 126px // From mockup
 
     +below($breakpoint-slideshow)
       bottom: 4em
 
-  // ToDo: see how this will work for translations - maybe it's more practical to use an SVG here instead of all this?
-  // Note: for the title to have a semi-transparent background,
-  // we're limited by the font properties because the inline
-  // backgrounds can't overlap so we need to get the line-height
-  // and padding just right. Maybe it would be better if it was
-  // solid white... More details:
-  // https://iamvdo.me/en/blog/css-font-metrics-line-height-and-vertical-align
-  &-title
-    .header-slideshow & // Extra specificity needed to override generic headings
-      position: relative
-      line-height: 1.27
-      padding-right: 1.5rem // To match inline text below
-      margin-left: 0
+    +below($breakpoint-slideshow-images)
+      width: 75%
 
-      &:before
-        top: 40px
-        left: -36px
-        width: 48px
-        height: 5px
-
-      // For multi-line padded text effect
-      // Ref: https://css-tricks.com/multi-line-padded-text/
-      &-text
-        font-size: 68px fixed // Don't use REMs because we will scale this later with JS
-        box-decoration-break: clone
-        white-space: nowrap
-        display: inline
-        padding: 0 1.5rem
-        background-color: $title_bg
-
-
-  // Need to position this absolutely so it sits properly
-  // right at the bottom but without overlapping...
-  // (due to also having a semi-transparent background)
-  &-subtitle
-    background-color: $title_bg
-    position: absolute
-    top: 100%
-    left: 0
-    width: 100%
-    font-size: 23px fixed
-    letter-spacing: 0.15px
-    white-space: nowrap
-    padding: 0 1.5rem 0.5em
+    .elementor-editor-active &, .elementor-editor-preview &
+      visibility: visible // Animation doesn't trigger in the editor for some reason so just show it
index df0fab899bd414b6eca41e0b2911e5d17b6b4085..4ce101976b911bbd733b59dce426bca9e6fc3989 100644 (file)
     &:hover
       @apply text-pink
 
+    +below(900px)
+      svg
+        width: 20px
+
   &-prev
     left: 0.5rem
   &-next
index e1b8052d31d9ac11a618180b984dd6b9f9bbf28d..e2ffd23e2c1aef2980d7a5cbfaa5e8e0af71af4b 100644 (file)
@@ -1,5 +1,5 @@
-<article @php(post_class('container px-2v pb-2v flex items-start'))>
-  <header class="post-featured-image" style="background-image: url({{ get_the_post_thumbnail_url() }})">
+<article @php(post_class('container px-2v pb-2v flex items-start sm:flex-wrap'))>
+  <header class="post-featured-image flex-shrink-0" style="background-image: url({{ get_the_post_thumbnail_url() }})">
     <div class="post-featured-image-sizer">{{-- Just here as a proportional sizer thanks to the padding --}}</div>
   </header>
 
     </h1>
 
     @php(the_content())
+
+    <p class="mt-6">
+      <a class="uppercase text-pink inline-flex items-center" href="<?= get_post_type_archive_link('post') ?>">
+        @svg('arrow', 'h-3 mr-2 fill-current')
+        <?= __('Retour aux actualités') ?>
+      </a>
+    </p>
   </div>
 
   {{--
index bc12184672f759b367dc1c34cb2f89355cff72f6..ce62e9fcca9649b72b03e33965245e7117613845 100644 (file)
       @php(the_excerpt())
     </div>
 
-    <p class="mt-6">
-      <a class="uppercase text-pink inline-flex items-center" href="{{ get_permalink() }}">@svg('arrow', 'h-3 mr-2 fill-current') Lire la suite</a>
+    <p class="mt-6 mb-1v">
+      <a class="uppercase text-pink inline-flex items-center" href="{{ get_permalink() }}">
+        @svg('arrow', 'h-3 mr-2 fill-current')
+        <?= __('Lire la suite') ?>
+      </a>
     </p>
 
   </header>
index 5607fb2c32c439c300d78d79e5fa91a375e6303e..11f1ca077640c3e8ad2f51e937e4c77b64cfa104 100644 (file)
@@ -10,7 +10,7 @@ module.exports = {
       // the sm: prefix in Tailwind. Maybe there's a better name for this breakpoint but for now it's 'sm'.
       // Sizes should be listed largest to smallest so they are generated in this order, allowing smaller
       // breakpoints to take precedence over larger ones (eg. xs:p-1 should override sm:p-2)
-      //'md': {'max': '1023px'}, // => @media (max-width: 1023px) { ... }
+      'md': {'max': '1023px'}, // => @media (max-width: 1023px) { ... }
       'sm': {'max': '767px'}, // => @media (max-width: 767px) { ... }
       'xs': {'max': '499px'}, // => @media (max-width: 499px) { ... }
     },
index c7f649ce6530812219d2ec1506587a75399fb6bf..a47bcf6d9276f4561f436083fe90981a71bd9aab 100644 (file)
@@ -72,6 +72,10 @@ mix.purgeCss({
   ],
   defaultExtractor: content => content.match(/[A-Za-z0-9-_:/]+/g) || [],
 
+  globs: [
+    path.join(__dirname, '../../mu-plugins/cube/**/*.php'), // Some classes (eg. for widgets) might be present only here
+  ],
+
   /*
    | Add classes, IDs, or selectors that which do not exist in your views or
    | scripts. By default, We have whitelisted classes generated by WordPress.
@@ -81,5 +85,6 @@ mix.purgeCss({
   ],
   whitelistPatterns: [
     ...whitelistPatterns,
+    /mm.*/, // MMenu
   ],
 });