| 1 |
<?php |
| 2 |
namespace Elementor\Modules\AtomicWidgets\Elements\Atomic_Tabs; |
| 3 |
|
| 4 |
use Elementor\Modules\AtomicWidgets\Elements\Atomic_Element_Base; |
| 5 |
use Elementor\Modules\AtomicWidgets\PropTypes\Primitives\String_Prop_Type; |
| 6 |
use Elementor\Modules\AtomicWidgets\PropTypes\Size_Prop_Type; |
| 7 |
use Elementor\Modules\AtomicWidgets\Styles\Style_Definition; |
| 8 |
use Elementor\Modules\AtomicWidgets\Styles\Style_Variant; |
| 9 |
use Elementor\Modules\AtomicWidgets\Controls\Section; |
| 10 |
use Elementor\Modules\AtomicWidgets\Controls\Types\Text_Control; |
| 11 |
use Elementor\Modules\AtomicWidgets\PropTypes\Classes_Prop_Type; |
| 12 |
|
| 13 |
if ( ! defined( 'ABSPATH' ) ) { |
| 14 |
exit; // Exit if accessed directly. |
| 15 |
} |
| 16 |
|
| 17 |
class Atomic_Tab_List extends Atomic_Element_Base { |
| 18 |
const BASE_STYLE_KEY = 'base'; |
| 19 |
|
| 20 |
public static function get_type() { |
| 21 |
return 'e-tab-list'; |
| 22 |
} |
| 23 |
|
| 24 |
public static function get_element_type(): string { |
| 25 |
return 'e-tab-list'; |
| 26 |
} |
| 27 |
|
| 28 |
public function get_title() { |
| 29 |
return esc_html__( 'Atomic Tab List', 'elementor' ); |
| 30 |
} |
| 31 |
|
| 32 |
public function get_keywords() { |
| 33 |
return [ 'ato', 'atom', 'atoms', 'atomic' ]; |
| 34 |
} |
| 35 |
|
| 36 |
public function get_icon() { |
| 37 |
return 'eicon-tabs'; |
| 38 |
} |
| 39 |
|
| 40 |
public function should_show_in_panel() { |
| 41 |
return false; |
| 42 |
} |
| 43 |
|
| 44 |
protected static function define_props_schema(): array { |
| 45 |
return [ |
| 46 |
'classes' => Classes_Prop_Type::make() |
| 47 |
->default( [] ), |
| 48 |
]; |
| 49 |
} |
| 50 |
|
| 51 |
protected function define_atomic_controls(): array { |
| 52 |
return [ |
| 53 |
Section::make() |
| 54 |
->set_label( __( 'Settings', 'elementor' ) ) |
| 55 |
->set_id( 'settings' ) |
| 56 |
->set_items( [ |
| 57 |
Text_Control::bind_to( '_cssid' ) |
| 58 |
->set_label( __( 'ID', 'elementor' ) ) |
| 59 |
->set_meta( $this->get_css_id_control_meta() ), |
| 60 |
] ), |
| 61 |
]; |
| 62 |
} |
| 63 |
|
| 64 |
protected function define_base_styles(): array { |
| 65 |
$display = String_Prop_Type::generate( 'flex' ); |
| 66 |
$gap = Size_Prop_Type::generate( [ |
| 67 |
'size' => 10, |
| 68 |
'unit' => 'px', |
| 69 |
] ); |
| 70 |
$justify_content = String_Prop_Type::generate( 'space-between' ); |
| 71 |
$min_width = Size_Prop_Type::generate( [ |
| 72 |
'size' => 30, |
| 73 |
'unit' => 'px', |
| 74 |
] ); |
| 75 |
|
| 76 |
return [ |
| 77 |
static::BASE_STYLE_KEY => Style_Definition::make() |
| 78 |
->add_variant( |
| 79 |
Style_Variant::make() |
| 80 |
->add_prop( 'display', $display ) |
| 81 |
->add_prop( 'min-width', $min_width ) |
| 82 |
->add_prop( 'gap', $gap ) |
| 83 |
->add_prop( 'justify-content', $justify_content ) |
| 84 |
), |
| 85 |
]; |
| 86 |
} |
| 87 |
|
| 88 |
protected function add_render_attributes() { |
| 89 |
parent::add_render_attributes(); |
| 90 |
$settings = $this->get_atomic_settings(); |
| 91 |
$base_style_class = $this->get_base_styles_dictionary()[ static::BASE_STYLE_KEY ]; |
| 92 |
|
| 93 |
$attributes = [ |
| 94 |
'class' => [ |
| 95 |
'e-con', |
| 96 |
'e-atomic-element', |
| 97 |
$base_style_class, |
| 98 |
...( $settings['classes'] ?? [] ), |
| 99 |
], |
| 100 |
]; |
| 101 |
|
| 102 |
if ( ! empty( $settings['_cssid'] ) ) { |
| 103 |
$attributes['id'] = esc_attr( $settings['_cssid'] ); |
| 104 |
} |
| 105 |
|
| 106 |
$this->add_render_attribute( '_wrapper', $attributes ); |
| 107 |
} |
| 108 |
} |
| 109 |
|