]> _ Git - physioassist-wordpress.git/commitdiff
WIP #3470 @6.75
authorstephen@cubedesigners.com <stephen@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 16 Mar 2020 18:59:11 +0000 (18:59 +0000)
committerstephen@cubedesigners.com <stephen@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 16 Mar 2020 18:59:11 +0000 (18:59 +0000)
wp-content/mu-plugins/physioassist/src/Elementor/Setup.php
wp-content/mu-plugins/physioassist/src/Elementor/Widgets/BackgroundImage.php
wp-content/mu-plugins/physioassist/src/Elementor/Widgets/TextBlock.php
wp-content/mu-plugins/physioassist/src/Elementor/Widgets/TextCarousel.php [new file with mode: 0644]
wp-content/themes/physioassist/resources/assets/config.json
wp-content/themes/physioassist/resources/assets/scripts/text-carousel.js [new file with mode: 0644]
wp-content/themes/physioassist/resources/assets/styles/widgets/text-carousel.styl [new file with mode: 0644]
wp-content/themes/physioassist/resources/views/widgets/text-carousel.blade.php [new file with mode: 0644]

index aee222748de92b0de56cec8e6ae8eced7b3033b0..6f87969a92772f907c1bef73955743368acb842d 100644 (file)
@@ -70,6 +70,7 @@ class Setup {
         $elementor->widgets_manager->register_widget_type( new Widgets\ProfileGrid() );
         $elementor->widgets_manager->register_widget_type( new Widgets\ResourceGrid() );
         $elementor->widgets_manager->register_widget_type( new Widgets\VideoGallery() );
+        $elementor->widgets_manager->register_widget_type( new Widgets\TextCarousel() );
         $elementor->widgets_manager->register_widget_type( new Widgets\BackgroundImage() );
     }
 
