PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.9.1
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.9.1
2.13.0 2.13.1 2.12.0 2.11.1 2.11.0 2.10.0 2.9.0 2.7.4 2.7.5 2.7.6 2.7.7 2.8.0 2.8.1 2.9.1 trunk 1.0 1.0-beta1 1.0-beta2 1.0-beta3 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 All 80 releases
ablocks / includes / blocks / tabs / block.php

block.php in aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder 2.9.1, at includes/blocks/tabs/block.php

724 lines 23.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace ABlocks\Blocks\Tabs;
4
5 use ABlocks\Classes\BlockBaseAbstract;
6 use ABlocks\Classes\CssGenerator;
7 use ABlocks\Controls\Typography;
8 use ABlocks\Controls\Dimensions;
9 use ABlocks\Controls\Border;
10 use ABlocks\Controls\Icon;
11 use ABlocks\Controls\BoxShadow;
12 use ABlocks\Controls\Range;
13
14 class Block extends BlockBaseAbstract {
15
16 protected $block_name = 'tabs';
17
18 public function build_css( $attributes ) {
19 $css_generator = new CssGenerator( $attributes, $this->block_name );
20
21 $css_generator->add_class_styles(
22 '{{WRAPPER}} .ablocks-block-tabs',
23 $this->get_tabs_css( $attributes ),
24 $this->get_tabs_css( $attributes, 'Tablet' ),
25 $this->get_tabs_css( $attributes, 'Mobile' )
26 );
27
28 $css_generator->add_class_styles(
29 '{{WRAPPER}} .ablocks-block-tabs__tab-panel',
30 $this->get_tabs_panel_css( $attributes ),
31 $this->get_tabs_panel_css( $attributes, 'Tablet' ),
32 $this->get_tabs_panel_css( $attributes, 'Mobile' )
33 );
34
35 $css_generator->add_class_styles(
36 '{{WRAPPER}} .ablocks-block-tabs__tab',
37 $this->get_tabs_menu_content_css( $attributes ),
38 $this->get_tabs_menu_content_css( $attributes, 'Tablet' ),
39 $this->get_tabs_menu_content_css( $attributes, 'Mobile' )
40 );
41
42 $css_generator->add_class_styles(
43 '{{WRAPPER}} .ablocks-block-tabs__tab--active',
44 $this->get_tabs_menu_content_active_css( $attributes ),
45 $this->get_tabs_menu_content_active_css( $attributes, 'Tablet' ),
46 $this->get_tabs_menu_content_active_css( $attributes, 'Mobile' )
47 );
48
49 $css_generator->add_class_styles(
50 '{{WRAPPER}} .ablocks-block-tabs__tab:hover',
51 $this->get_tabs_menu_content_hover_css( $attributes ),
52 $this->get_tabs_menu_content_hover_css( $attributes, 'Tablet' ),
53 $this->get_tabs_menu_content_hover_css( $attributes, 'Mobile' )
54 );
55 $css_generator->add_class_styles(
56 '{{WRAPPER}} .ablocks-block-tabs__tab-menu-title',
57 $this->get_tabs_title_css( $attributes ),
58 $this->get_tabs_title_css( $attributes, 'Tablet' ),
59 $this->get_tabs_title_css( $attributes, 'Mobile' )
60 );
61
62 $css_generator->add_class_styles(
63 '{{WRAPPER}} .ablocks-block-tabs__tab--active .ablocks-block-tabs__tab-menu-title',
64 $this->get_tabs_active_title_css( $attributes ),
65 $this->get_tabs_active_title_css( $attributes, 'Tablet' ),
66 $this->get_tabs_active_title_css( $attributes, 'Mobile' )
67 );
68
69 $css_generator->add_class_styles(
70 '{{WRAPPER}} .ablocks-block-tabs__tab-menu-subtitle',
71 $this->get_tabs_subtitle_css( $attributes ),
72 $this->get_tabs_subtitle_css( $attributes, 'Tablet' ),
73 $this->get_tabs_subtitle_css( $attributes, 'Mobile' )
74 );
75
76 $css_generator->add_class_styles(
77 '{{WRAPPER}} .ablocks-block-tabs__tab--active .ablocks-block-tabs__tab-menu-subtitle',
78 $this->get_tabs_active_subtitle_text_css( $attributes ),
79 $this->get_tabs_active_subtitle_text_css( $attributes, 'Tablet' ),
80 $this->get_tabs_active_subtitle_text_css( $attributes, 'Mobile' )
81 );
82 if ( isset( $attributes['showActiveSubTitle'] ) && $attributes['showActiveSubTitle'] === false ) {
83 $css_generator->add_class_styles(
84 '{{WRAPPER}} .ablocks-block-tabs__icon',
85 $this->get_icon_position_css( $attributes ),
86 $this->get_icon_position_css( $attributes, 'Tablet' ),
87 $this->get_icon_position_css( $attributes, 'Mobile' )
88 );
89 } else {
90 $css_generator->add_class_styles(
91 '{{WRAPPER}} .ablocks-block-tabs__tab--active .ablocks-block-tabs__icon',
92 $this->get_icon_position_css( $attributes ),
93 $this->get_icon_position_css( $attributes, 'Tablet' ),
94 $this->get_icon_position_css( $attributes, 'Mobile' )
95 );
96 }
97 $css_generator->add_class_styles(
98 '{{WRAPPER}} .ablocks-block-tabs__tab--active .ablocks-block-tabs__progressbar',
99 $this->progress_bar_style_css( $attributes ),
100 $this->progress_bar_style_css( $attributes, 'Tablet' ),
101 $this->progress_bar_style_css( $attributes, 'Mobile' )
102 );
103 $tabs_element_icon_wrapper_styles = Icon::get_wrapper_css( $attributes );
104
105 $spacing_value = [];
106
107 switch ( $attributes['iconPosition'] ) {
108 case 'left':
109 $spacing_value = Range::get_css([
110 'attributeValue' => $attributes['spacing'] ?? null,
111 'attributeObjectKey' => 'value',
112 'defaultValue' => 0,
113 'isResponsive' => true,
114 'hasUnit' => true,
115 'property' => 'margin-right',
116 'unitDefaultValue' => 'px',
117 ]);
118 break;
119 case 'right':
120 $spacing_value = Range::get_css([
121 'attributeValue' => $attributes['spacing'] ?? null,
122 'attributeObjectKey' => 'value',
123 'defaultValue' => 0,
124 'isResponsive' => true,
125 'hasUnit' => true,
126 'property' => 'margin-left',
127 'unitDefaultValue' => 'px',
128 ]);
129 break;
130 case 'bottom':
131 $spacing_value = Range::get_css([
132 'attributeValue' => $attributes['spacing'] ?? null,
133 'attributeObjectKey' => 'value',
134 'defaultValue' => 0,
135 'isResponsive' => true,
136 'hasUnit' => true,
137 'property' => 'margin-top',
138 'unitDefaultValue' => 'px',
139 ]);
140 break;
141 case 'top':
142 $spacing_value = Range::get_css([
143 'attributeValue' => $attributes['spacing'] ?? null,
144 'attributeObjectKey' => 'value',
145 'defaultValue' => 0,
146 'isResponsive' => true,
147 'hasUnit' => true,
148 'property' => 'margin-bottom',
149 'unitDefaultValue' => 'px',
150 ]);
151 break;
152 }//end switch
153
154 // Merge $spacing_value into icon wrapper styles
155 $tabs_element_icon_wrapper_styles = array_merge(
156 Icon::get_wrapper_css( $attributes ),
157 $spacing_value
158 );
159
160 // Generate tablet and mobile styles for the icon wrapper
161 $tablet_styles = array_merge(
162 Icon::get_wrapper_css( $attributes, 'Tablet' ),
163 $spacing_value
164 );
165 $mobile_styles = array_merge(
166 Icon::get_wrapper_css( $attributes, 'Mobile' ),
167 $spacing_value
168 );
169
170 // Add icon wrapper styles to the CSS generator
171 if ( ! empty( $tabs_element_icon_wrapper_styles ) || ! empty( $tablet_styles ) || ! empty( $mobile_styles ) ) {
172 $css_generator->add_class_styles(
173 '{{WRAPPER}} .ablocks-block-tabs__icon .ablocks-icon-wrap',
174 $tabs_element_icon_wrapper_styles,
175 $tablet_styles,
176 $mobile_styles
177 );
178 }
179
180 $css_generator->add_class_styles(
181 '{{WRAPPER}} .ablocks-block-tabs__icon .ablocks-icon-wrap img.ablocks-image-icon',
182 Icon::get_element_image_css( $attributes ),
183 Icon::get_element_image_css( $attributes, 'Tablet' ),
184 Icon::get_element_image_css( $attributes, 'Mobile' ),
185 );
186 $css_generator->add_class_styles(
187 '{{WRAPPER}} .ablocks-block-tabs__icon .ablocks-icon-wrap img.ablocks-image-icon:hover',
188 Icon::get_element_image_hover_css( $attributes ),
189 Icon::get_element_image_hover_css( $attributes, 'Tablet' ),
190 Icon::get_element_image_hover_css( $attributes, 'Mobile' ),
191 );
192 $css_generator->add_class_styles(
193 '{{WRAPPER}} .ablocks-block-tabs__icon .ablocks-icon-wrap svg.ablocks-svg-icon',
194 Icon::get_element_css( $attributes ),
195 Icon::get_element_css( $attributes, 'Tablet' ),
196 Icon::get_element_css( $attributes, 'Mobile' ),
197 );
198 $css_generator->add_class_styles(
199 '{{WRAPPER}} .ablocks-block-tabs__icon .ablocks-icon-wrap svg.ablocks-svg-icon:hover',
200 Icon::get_element_image_hover_css( $attributes ),
201 Icon::get_element_image_hover_css( $attributes, 'Tablet' ),
202 Icon::get_element_image_hover_css( $attributes, 'Mobile' ),
203 );
204
205 $css_generator->add_class_styles(
206 '{{WRAPPER}} .ablocks-block-tabs__body',
207 $this->get_tabs_content_css( $attributes ),
208 $this->get_tabs_content_css( $attributes, 'Tablet' ),
209 $this->get_tabs_content_css( $attributes, 'Mobile' )
210 );
211
212 $css_generator->add_class_styles(
213 '{{WRAPPER}} .ablocks-block-tabs__body:hover',
214 $this->get_tabs_content_hover_css( $attributes ),
215 $this->get_tabs_content_hover_css( $attributes, 'Tablet' ),
216 $this->get_tabs_content_hover_css( $attributes, 'Mobile' )
217 );
218 $css_generator->add_class_styles(
219 '{{WRAPPER}} .ablocks-block-tabs__tab-menu-content',
220 $this->get_content_css( $attributes ),
221 $this->get_content_css( $attributes, 'Tablet' ),
222 $this->get_content_css( $attributes, 'Mobile' )
223 );
224 $css_generator->add_class_styles(
225 '{{WRAPPER}} .ablocks-block-tabs__tab-panel',
226 $this->get_tabs_width_css( $attributes ),
227 $this->get_tabs_width_css( $attributes, 'Tablet' ),
228 $this->get_tabs_width_css( $attributes, 'Mobile' )
229 );
230 $css_generator->add_class_styles(
231 '{{WRAPPER}} .ablocks-block-tabs__body',
232 $this->get_content_width_css( $attributes ),
233 $this->get_content_width_css( $attributes, 'Tablet' ),
234 $this->get_content_width_css( $attributes, 'Mobile' )
235 );
236
237 return $css_generator->generate_css();
238 }
239
240
241 public function get_tabs_css( $attributes, $device = '' ) {
242 $tabs_css = [];
243
244 // Determine the tabs menu position for the given device
245 $menuPosition = $attributes['tabsMenuPositioning'][ 'value' . $device ] ?? '';
246
247 // Apply CSS rules based on the device type and menu position
248 if ( $device === 'Mobile' ) {
249 if ( empty( $menuPosition ) || $menuPosition === 'left' || $menuPosition === 'top' ) {
250 $tabs_css['flex-direction'] = 'column';
251 } elseif ( $menuPosition === 'right' || $menuPosition === 'bottom' ) {
252 $tabs_css['flex-direction'] = 'column-reverse';
253 }
254 } else {
255 // For desktop and tablet
256 if ( $menuPosition === 'top' ) {
257 $tabs_css['flex-direction'] = 'column';
258 } elseif ( $menuPosition === 'bottom' ) {
259 $tabs_css['flex-direction'] = 'column-reverse';
260 } elseif ( $menuPosition === 'right' ) {
261 $tabs_css['flex-direction'] = 'row-reverse';
262 } elseif ( $menuPosition === 'left' ) {
263 $tabs_css['flex-direction'] = 'row';
264 }
265 }
266
267 return $tabs_css;
268 }
269
270 public function get_tabs_panel_css( $attributes, $device = '' ) {
271 $tabs_panel_css = [];
272
273 // Handle tabMenuAlign for the given device
274 if ( isset( $attributes['tabMenuAlignment'][ 'value' . $device ] ) ) {
275 $tabs_panel_css['justify-content'] = $attributes['tabMenuAlignment'][ 'value' . $device ];
276 }
277
278 // Determine the tabsMenuPosition and apply styles accordingly
279 $tabsMenuPosition = $attributes['tabsMenuPositioning'][ 'value' . $device ] ?? '';
280
281 if ( $tabsMenuPosition === 'top' || $tabsMenuPosition === 'bottom' ) {
282 // For column layout
283 $tabs_panel_css['flex-direction'] = ( $device === 'Tablet' || $device === 'Mobile' ) ? 'column' : 'row';
284 $tabs_panel_css['max-width'] = '100%';
285 $tabs_panel_css['flex-wrap'] = 'wrap';
286 } elseif ( empty( $tabsMenuPosition ) || $tabsMenuPosition === 'left' || $tabsMenuPosition === 'right' ) {
287 // For row layout
288 $tabs_panel_css['flex-direction'] = 'column';
289 $tabs_panel_css['max-width'] = ( $device === 'Mobile' ) ? '100%' : '30%';
290 $tabs_panel_css['min-width'] = ( $device === 'Mobile' ) ? '100%' : '30%';
291 $tabs_panel_css['flex-grow'] = 1;
292 }
293
294 return $tabs_panel_css;
295 }
296 public function get_tabs_menu_content_css( $attributes, $device = '' ) {
297 $css = [];
298 $css['display'] = 'flex';
299
300 // Handling icon position
301 if ( isset( $attributes['iconPosition'] ) && $attributes['iconPosition'] === 'top' ) {
302 $css['flex-direction'] = 'column';
303 if ( isset( $attributes['menuContentAlignment'][ 'value' . $device ] ) ) {
304 $css['align-items'] = $attributes['menuContentAlignment'][ 'value' . $device ];
305 }
306 }
307 if ( isset( $attributes['iconPosition'] ) && $attributes['iconPosition'] === 'bottom' ) {
308 $css['flex-direction'] = 'column-reverse';
309 if ( isset( $attributes['menuContentAlignment'][ 'value' . $device ] ) ) {
310 $css['align-items'] = $attributes['menuContentAlignment'][ 'value' . $device ];
311 }
312 }
313 if ( isset( $attributes['iconPosition'] ) && $attributes['iconPosition'] === 'left' ) {
314 $css['flex-direction'] = 'row';
315 $css['align-items'] = 'center';
316 if ( isset( $attributes['menuContentAlignment'][ 'value' . $device ] ) ) {
317 $css['justify-content'] = $attributes['menuContentAlignment'][ 'value' . $device ];
318 }
319 }
320 if ( isset( $attributes['iconPosition'] ) && $attributes['iconPosition'] === 'right' ) {
321 $css['flex-direction'] = 'row-reverse';
322 $css['align-items'] = 'center';
323 if ( isset( $attributes['menuContentAlignment'][ 'value' . $device ] ) ) {
324 $css['justify-content'] = $attributes['menuContentAlignment'][ 'value' . $device ];
325 }
326 }
327
328 // Tab background color
329 if ( isset( $attributes['tabBackgroundColor'] ) ) {
330 $css['background-color'] = $attributes['tabBackgroundColor'];
331 }
332
333 // Handling tabs gap
334 $tabs_gap_value = [];
335 $tabs_menu_position = $attributes['tabsMenuPositioning'][ 'value' . $device ] ?? '';
336
337 if ( ( $tabs_menu_position === 'left' || $tabs_menu_position === 'right' ) ) {
338 $tabs_gap_value = array_merge(
339 Range::get_css([
340 'attributeValue' => $attributes['tabsGap'],
341 'attribute_object_key' => 'value',
342 'isResponsive' => true,
343 'defaultValue' => 10,
344 'hasUnit' => true,
345 'unitDefaultValue' => 'px',
346 'property' => 'margin-top',
347 'device' => $device,
348 ]),
349 Range::get_css([
350 'attributeValue' => $attributes['tabsGap'],
351 'attribute_object_key' => 'value',
352 'isResponsive' => true,
353 'defaultValue' => 10,
354 'hasUnit' => true,
355 'unitDefaultValue' => 'px',
356 'property' => 'margin-bottom',
357 'device' => $device,
358 ]),
359 );
360 }//end if
361 if ( ( $tabs_menu_position === 'top' || $tabs_menu_position === 'bottom' ) ) {
362 if ( $device === 'Tablet' || $device === 'Mobile' ) {
363 $tabs_gap_value = array_merge(
364 Range::get_css([
365 'attributeValue' => $attributes['tabsGap'],
366 'attribute_object_key' => 'value',
367 'isResponsive' => true,
368 'defaultValue' => 10,
369 'hasUnit' => true,
370 'unitDefaultValue' => 'px',
371 'property' => 'margin-top',
372 'device' => $device,
373 ]),
374 Range::get_css([
375 'attributeValue' => $attributes['tabsGap'],
376 'attribute_object_key' => 'value',
377 'isResponsive' => true,
378 'defaultValue' => 10,
379 'hasUnit' => true,
380 'unitDefaultValue' => 'px',
381 'property' => 'margin-bottom',
382 'device' => $device,
383 ]),
384 );
385 } else {
386 $tabs_gap_value = array_merge(
387 Range::get_css([
388 'attributeValue' => $attributes['tabsGap'],
389 'attribute_object_key' => 'value',
390 'isResponsive' => true,
391 'defaultValue' => 10,
392 'hasUnit' => true,
393 'unitDefaultValue' => 'px',
394 'property' => 'margin-left',
395 'device' => $device,
396 ]),
397 Range::get_css([
398 'attributeValue' => $attributes['tabsGap'],
399 'attribute_object_key' => 'value',
400 'isResponsive' => true,
401 'defaultValue' => 10,
402 'hasUnit' => true,
403 'unitDefaultValue' => 'px',
404 'property' => 'margin-right',
405 'device' => $device,
406 ]),
407 );
408 }//end if
409 }//end if
410
411 // Merging with margin, padding, and border styles
412 return array_merge(
413 $css,
414 $tabs_gap_value,
415 Dimensions::get_css( $attributes['menuContentPadding'] ?? [], 'padding', $device ),
416 Border::get_css( $attributes['menuContentBorder'] ?? [], '', $device ),
417 BoxShadow::get_css( $attributes['boxShadow'], '', $device ),
418 );
419 }
420
421
422 public function get_tabs_menu_content_active_css( $attributes, $device = '' ) {
423 $tabs_menu_content_active_css = [];
424 if ( isset( $attributes['tabsMenuPositioning'][ 'value' . $device ] ) ) {
425 switch ( $attributes['tabsMenuPositioning'][ 'value' . $device ] ) {
426 case 'top':
427 $tabs_menu_content_active_css['border-bottom-color'] = 'none';
428 break;
429 case 'bottom':
430 $tabs_menu_content_active_css['border-top-color'] = 'none';
431 break;
432 case 'left':
433 $tabs_menu_content_active_css['border-right-color'] = 'none';
434 break;
435 case 'right':
436 $tabs_menu_content_active_css['border-left-color'] = 'none';
437 break;
438 }
439 }
440 $border_width = isset( $attributes['menuContentBorder']['commonWidth'] ) && ! empty( $attributes['menuContentBorder']['commonWidth'] )
441 ? $attributes['menuContentBorder']['commonWidth']
442 : '2px';
443 if ( isset( $attributes['activeColorOptions'] ) && $attributes['activeColorOptions'] === 'background' ) {
444 if ( isset( $attributes['tabActiveBackgroundColor'] ) ) {
445 $tabs_menu_content_active_css['background-color'] = $attributes['tabActiveBackgroundColor'] . ' !important';
446 }
447 } elseif ( isset( $attributes['activeColorOptions'] ) && $attributes['activeColorOptions'] === 'border' ) {
448 $tabs_menu_content_active_css['border-width'] = $border_width;
449 if ( isset( $attributes['activeBorderColor'] ) ) {
450 $tabs_menu_content_active_css['border-color'] = $attributes['activeBorderColor'] . ' !important';
451 }
452 }
453
454 return $tabs_menu_content_active_css;
455 }
456
457
458 public function get_tabs_menu_content_hover_css( $attributes, $device = '' ) {
459
460 return array_merge(
461 Border::get_hover_css( $attributes['menuContentBorder'] ?? [], '', $device ),
462 BoxShadow::get_hover_css( $attributes['boxShadow'], '', $device )
463 );
464 }
465 public function get_tabs_title_css( $attributes, $device = '' ) {
466 $css = [];
467 if ( isset( $attributes['titleTextColor'] ) ) {
468 $css['color'] = $attributes['titleTextColor'];
469 }
470 return array_merge(
471 $css,
472 Typography::get_css( $attributes['titleTypography'] ?? [], '', $device ));
473 }
474
475 public function get_tabs_active_title_css( $attributes, $device = '' ) {
476 $css = [];
477 if ( isset( $attributes['titleTextActiveColor'] ) ) {
478 $css['color'] = $attributes['titleTextActiveColor'];
479 }
480 return $css;
481 }
482
483 public function get_tabs_subtitle_css( $attributes, $device = '' ) {
484 $tabsSubtitleCSS = [];
485 if ( isset( $attributes['showActiveSubTitle'] ) && $attributes['showActiveSubTitle'] === true ) {
486 $tabsSubtitleCSS['display'] = 'none';
487 }
488 // Get subtitle text color
489 if ( isset( $attributes['subTitleTextColor'] ) ) {
490 $tabsSubtitleCSS['color'] = $attributes['subTitleTextColor'];
491 }
492
493 // Get typography styles
494 $typographyStyles = Typography::get_css( $attributes['subTitleTypography'] ?? [], '', $device );
495 $tabsSubtitleCSS = array_merge( $tabsSubtitleCSS, $typographyStyles );
496
497 // Determine width based on menu position
498 $position = $attributes['tabsMenuPositioning'][ 'value' . $device ] ?? '';
499 if ( $position === 'top' || $position === 'bottom' ) {
500 $tabsSubtitleCSS['width'] = '160px';
501 } else {
502 $tabsSubtitleCSS['width'] = '100%';
503 }
504
505 return $tabsSubtitleCSS;
506 }
507
508
509 public function get_tabs_active_subtitle_text_css( $attributes, $device = '' ) {
510 $css = [];
511 if ( isset( $attributes['showActiveSubTitle'] ) && $attributes['showActiveSubTitle'] === true ) {
512 $css['display'] = 'block';
513 }
514 if ( isset( $attributes['subTitleTextActiveColor'] ) ) {
515 $css['color'] = $attributes['subTitleTextActiveColor'] . '!important';
516 }
517 return $css;
518 }
519 public function get_icon_position_css( $attributes, $device = '' ) {
520 return array_merge(
521 Dimensions::get_css( $attributes['iconPositionMargin'] ?? [], 'margin', $device )
522 );
523 }
524 public function progress_bar_style_css( $attributes, $device = '' ) {
525 $css = [];
526 if ( isset( $attributes['progressBarColor'] ) ) {
527 $css['background-color'] = $attributes['progressBarColor'];
528 }
529 return $css;
530 }
531
532 public function get_tabs_icon_css( $attributes, $device = '' ) {
533 $css = [];
534 $iconType = $attributes['iconType'] ?? 'default';
535 $iconShape = $attributes['iconShape'] ?? 'square';
536 $iconColor = $attributes['iconColor'] ?? '#69727d';
537 $iconBackground = $attributes['iconBackground'] ?? 'transparent';
538 $size = $attributes['size'][ 'value' . $device ] ?? null;
539 $spacing = $attributes['spacing'][ 'value' . $device ] ?? null;
540 $iconPosition = $attributes['iconPosition'] ?? '';
541
542 // Determine icon view CSS based on type and shape
543 $iconViewCSS = [];
544
545 if ( $iconType !== 'default' ) {
546 if ( $iconType === 'stacked' ) {
547 $iconViewCSS['background'] = $iconBackground;
548 $iconViewCSS['padding'] = '.5em';
549
550 if ( $iconShape === 'circle' ) {
551 $iconViewCSS['border-radius'] = '50px';
552 }
553 } elseif ( $iconType === 'framed' ) {
554 $iconViewCSS['background'] = 'transparent';
555 $iconViewCSS['padding'] = '.5em';
556 $iconViewCSS['border'] = '2px solid ' . ( $iconColor ? $iconColor : '#69727d' );
557
558 if ( $iconShape === 'circle' ) {
559 $iconViewCSS['border-radius'] = '50px';
560 }
561 }
562 }
563
564 // Apply size CSS if available
565 if ( $size ) {
566 $css['width'] = $size . 'px !important';
567 $css['height'] = $size . 'px !important';
568 }
569
570 // Apply icon color if available
571 if ( isset( $attributes['iconColor'] ) ) {
572 $css['fill'] = $attributes['iconColor'];
573 }
574
575 // Apply spacing based on position
576 if ( $spacing ) {
577 switch ( $iconPosition ) {
578 case 'left':
579 $css['margin-right'] = $spacing . 'px';
580 break;
581 case 'right':
582 $css['margin-left'] = $spacing . 'px';
583 break;
584 case 'bottom':
585 $css['margin-top'] = $spacing . 'px';
586 break;
587 case 'top':
588 $css['margin-bottom'] = $spacing . 'px';
589 break;
590 }
591 }
592 // Merge the icon view CSS with the main CSS
593 return array_merge( $css, $iconViewCSS );
594 }
595
596 public function get_tabs_active_icon_css( $attributes ) {
597 $css = [];
598
599 // Check for active icon color
600 if ( isset( $attributes['iconActiveColor'] ) ) {
601 $css['fill'] = $attributes['iconActiveColor'];
602 }
603
604 // Check for icon type and active background color
605 if ( isset( $attributes['iconType'] ) && $attributes['iconType'] !== 'default' && $attributes['iconType'] !== 'framed' ) {
606 if ( isset( $attributes['iconActiveBackground'] ) ) {
607 $css['background-color'] = $attributes['iconActiveBackground'];
608 }
609 }
610
611 return $css;
612 }
613
614 public function get_tabs_content_css( $attributes, $device = '' ) {
615 $tabs_content_css = [];
616
617 // Merge margin, padding, and border CSS
618 $tabs_content_css = array_merge(
619 $tabs_content_css,
620 Dimensions::get_css( $attributes['contentMargin'] ?? [], 'margin', $device ),
621 Dimensions::get_css( $attributes['contentPadding'] ?? [], 'padding', $device ),
622 Border::get_css( $attributes['contentBorder'] ?? [], '', $device )
623 );
624
625 // Apply background color if set
626 if ( isset( $attributes['contentBackgroundColor'] ) ) {
627 $tabs_content_css['background-color'] = $attributes['contentBackgroundColor'];
628 }
629
630 // Apply max-width based on device and tabsMenuPosition
631 if ( $device === 'Mobile' ) {
632 $tabs_content_css['max-width'] = '100%';
633 } else {
634 $menuPosition = $attributes['tabsMenuPositioning'][ 'value' . $device ] ?? '';
635 if ( $menuPosition === 'top' || $menuPosition === 'bottom' ) {
636 $tabs_content_css['max-width'] = '100% !important';
637 } elseif ( $menuPosition === 'left' || $menuPosition === 'right' ) {
638 $tabs_content_css['max-width'] = '70%';
639 $tabs_content_css['flex-grow'] = 3;
640 }
641 }
642
643 return $tabs_content_css;
644 }
645
646
647 public function get_tabs_content_hover_css( $attributes, $device = '' ) {
648 return array_merge(
649 Border::get_hover_css( $attributes['contentBorder'] ?? [], '', $device ),
650 );
651 }
652
653 public function get_content_css( $attributes, $device = '' ) {
654 $css = [];
655 return array_merge(
656 Range::get_css([
657 'attributeValue' => $attributes['contentGap'],
658 'attribute_object_key' => 'value',
659 'isResponsive' => true,
660 'defaultValue' => 10,
661 'hasUnit' => true,
662 'unitDefaultValue' => 'px',
663 'property' => 'gap',
664 'device' => $device,
665 ]),
666 $css,
667 );
668 }
669 public function get_tabs_width_css( $attributes, $device = '' ) {
670 $css = [];
671
672 if (
673 isset( $attributes['tabsMenuPositioning'][ 'value' . $device ] ) &&
674 (
675 $attributes['tabsMenuPositioning'][ 'value' . $device ] === 'top' ||
676 $attributes['tabsMenuPositioning'][ 'value' . $device ] === 'bottom'
677 )
678 ) {
679 $css['max-width'] = '100% !important';
680 }
681
682 return array_merge(
683 Range::get_css([
684 'attributeValue' => $attributes['tabsWidth'],
685 'attribute_object_key' => 'value',
686 'isResponsive' => true,
687 'defaultValue' => 30,
688 'hasUnit' => false,
689 'unitDefaultValue' => '%',
690 'property' => 'max-width',
691 'device' => $device,
692 ]),
693 $css,
694 );
695 }
696
697 public function get_content_width_css( $attributes, $device = '' ) {
698 $css = [];
699 if (
700 isset( $attributes['tabsMenuPositioning'][ 'value' . $device ] ) &&
701 (
702 $attributes['tabsMenuPositioning'][ 'value' . $device ] === 'top' ||
703 $attributes['tabsMenuPositioning'][ 'value' . $device ] === 'bottom'
704 )
705 ) {
706 $css['max-width'] = '100% !important';
707 }
708 return array_merge(
709 Range::get_css([
710 'attributeValue' => $attributes['contentWidth'],
711 'attribute_object_key' => 'value',
712 'isResponsive' => true,
713 'defaultValue' => 70,
714 'hasUnit' => false,
715 'unitDefaultValue' => '%',
716 'property' => 'max-width',
717 'device' => $device,
718 ]),
719 $css,
720 );
721 }
722
723 }
724