PluginProbe
Elementor Website Builder – more than just a page builder / 3.34.0-beta1
Elementor Website Builder – more than just a page builder v3.34.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-content.php

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

140 lines 3.8 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\String_Prop_Type;
6 use Elementor\Modules\AtomicWidgets\PropTypes\Size_Prop_Type;
7 use Elementor\Modules\AtomicWidgets\PropTypes\Selection_Size_Prop_Type;
8 use Elementor\Modules\AtomicWidgets\PropTypes\Transition_Prop_Type;
9 use Elementor\Modules\AtomicWidgets\PropTypes\Key_Value_Prop_Type;
10 use Elementor\Modules\AtomicWidgets\Styles\Style_Definition;
11 use Elementor\Modules\AtomicWidgets\Styles\Style_Variant;
12 use Elementor\Modules\AtomicWidgets\Styles\Style_States;
13 use Elementor\Modules\AtomicWidgets\Controls\Section;
14 use Elementor\Modules\AtomicWidgets\PropTypes\Classes_Prop_Type;
15 use Elementor\Modules\AtomicWidgets\PropTypes\Attributes_Prop_Type;
16 use Elementor\Modules\AtomicWidgets\Render_Context;
17
18
19 if ( ! defined( 'ABSPATH' ) ) {
20 exit; // Exit if accessed directly.
21 }
22
23 class Atomic_Tab_Content extends Atomic_Element_Base {
24 const BASE_STYLE_KEY = 'base';
25
26 public static function get_type() {
27 return 'e-tab-content';
28 }
29
30 public static function get_element_type(): string {
31 return 'e-tab-content';
32 }
33
34 public function get_title() {
35 return esc_html__( 'Tab content', 'elementor' );
36 }
37
38 public function get_keywords() {
39 return [ 'ato', 'atom', 'atoms', 'atomic', 'tab', 'content', 'tabs' ];
40 }
41
42 public function get_icon() {
43 return 'eicon-layout';
44 }
45
46 public function should_show_in_panel() {
47 return false;
48 }
49
50 protected static function define_props_schema(): array {
51 return [
52 'classes' => Classes_Prop_Type::make()
53 ->default( [] ),
54 'tab-id' => String_Prop_Type::make(),
55 'attributes' => Attributes_Prop_Type::make(),
56 ];
57 }
58
59 protected function define_atomic_controls(): array {
60 return [
61 Section::make()
62 ->set_label( __( 'Settings', 'elementor' ) )
63 ->set_id( 'settings' )
64 ->set_items( [] ),
65 ];
66 }
67
68 protected function define_atomic_style_states(): array {
69 $selected_state = Style_States::get_class_states_map()['selected'];
70
71 return [ $selected_state ];
72 }
73
74 protected function define_base_styles(): array {
75 $styles = [
76 'display' => String_Prop_Type::generate( 'block' ),
77 'padding' => Size_Prop_Type::generate( [
78 'size' => 10,
79 'unit' => 'px',
80 ] ),
81 'min-width' => Size_Prop_Type::generate( [
82 'size' => 30,
83 'unit' => 'px',
84 ] ),
85 ];
86
87 return [
88 static::BASE_STYLE_KEY => Style_Definition::make()
89 ->add_variant(
90 Style_Variant::make()
91 ->add_props( $styles )
92 ),
93 ];
94 }
95
96 protected function define_initial_attributes() {
97 return [
98 'role' => 'tabpanel',
99 ];
100 }
101
102 protected function add_render_attributes() {
103 parent::add_render_attributes();
104 $settings = $this->get_atomic_settings();
105 $base_style_class = $this->get_base_styles_dictionary()[ static::BASE_STYLE_KEY ];
106 $initial_attributes = $this->define_initial_attributes();
107
108 $tabs_context = Render_Context::get( Atomic_Tabs::class );
109 $default_active_tab = $tabs_context['default-active-tab'];
110 $get_tab_content_index = $tabs_context['get-tab-content-index'];
111 $tabs_id = $tabs_context['tabs-id'];
112
113 $index = $get_tab_content_index( $this->get_id() );
114 $is_active = $default_active_tab === $index;
115
116 $attributes = [
117 'class' => [
118 'e-con',
119 'e-atomic-element',
120 $base_style_class,
121 ...( $settings['classes'] ?? [] ),
122 ],
123 'x-bind' => 'tabContent',
124 'id' => Atomic_Tabs::get_tab_content_id( $tabs_id, $index ),
125 'aria-labelledby' => Atomic_Tabs::get_tab_id( $tabs_id, $index ),
126 ];
127
128 if ( ! $is_active ) {
129 $attributes['hidden'] = 'true';
130 $attributes['style'] = 'display: none;';
131 }
132
133 if ( ! empty( $settings['_cssid'] ) ) {
134 $attributes['id'] = esc_attr( $settings['_cssid'] );
135 }
136
137 $this->add_render_attribute( '_wrapper', array_merge( $initial_attributes, $attributes ) );
138 }
139 }
140