1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
<?php namespace Elementor\Modules\AtomicWidgets\Elements\Flexbox;
use Elementor\Modules\AtomicWidgets\Elements\Atomic_Element_Base; use Elementor\Modules\AtomicWidgets\PropTypes\Primitives\String_Prop_Type; use Elementor\Modules\AtomicWidgets\PropTypes\Size_Prop_Type; use Elementor\Modules\AtomicWidgets\Styles\Style_Definition; use Elementor\Modules\AtomicWidgets\Styles\Style_Variant; use Elementor\Modules\AtomicWidgets\Controls\Section; use Elementor\Modules\AtomicWidgets\Controls\Types\Link_Control; use Elementor\Modules\AtomicWidgets\Controls\Types\Select_Control; use Elementor\Modules\AtomicWidgets\Controls\Types\Text_Control; use Elementor\Modules\AtomicWidgets\PropDependencies\Manager as Dependency_Manager; use Elementor\Modules\AtomicWidgets\PropTypes\Classes_Prop_Type; use Elementor\Modules\AtomicWidgets\PropTypes\Attributes_Prop_Type; use Elementor\Modules\AtomicWidgets\PropTypes\Link_Prop_Type;
if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. }
class Flexbox extends Atomic_Element_Base { const BASE_STYLE_KEY = 'base';
public static function get_type() { return 'e-flexbox'; }
public static function get_element_type(): string { return 'e-flexbox'; }
public function get_title() { return esc_html__( 'Flexbox', 'elementor' ); }
public function get_keywords() { return [ 'ato', 'atom', 'atoms', 'atomic' ]; }
public function get_icon() { return 'eicon-flexbox'; }
protected static function define_props_schema(): array { $tag_dependencies = Dependency_Manager::make() ->where( [ 'operator' => 'not_exist', 'path' => [ 'link', 'destination' ], ] ) ->get();
return [ 'classes' => Classes_Prop_Type::make() ->default( [] ), 'tag' => String_Prop_Type::make() ->enum( [ 'div', 'header', 'section', 'article', 'aside', 'footer' ] ) ->default( 'div' ) ->set_dependencies( $tag_dependencies ), 'link' => Link_Prop_Type::make(), 'attributes' => Attributes_Prop_Type::make(), ]; }
protected function define_atomic_controls(): array { return [ Section::make() ->set_label( __( 'Settings', 'elementor' ) ) ->set_id( 'settings' ) ->set_items( [ Select_Control::bind_to( 'tag' ) ->set_options( [ [ 'value' => 'div', 'label' => 'Div', ], [ 'value' => 'header', 'label' => 'Header', ], [ 'value' => 'section', 'label' => 'Section', ], [ 'value' => 'article', 'label' => 'Article', ], [ 'value' => 'aside', 'label' => 'Aside', ], [ 'value' => 'footer', 'label' => 'Footer', ], ]) ->set_label( esc_html__( 'HTML Tag', 'elementor' ) ), Link_Control::bind_to( 'link' ) ->set_label( __( 'Link', 'elementor' ) ) ->set_meta( [ 'topDivider' => true, ] ), Text_Control::bind_to( '_cssid' ) ->set_label( __( 'ID', 'elementor' ) ) ->set_meta( $this->get_css_id_control_meta() ), ] ), ]; }
protected function define_base_styles(): array { $display = String_Prop_Type::generate( 'flex' ); $flex_direction = String_Prop_Type::generate( 'row' );
return [ static::BASE_STYLE_KEY => Style_Definition::make() ->add_variant( Style_Variant::make() ->add_prop( 'display', $display ) ->add_prop( 'flex-direction', $flex_direction ) ->add_prop( 'padding', $this->get_base_padding() ) ), ]; }
protected function get_base_padding(): array { return Size_Prop_Type::generate( [ 'size' => 10, 'unit' => 'px', ] ); }
protected function add_render_attributes() { parent::add_render_attributes(); $settings = $this->get_atomic_settings(); $base_style_class = $this->get_base_styles_dictionary()[ static::BASE_STYLE_KEY ];
$attributes = [ 'class' => [ 'e-con', 'e-atomic-element', $base_style_class, ...( $settings['classes'] ?? [] ), ], ];
if ( ! empty( $settings['_cssid'] ) ) { $attributes['id'] = esc_attr( $settings['_cssid'] ); }
if ( ! empty( $settings['link']['href'] ) ) { $attributes = array_merge( $attributes, $settings['link'] ); }
$this->add_render_attribute( '_wrapper', $attributes ); } }
|