index ef11111887cd55e12f059e2754bae649bce58fc0..e0d18e5404cece52bc535edb10a6a535ed846b0d 100644 (file)
@@ -23,7 +23,7 @@ class BackgroundImage extends Widget_Base {
 
     // Elementor interface icon
     public function get_icon() {
-        return 'eicon-insert-image';
+        return 'eicon-image';
     }
 
     // Where to display the widget in the Elementor interface
index 9c50084f02db9e837850afa77c957c761c4ebf40..f904c05bc828ce2d4ce5be4816618a68ede8d2a5 100644 (file)
@@ -23,7 +23,7 @@ class TextBlock extends Widget_Base {
 
     // Elementor interface icon
     public function get_icon() {
-        return 'eicon-align-left';
+        return 'eicon-columns';
     }
 
     // Where to display the widget in the Elementor interface
diff --git a/wp-content/mu-plugins/physioassist/src/Elementor/Widgets/TextCarousel.php b/wp-content/mu-plugins/physioassist/src/Elementor/Widgets/TextCarousel.php
new file mode 100644 (file)
index 0000000..4f25c39
--- /dev/null
@@ -0,0 +1,250 @@
+<?php
+
+namespace PhysioAssist\Elementor\Widgets;
+
+use Elementor\Widget_Base;
+use Elementor\Controls_Manager;
+use Elementor\Scheme_Color;
+
+
+class TextCarousel 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-text-carousel';
+    }
+
+    // Elementor widget title
+    public function get_title() {
+        return __( 'Text Carousel', 'cube' );
+    }
+
+    // Elementor interface icon
+    public function get_icon() {
+        return 'eicon-posts-carousel';
+    }
+
+    // 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() {
+
+        wp_register_script(
+            'cube-text-carousel',
+            \App\asset_path('scripts/text-carousel.js'),
+            ['jquery'], // Dependencies
+            null, // Version
+            true // In footer?
+        );
+
+        return ['cube-text-carousel'];
+    }
+    /**
+     * 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' => __( 'Content', 'cube' ),
+            ]
+        );
+
+        $this->add_control(
+            'items',
+            [
+                'label' => __( 'Items', 'cube' ),
+                'type' => Controls_Manager::REPEATER,
+                'fields' => [
+                    [
+                        'name' => 'title',
+                        'label' => __( 'Title', 'elementor' ),
+                        'type' => Controls_Manager::TEXTAREA,
+                        'placeholder' => __( 'Enter your title', 'elementor' ),
+                        'default' => '',
+                    ],
+                    [
+                        'name' => 'subtitle',
+                        'label' => __( 'Subtitle', 'cube' ),
+                        'type' => Controls_Manager::TEXT,
+                        'label_block' => true,
+                    ],
+                    [
+                        'name' => 'body',
+                        'label' => __('Body', 'cube'),
+                        'type' => Controls_Manager::WYSIWYG,
+                        'default' => '',
+                    ],
+                    [
+                        'name' => 'cta_text',
+                        'label' => __('Call to Action text', 'cube'),
+                        'type' => Controls_Manager::TEXT,
+                        'default' => ''
+                    ],
+                    [
+                        'name' => 'cta_link',
+                        'label' => __('Call to Action link', 'cube'),
+                        'type' => Controls_Manager::URL,
+                        'default' => [
+                            'url' => '',
+                            'is_external' => false,
+                        ],
+                        'show_external' => true
+                    ],
+                ],
+                'title_field' => '{{{ title }}}',
+            ]
+        );
+       
+        $this->end_controls_section();
+
+
+        $this->start_controls_section(
+            'section_formatting',
+            [
+                'label' => __( 'Colours & Formatting', 'cube' ),
+            ]
+        );
+
+
+        $this->add_control(
+            'title_color',
+            [
+                'label' => __( 'Title Colour', 'cube' ),
+                'type' => Controls_Manager::COLOR,
+                'default' => '',
+                'selectors' => [
+                    '{{WRAPPER}} .text-block-title' => 'color: {{VALUE}};',
+                ],
+            ]
+        );
+
+
+        $this->add_control(
+                       'subtitle_color',
+                       [
+                               'label' => __( 'Subtitle Colour', 'cube' ),
+                               'type' => Controls_Manager::COLOR,
+                               'default' => '',
+                               'selectors' => [
+                                       '{{WRAPPER}} .text-block-subtitle' => 'color: {{VALUE}};',
+                               ],
+                       ]
+               );
+
+
+        $this->add_control(
+                       'body_color',
+                       [
+                               'label' => __( 'Body Colour', 'cube' ),
+                               'type' => Controls_Manager::COLOR,
+                               'default' => '',
+                               'selectors' => [
+                                       '{{WRAPPER}} .text-block-body' => 'color: {{VALUE}};',
+                               ],
+                       ]
+        );
+
+
+        $this->add_control(
+                       'cta_color',
+                       [
+                               'label' => __( 'Call to Action Colour', 'cube' ),
+                               'type' => Controls_Manager::COLOR,
+                               'default' => '',
+                               'selectors' => [
+                                       '{{WRAPPER}} .text-block-cta' => 'color: {{VALUE}};',
+                               ],
+                       ]
+        );
+
+
+        $this->add_responsive_control(
+                       'align',
+                       [
+                               'label' => __( 'Alignment', 'elementor' ),
+                               'type' => Controls_Manager::CHOOSE,
+                               'options' => [
+                                       'left' => [
+                                               'title' => __( 'Left', 'elementor' ),
+                                               'icon' => 'fa fa-align-left',
+                                       ],
+                                       'center' => [
+                                               'title' => __( 'Center', 'elementor' ),
+                                               'icon' => 'fa fa-align-center',
+                                       ],
+                                       'right' => [
+                                               'title' => __( 'Right', 'elementor' ),
+                                               'icon' => 'fa fa-align-right',
+                                       ],
+                                       'justify' => [
+                                               'title' => __( 'Justified', 'elementor' ),
+                                               'icon' => 'fa fa-align-justify',
+                                       ],
+                               ],
+                               'default' => '',
+                               'selectors' => [
+                                       '{{WRAPPER}}' => 'text-align: {{VALUE}}; margin: 0 auto;',
+                               ],
+                       ]
+        );
+        
+        $this->add_control(
+                       'max-width',
+                       [
+                               'label' => __( 'Maximum Width', 'cube' ),
+                               'type' => Controls_Manager::SLIDER,
+                               // 'default' => [
+                               //      'size' => 400,
+                               // ],
+                               'range' => [
+                                       'px' => [
+                                               'min' => 400,
+                        'max' => 1600,
+                        'step' => 10,
+                                       ],
+                                       '%' => [
+                                               'min' => 0,
+                                               'max' => 100,
+                                       ],
+                               ],
+                               'selectors' => [
+                                       '{{WRAPPER}} .text-block' => 'max-width: {{SIZE}}{{UNIT}};',
+                               ],
+                       ]
+               );
+
+        $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() {
+
+        $items = $this->get_settings('items');
+
+        echo \App\template('widgets/text-carousel', compact('items'));
+    }
+
+}
index 807859a3be0c9294baaa82b52343ecb77ba8b920..9f14bc13ad6bbdc79c445923d36a55cf156b5b53 100644 (file)
@@ -13,6 +13,9 @@
     "text-block": [
       "./scripts/text-block.js"
     ],
+    "text-carousel": [
+      "./scripts/text-carousel.js"
+    ],
     "video-carousel": [
       "./scripts/video-carousel.js"
     ],
@@ -25,7 +28,7 @@
   },
   "publicPath": "/wp-content/themes/physioassist",
   "devUrl": "http://physioassist.test",
-  "proxyUrl": "http://paris.cubedesigners.com:63000",
+  "proxyUrl": "http://stephen.local:63000",
   "cacheBusting": "[name]_[hash:8]",
   "watch": [
     "app/**/*.php",
