$elementor->widgets_manager->register_widget_type( new Widgets\LinkCarousel() );
$elementor->widgets_manager->register_widget_type( new Widgets\PictoGrid() );
$elementor->widgets_manager->register_widget_type( new Widgets\PeopleGrid() );
+ $elementor->widgets_manager->register_widget_type( new Widgets\Timeline() );
}
protected function _customise_sections() {
// Add controls to section element in editor
add_action( 'elementor/element/section/section_layout/after_section_start', function( $element, $args ) {
+
/** @var \Elementor\Element_Base $element */
$element->add_control(
- 'block_layout',
+ 'layout_reversed',
[
- 'label' => __('Custom Layout', 'cube'),
- 'type' => Controls_Manager::SELECT,
- 'options' => [
- 'layout-default' => __( 'Default', 'cube' ),
- 'layout-overlap-above' => __( 'Overlap Above', 'cube' ),
- 'layout-overlap-below' => __( 'Overlap Below', 'cube' ),
- ],
- 'default' => 'layout-default',
- 'prefix_class' => '', // Use the full value as the classname (too late to change values after many pages have been built)
+ 'label' => __('Colonnes inversées', 'cube'),
+ 'type' => Controls_Manager::SWITCHER,
+ 'default' => '',
+ 'return_value' => 'layout-reversed',
+ 'prefix_class' => '',
]
);
$element->add_control(
- 'layout_reversed',
+ 'bg_color',
[
- 'label' => __('Reverse layout?', 'cube'),
- 'type' => Controls_Manager::SWITCHER,
+ 'label' => __('Couleur de fond', 'cube'),
+ 'type' => Controls_Manager::SELECT,
+ 'options' => [
+ '' => __( 'Défaut (blanc)', 'cube' ),
+ 'bg-light' => __( 'Gris clair', 'cube' ),
+ 'bg-purple-dark text-white' => __( 'Violet foncé', 'cube' ),
+ ],
'default' => '',
- 'return_value' => 'layout-reversed',
- 'prefix_class' => '',
+ 'prefix_class' => '', // Use the full value as the classname
]
);
$element->add_control(
'padding_top',
[
- 'label' => __('Disable padding top', 'cube'),
- 'type' => Controls_Manager::SWITCHER,
+ 'label' => __('Top Padding', 'cube'),
+ 'type' => Controls_Manager::SELECT,
+ 'options' => [
+ '' => __( 'Défaut', 'cube' ),
+ 'pt-0' => '0',
+ 'pt-1v' => '2.5%',
+ 'pt-2v' => '5%',
+ 'pt-3v' => '7.5%',
+ 'pt-4v' => '10%',
+ ],
'default' => '',
- 'return_value' => 'pt0',
- 'prefix_class' => '',
+ 'prefix_class' => '', // Use the full value as the classname
]
);
$element->add_control(
'padding_bottom',
[
- 'label' => __('Disable padding bottom', 'cube'),
- 'type' => Controls_Manager::SWITCHER,
+ 'label' => __('Bottom Padding', 'cube'),
+ 'type' => Controls_Manager::SELECT,
+ 'options' => [
+ '' => __( 'Défaut', 'cube' ),
+ 'pb-0' => '0',
+ 'pb-1v' => '2.5%',
+ 'pb-2v' => '5%',
+ 'pb-3v' => '7.5%',
+ 'pb-4v' => '10%',
+ ],
'default' => '',
- 'return_value' => 'pb0',
- 'prefix_class' => '',
+ 'prefix_class' => '', // Use the full value as the classname
]
);
+
+ /*
$element->add_control(
'stacking_margins',
[
'prefix_class' => '',
]
);
+ */
}, 10, 2 );
--- /dev/null
+<?php
+
+namespace Cube\Elementor\Widgets;
+
+use Elementor\Controls_Manager;
+
+use function Roots\view;
+
+
+class Timeline extends _Base {
+
+ // Widget name / ID
+ public function get_name() {
+ return 'cube-timeline';
+ }
+
+ // Elementor widget title
+ public function get_title() {
+ return __('Timeline', 'cube');
+ }
+
+ // Elementor interface icon
+ public function get_icon() {
+ return 'eicon-date';
+ }
+
+ /**
+ * 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' => __('Content', 'cube'),
+ ]
+ );
+
+ $this->add_control(
+ 'items',
+ [
+ 'label' => __('Items', 'cube'),
+ 'type' => Controls_Manager::REPEATER,
+ 'fields' => [
+ [
+ 'name' => 'highlight',
+ 'label' => __('Highlight', 'cube'),
+ 'type' => Controls_Manager::SWITCHER,
+ 'return_value' => 'yes',
+ 'default' => 'no',
+ ],
+ [
+ 'name' => 'year',
+ 'label' => __('Year', 'cube'),
+ 'type' => Controls_Manager::TEXT,
+ 'label_block' => true,
+ 'default' => '',
+ ],
+ [
+ 'name' => 'details',
+ 'label' => __('Description', 'cube'),
+ 'type' => Controls_Manager::WYSIWYG,
+ 'default' => '',
+ ],
+
+ ],
+ 'title_field' => '{{{ year }}}',
+ ]
+ );
+
+ $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 view('widgets/timeline', compact('items'));
+ }
+
+
+}
]
);
+ $this->add_control(
+ 'padding_top',
+ [
+ 'label' => __('Top Padding', 'cube'),
+ 'type' => Controls_Manager::SELECT,
+ 'options' => [
+ '' => __( 'Défaut', 'cube' ),
+ 'pt-0' => '0',
+ 'pt-1v' => '2.5%',
+ 'pt-2v' => '5%',
+ 'pt-3v' => '7.5%',
+ 'pt-4v' => '10%',
+ ],
+ 'default' => '',
+ 'prefix_class' => '', // Use the full value as the classname
+ 'separator' => 'before',
+ ]
+ );
+
+ $this->add_control(
+ 'padding_bottom',
+ [
+ 'label' => __('Bottom Padding', 'cube'),
+ 'type' => Controls_Manager::SELECT,
+ 'options' => [
+ '' => __( 'Défaut', 'cube' ),
+ 'pb-0' => '0',
+ 'pb-1v' => '2.5%',
+ 'pb-2v' => '5%',
+ 'pb-3v' => '7.5%',
+ 'pb-4v' => '10%',
+ ],
+ 'default' => '',
+ 'prefix_class' => '', // Use the full value as the classname
+ ]
+ );
+
$this->end_controls_section();
}
--- /dev/null
+// Elementor Image Box Widget overrides
+.elementor-widget-image-box .elementor-image-box
+
+ &-wrapper
+ @apply text-left
+
+ &-img img
+ +below(768px)
+ @apply mx-auto
+
+ &-title
+ @apply font-body text-lg mb-6
--- /dev/null
+.timeline
+ &-item
+ @apply flex items-center
+
+ &:not(:last-child)
+ @apply mb-6
+
+ &-date
+ @apply bg-teal text-white text-lg rounded-full
+ @apply flex flex-shrink-0 items-center justify-center mb-4 mr-16
+ width: 5em
+ height: @width
+ overflow: hidden
+ box-shadow: inset 0 0 0 0.45em rgba(#fff, 0.6)
+
+ &.is-highlight
+ @apply bg-pink
+
+
+ // Todo: implement dotted lines like we did for cubedesigners.com/news
--- /dev/null
+{{-- TIMELINE --}}
+<div class="timeline">
+ @foreach ($items as $item)
+ <div class="timeline-item">
+ <div class="timeline-item-date @if($item['highlight'] == 'yes')is-highlight @endif">{{ $item['year'] }}</div>
+ <div class="timeline-item-content">{!! $item['details'] !!}</div>
+ </div>
+ @endforeach
+</div>