]> _ Git - ccv-wordpress.git/commitdiff
WIP #3053 @7
authorStephen Cameron <stephen@cubedesigners.com>
Wed, 2 Oct 2019 17:37:01 +0000 (19:37 +0200)
committerStephen Cameron <stephen@cubedesigners.com>
Wed, 2 Oct 2019 17:37:01 +0000 (19:37 +0200)
13 files changed:
wp-content/mu-plugins/cube/src/Elementor/Setup.php
wp-content/mu-plugins/cube/src/Elementor/Widgets/HeaderSlideshow.php [new file with mode: 0644]
wp-content/mu-plugins/cube/src/Elementor/Widgets/TextBlock.php
wp-content/themes/CCV/resources/assets/styles/app.styl
wp-content/themes/CCV/resources/assets/styles/common/animations.styl [new file with mode: 0644]
wp-content/themes/CCV/resources/assets/styles/common/global.styl
wp-content/themes/CCV/resources/assets/styles/common/setup.styl
wp-content/themes/CCV/resources/assets/styles/components/headings.styl
wp-content/themes/CCV/resources/assets/styles/components/navigation.styl
wp-content/themes/CCV/resources/assets/styles/components/sections.styl
wp-content/themes/CCV/resources/assets/styles/widgets/text-block.styl
wp-content/themes/CCV/resources/views/partials/footer.blade.php
wp-content/themes/CCV/tailwind.config.js