diff --git a/wp-content/themes/physioassist/resources/assets/scripts/text-carousel.js b/wp-content/themes/physioassist/resources/assets/scripts/text-carousel.js
new file mode 100644 (file)
index 0000000..7b6a5d0
--- /dev/null
@@ -0,0 +1,14 @@
+// ELEMENTOR Trigger
+(function($) {
+  // Trigger handler when element ready
+  $(window).on( 'elementor/frontend/init', function() {
+    // eslint-disable-next-line
+    elementorFrontend.hooks.addAction('frontend/element_ready/cube-text-carousel.default', function ($scope) {
+
+      // Only trigger if it is a carousel type gallery
+      if ($scope.hasClass('elementor-widget-cube-text-carousel')) {
+        $scope.find('.text-carousel').slick(); // Note: settings come from data-attribute in HTML
+      }
+    });
+  });
+})(jQuery);
diff --git a/wp-content/themes/physioassist/resources/assets/styles/widgets/text-carousel.styl b/wp-content/themes/physioassist/resources/assets/styles/widgets/text-carousel.styl
new file mode 100644 (file)
index 0000000..73cc669
--- /dev/null
@@ -0,0 +1,27 @@
+.text-carousel
+
+  &-item-content
+    padding: 0 1.75em
+    text-align: center
+
+  &-title
+    color: $colors.headings
+    font-size: 18px
+    font-weight: 600
+    text-transform: uppercase
+    margin-bottom: 0.8em
+    line-height: 1.2
+
+  &-subtitle
+    font-weight: 600
+    margin-bottom: 1.5em
+
+  &-link
+    position: relative
+    margin-top: 1.4em
+    padding-left: 1em
+
+    svg
+      position: absolute
+      top: 0.425em
+      left: 0
diff --git a/wp-content/themes/physioassist/resources/views/widgets/text-carousel.blade.php b/wp-content/themes/physioassist/resources/views/widgets/text-carousel.blade.php
new file mode 100644 (file)
index 0000000..2b0fa4f
--- /dev/null
@@ -0,0 +1,63 @@
+{{--TEXT CAROUSEL--}}
+@php
+  $settings = [
+    'slidesToShow' => 4,
+    'slidesToScroll' => 1,
+    'dots' => count($items) > 4, // Only show dots when there are enough items
+    'infinite' => true,
+    'responsive' => [
+      [
+        'breakpoint' => 1400,
+        'settings' => [
+          'slidesToShow' => 3
+        ]
+      ],
+      [
+        'breakpoint' => 1100,
+        'settings' => [
+          'slidesToShow' => 2
+        ]
+      ],
+      [
+        'breakpoint' => 850,
+        'settings' => [
+          'slidesToShow' => 1
+        ]
+      ],
+    ]
+  ];
+
+  $slick = json_encode($settings);
+
+@endphp
+
+<div class="text-carousel elementor-slick-slider" data-slick="{{ $slick }}">
+
+  @foreach ($items as $item)
+
+    <div class="text-carousel-item slick-slide">
+      <div class="text-carousel-item-content">
+
+          <h3 class="text-carousel-title">{{ $item['title'] }}</h3>
+
+          <p class="text-carousel-subtitle">{{ $item['subtitle'] }}</p>
+
+          <div class="text-carousel-body">
+            {!! $item['body'] !!}
+          </div>
+
+          @if (!empty($item['cta_text']))
+            <a href="{{ $item['cta_link']['url'] }}" class="text-carousel-link arrow-link"
+            @if ($item['cta_link']['is_external']) target="_blank" @endif
+            @if ($item['cta_link']['nofollow']) rel="noopener" @endif
+            >
+              @svg('arrow') {{ $item['cta_text'] }}
+            </a>
+          @endif
+
+      </div>  {{-- .text-carousel-item-content --}}
+    </div> {{-- .text-carousel-item --}}
+
+  @endforeach
+
+</div>