PluginProbe
Elementor Website Builder – more than just a page builder / 3.33.0-beta1
Elementor Website Builder – more than just a page builder v3.33.0-beta1
4.3.4 4.3.3 4.3.2 4.3.1 4.3.0 4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 All 457 releases
elementor / modules / atomic-widgets / elements / atomic-tabs / atomic-tab-panel.php

atomic-tab-panel.php in Elementor Website Builder – more than just a page builder 3.33.0-beta1, at modules/atomic-widgets/elements/atomic-tabs/atomic-tab-panel.php

136 lines 3.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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\Boolean_Prop_Type;
6 use Elementor\Modules\AtomicWidgets\PropTypes\Primitives\String_Prop_Type;
7 use Elementor\Modules\AtomicWidgets\PropTypes\Size_Prop_Type;
8 use Elementor\Modules\AtomicWidgets\Styles\Style_Definition;
9 use Elementor\Modules\AtomicWidgets\Styles\Style_Variant;
10 use Elementor\Modules\AtomicWidgets\Controls\Section;
11 use Elementor\Modules\AtomicWidgets\Controls\Types\Text_Control;
12 use Elementor\Modules\AtomicWidgets\Elements\Atomic_Paragraph\Atomic_Paragraph;
13 use Elementor\Modules\AtomicWidgets\PropTypes\Classes_Prop_Type;
14 use Elementor\Modules\AtomicWidgets\PropTypes\Attributes_Prop_Type;
15
16 if ( ! defined( 'ABSPATH' ) ) {
17 exit; // Exit if accessed directly.
18 }
19
20 class Atomic_Tab_Panel extends Atomic_Element_Base {
21 const BASE_STYLE_KEY = 'base';
22
23 public static function get_type() {
24 return 'e-tab-panel';
25 }
26
27 public static function get_element_type(): string {
28 return 'e-tab-panel';
29 }
30
31 public function get_title() {
32 return esc_html__( 'Atomic Tab Panel', 'elementor' );
33 }
34
35 public function get_keywords() {
36 return [ 'ato', 'atom', 'atoms', 'atomic', 'tab', 'panel', 'tabs' ];
37 }
38
39 public function get_icon() {
40 return 'eicon-tabs';
41 }
42
43 public function should_show_in_panel() {
44 return false;
45 }
46
47 protected static function define_props_schema(): array {
48 return [
49 'classes' => Classes_Prop_Type::make()
50 ->default( [] ),
51 'tab-id' => String_Prop_Type::make(),
52 'attributes' => Attributes_Prop_Type::make(),
53 ];
54 }
55
56 protected function define_atomic_controls(): array {
57 return [
58 Section::make()
59 ->set_label( __( 'Settings', 'elementor' ) )
60 ->set_id( 'settings' )
61 ->set_items( [] ),
62 ];
63 }
64
65 protected function define_base_styles(): array {
66 $display = String_Prop_Type::generate( 'block' );
67
68 return [
69 static::BASE_STYLE_KEY => Style_Definition::make()
70 ->add_variant(
71 Style_Variant::make()
72 ->add_prop( 'display', $display )
73 ->add_prop( 'padding', $this->get_base_padding() )
74 ->add_prop( 'min-width', $this->get_base_min_width() )
75 ),
76 ];
77 }
78
79 protected function get_base_padding(): array {
80 return Size_Prop_Type::generate( [
81 'size' => 10,
82 'unit' => 'px',
83 ] );
84 }
85
86 protected function get_base_min_width(): array {
87 return Size_Prop_Type::generate( [
88 'size' => 30,
89 'unit' => 'px',
90 ] );
91 }
92
93 protected function define_initial_attributes() {
94 return [
95 'role' => 'tabpanel',
96 ];
97 }
98
99 protected function define_default_children() {
100 return [
101 Atomic_Paragraph::generate()
102 ->settings( [
103 'text' => String_Prop_Type::generate( 'Tab Content' ),
104 ] )
105 ->build(),
106 ];
107 }
108
109 protected function add_render_attributes() {
110 parent::add_render_attributes();
111 $settings = $this->get_atomic_settings();
112 $base_style_class = $this->get_base_styles_dictionary()[ static::BASE_STYLE_KEY ];
113 $initial_attributes = $this->define_initial_attributes();
114
115 $attributes = [
116 'class' => [
117 'e-con',
118 'e-atomic-element',
119 $base_style_class,
120 ...( $settings['classes'] ?? [] ),
121 ],
122 ];
123
124 if ( ! empty( $settings['tab-id'] ) ) {
125 $attributes['data-tab-id'] = esc_attr( $settings['tab-id'] );
126 $attributes['aria-labelledby'] = esc_attr( $settings['tab-id'] );
127 }
128
129 if ( ! empty( $settings['_cssid'] ) ) {
130 $attributes['id'] = esc_attr( $settings['_cssid'] );
131 }
132
133 $this->add_render_attribute( '_wrapper', array_merge( $initial_attributes, $attributes ) );
134 }
135 }
136