PluginProbe
UiCore Elements – Free widgets and templates for Elementor / 1.3.17
UiCore Elements – Free widgets and templates for Elementor v1.3.17
1.3.17 1.3.16 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 All 41 releases
uicore-elements / includes / utils / item-style-component.php

item-style-component.php in UiCore Elements – Free widgets and templates for Elementor 1.3.17, at includes/utils/item-style-component.php

220 lines 7.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace UiCoreElements\Utils;
4
5 use Elementor\Controls_Manager;
6 use Elementor\Group_Control_Border;
7 use Elementor\Group_Control_Box_Shadow;
8 use Elementor\Group_Control_Background;
9
10 defined('ABSPATH') || exit();
11
12 /*
13 * Basic Item Styles Component
14 */
15
16 trait Item_Style_Component
17 {
18
19 function TRAIT_register_normal_item_style_controls($tab = true)
20 {
21 // If the widget doesn't require extra controls, we can use tabs to decrease the widget code
22 if ($tab) {
23 $this->start_controls_tab(
24 'tab_item_normal',
25 [
26 'label' => esc_html__('Normal', 'uicore-elements'),
27 ]
28 );
29 }
30
31 $this->add_group_control(
32 Group_Control_Background::get_type(),
33 [
34 'name' => 'item_background',
35 'selector' => '{{WRAPPER}} .ui-e-item',
36 ]
37 );
38 $this->add_group_control(
39 Group_Control_Border::get_type(),
40 [
41 'name' => 'item_border',
42 'label' => esc_html__('Border', 'uicore-elements'),
43 'fields_options' => [
44 'border' => [
45 'default' => 'solid',
46 ],
47 'width' => [
48 'default' => [
49 'top' => '1',
50 'right' => '1',
51 'bottom' => '1',
52 'left' => '1',
53 'isLinked' => true,
54 ],
55 ],
56 'color' => [
57 'default' => '#EEE'
58 ]
59 ],
60 'selector' => '{{WRAPPER}} .ui-e-item',
61 ]
62 );
63 $this->add_responsive_control(
64 'item_border_radius',
65 [
66 'label' => esc_html__('Border Radius', 'uicore-elements'),
67 'type' => Controls_Manager::DIMENSIONS,
68 'size_units' => ['px', '%'],
69 'default' => [
70 'top' => 12,
71 'right' => 12,
72 'bottom' => 12,
73 'left' => 12,
74 'unit' => 'px',
75 'isLinked' => true,
76 ],
77 'selectors' => [
78 '{{WRAPPER}}' => '--ui-e-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', // Sliders use --ui-e-radius var as item radius
79 '{{WRAPPER}} .ui-e-item' => 'border-radius: var(--ui-e-radius);',
80 ],
81 ]
82 );
83 $this->add_responsive_control(
84 'item_padding',
85 [
86 'label' => esc_html__('Padding', 'uicore-elements'),
87 'type' => Controls_Manager::DIMENSIONS,
88 'size_units' => ['px', 'em', '%'],
89 'default' => [
90 'top' => 30,
91 'right' => 30,
92 'bottom' => 30,
93 'left' => 30,
94 'unit' => 'px',
95 'isLinked' => true,
96 ],
97 'selectors' => [
98 '{{WRAPPER}} .ui-e-item' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
99 ],
100 ]
101 );
102 $this->add_group_control(
103 Group_Control_Box_Shadow::get_type(),
104 [
105 'name' => 'item_box_shadow',
106 'selector' => '{{WRAPPER}} .ui-e-item',
107 ]
108 );
109
110 if ($tab) {
111 $this->end_controls_tab();
112 }
113 }
114 function TRAIT_register_hover_item_style_controls($tab = true)
115 {
116 // If the widget doesn't require extra controls, we can use tabs to decrease the widget code
117 if ($tab) {
118 $this->start_controls_tab(
119 'tab_item_hover',
120 [
121 'label' => esc_html__('Hover', 'uicore-elements'),
122 ]
123 );
124 }
125
126 $this->add_group_control(
127 Group_Control_Background::get_type(),
128 [
129 'name' => 'item_hover_background',
130 'selector' => '{{WRAPPER}} .ui-e-item:hover',
131 ]
132 );
133 $this->add_control(
134 'item_hover_border_color',
135 [
136 'label' => esc_html__('Border Color', 'uicore-elements'),
137 'type' => Controls_Manager::COLOR,
138 'condition' => [
139 'item_border_border!' => '',
140 ],
141 'selectors' => [
142 '{{WRAPPER}} .ui-e-item:hover' => 'border-color: {{VALUE}};',
143 ],
144 ]
145 );
146 $this->add_group_control(
147 Group_Control_Box_Shadow::get_type(),
148 [
149 'name' => 'item_hover_box_shadow',
150 'selector' => '{{WRAPPER}} .ui-e-wrp:hover .ui-e-item',
151 ]
152 );
153
154 if ($tab) {
155 $this->end_controls_tab();
156 }
157 }
158 function TRAIT_register_active_item_style_controls($tab = true)
159 {
160 // If the widget doesn't require extra controls, we can use tabs to decrease the widget code
161 if ($tab) {
162 $this->start_controls_tab(
163 'tab_item_active',
164 [
165 'label' => esc_html__('Active', 'uicore-elements'),
166 ]
167 );
168 }
169
170 $this->add_group_control(
171 Group_Control_Background::get_type(),
172 [
173 'name' => 'item_active_background',
174 'selector' => '{{WRAPPER}} .ui-e-wrp.is-selected .ui-e-item',
175 ]
176 );
177 $this->add_control(
178 'item_active_border_color',
179 [
180 'label' => esc_html__('Border Color', 'uicore-elements'),
181 'type' => Controls_Manager::COLOR,
182 'condition' => [
183 'item_border_border!' => '',
184 ],
185 'selectors' => [
186 '{{WRAPPER}} .ui-e-wrp.is-selected .ui-e-item' => 'border-color: {{VALUE}};',
187 ],
188 ]
189 );
190 $this->add_group_control(
191 Group_Control_Box_Shadow::get_type(),
192 [
193 'name' => 'item_active_box_shadow',
194 'selector' => '{{WRAPPER}} .ui-e-wrp.is-selected .ui-e-item',
195 ]
196 );
197
198 if ($tab) {
199 $this->end_controls_tab();
200 }
201 }
202
203 /**
204 * Register all Item Style Controls at Once
205 *
206 * @param boolean $active_state Register Active State Controls. Default is `true`
207 * @return void
208 */
209 function TRAIT_register_all_item_style_controls($active_state = true)
210 {
211 $this->start_controls_tabs('tabs_item_style');
212 $this->TRAIT_register_normal_item_style_controls();
213 $this->TRAIT_register_hover_item_style_controls();
214 if ($active_state) {
215 $this->TRAIT_register_active_item_style_controls();
216 }
217 $this->end_controls_tabs();
218 }
219 }
220