index b2168f0a641a29555026376d0483273623e0758b..0243899c31ab2b4449c1ca9224db6e6f1e5b1369 100644 (file)
@@ -32,6 +32,7 @@ class Setup {
 
         $elementor->widgets_manager->register_widget_type( new Widgets\BackgroundImage() );
         $elementor->widgets_manager->register_widget_type( new Widgets\TextBlock() );
+        $elementor->widgets_manager->register_widget_type( new Widgets\HeaderSlideshow() );
     }
 
     protected function _customise_sections() {
diff --git a/wp-content/mu-plugins/cube/src/Elementor/Widgets/HeaderSlideshow.php b/wp-content/mu-plugins/cube/src/Elementor/Widgets/HeaderSlideshow.php
new file mode 100644 (file)
index 0000000..99a810f
--- /dev/null
@@ -0,0 +1,149 @@
+<?php
+
+namespace Cube\Elementor\Widgets;
+
+use Elementor\Widget_Base;
+use Elementor\Controls_Manager;
+
+
+class HeaderSlideshow extends Widget_Base {
+
+    protected $_has_template_content = false; // Tell Elementor that content is all rendered dynamically
+
+    // Widget name / ID
+    public function get_name() {
+        return 'cube-header-slideshow';
+    }
+
+    // Elementor widget title
+    public function get_title() {
+        return __( 'Header Slideshow', 'cube' );
+    }
+
+    // Elementor interface icon
+    public function get_icon() {
+        return 'eicon-slideshow';
+    }
+
+    // Where to display the widget in the Elementor interface
+    public function get_categories() {
+        return [ 'theme-elements' ];
+    }
+
+    /**
+     * List of scripts the widget depends on.
+     * Used to set scripts dependencies required to run the widget.
+     *
+     * @since 1.0.0
+     * @access public
+     * @return array Widget scripts dependencies.
+     */
+    public function get_script_depends() {
+        return [];
+    }
+    /**
+     * Register the widget controls.
+     * Adds different input fields to allow the user to change and customize the widget settings.
+     *
+     * @since 1.0.0
+     * @access protected
+     */
+    protected function _register_controls() {
+
+        $this->start_controls_section(
+            'section_content',
+            [
+                'label' => __( 'Header Slideshow', 'cube' ),
+            ]
+        );
+
+        $this->add_control(
+            'images',
+            [
+                'label' => __( 'Add Images', 'elementor' ),
+                'type' => Controls_Manager::GALLERY,
+                'default' => [],
+                'show_label' => false,
+                'dynamic' => [
+                    'active' => true,
+                ],
+            ]
+        );
+
+        $this->add_control(
+            'title',
+            [
+                'label' => __( 'Title', 'elementor' ),
+                'type' => Controls_Manager::TEXTAREA,
+                'placeholder' => __( 'Enter your title', 'elementor' ),
+                'default' => '',
+            ]
+        );
+
+        $this->add_control(
+            'subtitle',
+            [
+                'label' => __( 'Subtitle', 'cube' ),
+                'type' => Controls_Manager::TEXTAREA,
+                'placeholder' => __( 'Enter your subtitle', 'cube' ),
+                'default' => '',
+            ]
+        );
+
+        
+        $this->end_controls_section();
+    }
+    /**
+     * Render the widget output on the frontend.
+     * Written in PHP and used to generate the final HTML.
+     *
+     * @since 1.0.0
+     * @access protected
+     */
+    protected function render() {
+
+        $id = 'header_slideshow_' . $this->get_id();
+        $title = $this->get_settings('title');
+        $subtitle = $this->get_settings('subtitle');
+        $images = $this->get_settings('images');
+
+        // When this element is present, add a class to the body so the header can be styled differently (transparent background)
+        add_filter('body_class', function($classes) {
+            $classes[] = 'header-slideshow-present';
+            return $classes;
+        });
+
+
+        ?>
+
+        <div class="header-slideshow elementor" id="<?= $id ?>">
+
+            <?php
+            /*
+            Here we're hijacking Elementor's built in entrance animations for the title text.
+            The class "elementor-element" must be present for it to be attached to the waypoints.
+            The other classes are also necessary for making the animation work...
+            After recent updates, the parent must also have the class "elementor" for animations to work.
+            */
+            ?>
+            <div class="header-slideshow-content">
+
+                <div class="header-slideshow-content-inner elementor-element elementor-invisible" data-settings='{"animation":"fadeInUp","animation_delay":0}' data-element_type="section">
+                    <h1 class="header-slideshow-title"><?= $title ?></h1>
+                    <h2 class="header-slideshow-subtitle"><?= $subtitle ?></h2>
+                </div>
+
+                <!-- Todo: handle images and simple carousel. See Elementor image-carousel.php -->
+
+            </div>
+
+
+            <div class="header-slideshow-background-container">
+                <div class="header-slideshow-background"></div>
+            </div>
+
+        </div>
+
+        <?php
+    }
+}
index 204adf470fdc7871d87a2375f9576e586677dc95..bf4cebdce657c9826916996db336fc3e7f442f60 100644 (file)
@@ -20,7 +20,7 @@ class TextBlock extends Widget_Base {
 
     // Elementor interface icon
     public function get_icon() {
-        return 'eicon-align-left';
+        return 'eicon-post-title';
     }
 
     // Where to display the widget in the Elementor interface
index 8dc55226095a41ccaad17189c9eeb5c001124bf5..49781f723a42455055cfcdceadb962fe092e3cdf 100644 (file)
@@ -9,6 +9,7 @@
 @import 'common/global'
 @import 'common/layout'
 @import 'common/spacing'
+@import 'common/animations'
 
 // Extracted components or custom styles that can't be done with utilities
 @import 'components/*'
diff --git a/wp-content/themes/CCV/resources/assets/styles/common/animations.styl b/wp-content/themes/CCV/resources/assets/styles/common/animations.styl
new file mode 100644 (file)
index 0000000..eb06186
--- /dev/null
@@ -0,0 +1,6 @@
+// Submenu fade in effect
+@keyframes fade-in
+  from
+    opacity: 0
+  to
+    opacity: 1
index 5afabd1225de2675b56f31697c93795aac1bacd7..402c8740ba6ee2730d606254ca00b36e71bf60d8 100644 (file)
@@ -1,6 +1,15 @@
 html
   font-size: $font-size-base // Base used for REM calculations
 
+  +below(1500px)
+    font-size: 20px
+  +below(1200px)
+    font-size: 18px
+  +below(1000px)
+    font-size: 17px
+  +below(700px)
+    font-size: 16px
+
 body
   min-width: 320px
   background-color: #FBFBFB
index ba297bd35da197b0058bb58bbb0ce2f3ffac189f..71a78bb2f24125bb8e9480c7a5cca36a56f99c08 100644 (file)
@@ -14,7 +14,7 @@ $vertical-gutter   = 7.5vw
 
 // Breakpoints in Rupture (https://github.com/jescalan/rupture)
 $breakpoint-columns  = 768px // NOTE: this should align with the 'sm' screen value in tailwind.config.js
-$breakpoint-menu     = 1600px // This needs to match the MMenu activation setting in menu.js
+$breakpoint-menu     = 1350px // This needs to match the MMenu activation setting in menu.js
 rupture.scale        = 0 400px  768px   1024px
 rupture.scale-names  = 'small' 'medium' 'large'
 rupture.anti-overlap = -1px // Results in +below(1000px) being max-width: 999px and +above(1000px) being min-width: 1000px
index 8a21a2054c310e01ed95cd3d0beec4b4610b7c66..3400b285fac0a31e446844602f75ac5b0038195a 100644 (file)
@@ -12,6 +12,9 @@ h2, .h2
 h1, .h1, h2, .h2, .decorated
   @apply relative
 
+  +below($breakpoint-columns)
+    margin-left: 0.9em
+
   &:before
     content: ''
     display: block
@@ -22,10 +25,18 @@ h1, .h1, h2, .h2, .decorated
     height: 5px
     background: theme('colors.pink')
 
+    +below(1150px)
+      width: 0.9em
+      left: -1.3em
+      height: 4px
+
+    +below($breakpoint-columns)
+      height: 3px
+
 
 h3, .h3, h4, .h4
   @apply font-medium
-  line-height: 1.4
+  line-height: 1.3
 
 h3, .h3
   @apply font-display text-xl
index b2800dbe81ea1153bdc0b4d3e795a254c5728ff7..e96c63384ade752129fad47ed40d81bac0f14cbe 100644 (file)
@@ -1,10 +1,13 @@
 .nav-primary
 
+  +below($breakpoint-menu)
+    display: none
+
   .menu-list
     @apply flex
 
   .menu-item
-    @apply block mx-5
+    @apply block mx-5 relative
     @apply border-b-2 border-transparent // Reserve space for active border
     @apply py-1 leading-tight // Adjust active border spacing
 
     &:last-child
       @apply mr-0 // So menu sits flush with edge of content area
 
+    // Sub menu display
+    &:hover
+      .sub-menu
+        display: block
+        animation: fade-in 0.3s
+
     a
       @apply whitespace-no-wrap
       transition: color 0.3s
       &:hover
         @apply text-pink
 
+
+  // Sub-menu
+  .sub-menu
+    @apply hidden absolute
+    @apply bg-pink
+    left: 0
+    top: 100%
+    white-space: normal
+    z-index: 50
+    text-align: left
+    text-transform: none
+    font-weight: normal
+    transition: opacity 0.3s
+
+    .menu-item
+      white-space: nowrap
+      display: block
+      width: 100%
+      padding: 0
+      margin: 0
+      border-bottom: none
+
+    a
+      @apply text-white
+      @apply block py-2 px-4 m-0
+
+      &:hover
+        @apply text-white
+        background-color: rgba(#fff, 0.2)
+
+
index 6aaf431c38f89da1a1f3fde840cf2b6b80f28cf7..6ae591c12749095c7a536a4ec0b4c3391052d468 100644 (file)
@@ -20,8 +20,8 @@
       //horizontal-spacing(5vw)
       //box-sizing: content-box // So padding doesn't influence max-width
 
-      +below(450px)
-        horizontal-spacing(2.5vw)
+      //+below(450px)
+      //  horizontal-spacing(2.5vw)
 
 //--- Reversed layout
 // Handle column swapping when layout reversed toggle is set
index af1034161437d957918a8225d461c8aed719ee4b..a0f5a70164e14c840649bbeda439270bd7d3e39e 100644 (file)
@@ -3,12 +3,11 @@
   vertical-spacing(7.5vw)
   constrain(padding-left, 10vw)
   constrain(padding-right, 7.5vw)
-  max-width: 640px
   width: 100%
   box-sizing: content-box // So padding doesn't influence max-width
 
-  +below(450px)
-    horizontal-spacing(2.5vw)
+  +below(500px)
+    horizontal-spacing(5vw)
 
 .text-block
 
@@ -16,7 +15,7 @@
     @apply text-2xl antialiased
     white-space: pre-line
 
-    +below(1600px)
+    +below(1150px)
       white-space: normal // Avoid strange gaps caused by pre-line breaks wrapping
       font-size: 4.25vw // Using vw units so headings scale instead of wrapping further
     +below(795px) // Cap font size to medium once the vw size matches medium size
index 9fdff8ec931c34301ea0aec0d14fd816cbf16242..9f34debc64a0dcbbe8872f1e0eefd8eea52bde8c 100644 (file)
@@ -1,16 +1,16 @@
 <footer class="bg-purple-dark text-white antialiased pt-2v pb-1v">
   <div class="container">
-    <div class="flex pb-2v">
-      <div class="w-1/2 px-4v">
+    <div class="flex pb-2v sm:flex-col-reverse">
+      <div class="w-1/2 pl-4v sm:pl-2v sm:w-full sm:pt-8">
         @php(dynamic_sidebar('sidebar-footer-1'))
       </div>
-      <div class="w-1/2 px-4v">
+      <div class="w-1/2 pl-4v sm:pl-2v pr-2v sm:w-full">
       @php(dynamic_sidebar('sidebar-footer-2'))
       </div>
     </div>
 
     {{-- Copyright message and links --}}
-    <div class="pl-4v text-sm opacity-50">
+    <div class="pl-4v sm:pl-2v pr-2v text-sm opacity-50">
       @php(dynamic_sidebar('sidebar-footer-copyright'))
     </div>
   </div>
index 099a81df10e7dc77c3f6f42b10e1db957cf9368a..09253345d976f2d2015037b70f179d38eae1047d 100644 (file)
@@ -3,8 +3,20 @@ const { wordpressUtilities } = require('tailwindcss-wordpress');
 
 module.exports = {
   theme: {
+    screens: {
+      // We're using the desktop-first approach to media queries so everything is max-width based
+      // The most important breakpoint is when the columns stack. This is defined in setup.styl
+      // and for now it needs to be manually matched here. The idea is that we can set styles using
+      // 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) { ... }
+      'sm': {'max': '767px'}, // => @media (max-width: 767px) { ... }
+      'xs': {'max': '499px'}, // => @media (max-width: 499px) { ... }
+    },
     extend: {
       colors: {
+        'inherit': 'inherit',
         'dark': '#1A0707', // Text colour
         'light': '#F6F5F5', // Light grey backgrounds
         'purple-dark': '#2E2C40', // Footer and other dark sections