| @@ -1,0 +1,905 @@ | ||
| 1 | +<?php | |
| 2 | + | |
| 3 | +namespace ABlocks\Blocks\Tabs; | |
| 4 | + | |
| 5 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 6 | + exit; | |
| 7 | +} | |
| 8 | + | |
| 9 | +use ABlocks\Classes\BlockBaseAbstract; | |
| 10 | +use ABlocks\Classes\CssGenerator; | |
| 11 | +use ABlocks\Classes\CssGeneratorV2; | |
| 12 | +use ABlocks\Controls\Typography; | |
| 13 | +use ABlocks\Controls\Dimensions; | |
| 14 | +use ABlocks\Controls\Border; | |
| 15 | +use ABlocks\Controls\Icon; | |
| 16 | +use ABlocks\Controls\BoxShadow; | |
| 17 | +use ABlocks\Controls\Range; | |
| 18 | +use ABlocks\Controls\Color; | |
| 19 | + | |
| 20 | + | |
| 21 | +class Block extends BlockBaseAbstract { | |
| 22 | + | |
| 23 | + protected $block_name = 'tabs'; | |
| 24 | + | |
| 25 | + public function build_css_v1( $attributes ) { | |
| 26 | + $css_generator = new CssGenerator( $attributes, $this->block_name ); | |
| 27 | + | |
| 28 | + $css_generator->add_class_styles( | |
| 29 | + '{{WRAPPER}} .ablocks-block-tabs', | |
| 30 | + $this->get_tabs_css( $attributes ), | |
| 31 | + $this->get_tabs_css( $attributes, 'Tablet' ), | |
| 32 | + $this->get_tabs_css( $attributes, 'Mobile' ) | |
| 33 | + ); | |
| 34 | + $css_generator->add_class_styles( | |
| 35 | + '{{WRAPPER}} .ablocks-block-tabs__tab-panel', | |
| 36 | + $this->get_tabs_panel_css( $attributes ), | |
| 37 | + $this->get_tabs_panel_css( $attributes, 'Tablet' ), | |
| 38 | + $this->get_tabs_panel_css( $attributes, 'Mobile' ) | |
| 39 | + ); | |
| 40 | + | |
| 41 | + $css_generator->add_class_styles( | |
| 42 | + '{{WRAPPER}} .ablocks-block-tabs__tab-panel:hover', | |
| 43 | + $this->get_tabs_panel_hover_css( $attributes ), | |
| 44 | + $this->get_tabs_panel_hover_css( $attributes, 'Tablet' ), | |
| 45 | + $this->get_tabs_panel_hover_css( $attributes, 'Mobile' ) | |
| 46 | + ); | |
| 47 | + | |
| 48 | + $css_generator->add_class_styles( | |
| 49 | + '{{WRAPPER}} .ablocks-block-tabs__tab', | |
| 50 | + $this->get_tabs_menu_content_css( $attributes ), | |
| 51 | + $this->get_tabs_menu_content_css( $attributes, 'Tablet' ), | |
| 52 | + $this->get_tabs_menu_content_css( $attributes, 'Mobile' ) | |
| 53 | + ); | |
| 54 | + | |
| 55 | + $css_generator->add_class_styles( | |
| 56 | + '{{WRAPPER}} .ablocks-block-tabs__tab--active', | |
| 57 | + $this->get_tabs_menu_content_active_css( $attributes ), | |
| 58 | + $this->get_tabs_menu_content_active_css( $attributes, 'Tablet' ), | |
| 59 | + $this->get_tabs_menu_content_active_css( $attributes, 'Mobile' ) | |
| 60 | + ); | |
| 61 | + | |
| 62 | + $css_generator->add_class_styles( | |
| 63 | + '{{WRAPPER}} .ablocks-block-tabs__tab:hover', | |
| 64 | + $this->get_tabs_menu_content_hover_css( $attributes ), | |
| 65 | + $this->get_tabs_menu_content_hover_css( $attributes, 'Tablet' ), | |
| 66 | + $this->get_tabs_menu_content_hover_css( $attributes, 'Mobile' ) | |
| 67 | + ); | |
| 68 | + $css_generator->add_class_styles( | |
| 69 | + '{{WRAPPER}} .ablocks-block-tabs__tab-menu-title', | |
| 70 | + $this->get_tabs_title_css( $attributes ), | |
| 71 | + $this->get_tabs_title_css( $attributes, 'Tablet' ), | |
| 72 | + $this->get_tabs_title_css( $attributes, 'Mobile' ) | |
| 73 | + ); | |
| 74 | + | |
| 75 | + $css_generator->add_class_styles( | |
| 76 | + '{{WRAPPER}} .ablocks-block-tabs__tab--active .ablocks-block-tabs__tab-menu-title', | |
| 77 | + $this->get_tabs_active_title_css( $attributes ), | |
| 78 | + $this->get_tabs_active_title_css( $attributes, 'Tablet' ), | |
| 79 | + $this->get_tabs_active_title_css( $attributes, 'Mobile' ) | |
| 80 | + ); | |
| 81 | + | |
| 82 | + $css_generator->add_class_styles( | |
| 83 | + '{{WRAPPER}} .ablocks-block-tabs__tab-menu-subtitle', | |
| 84 | + $this->get_tabs_subtitle_css( $attributes ), | |
| 85 | + $this->get_tabs_subtitle_css( $attributes, 'Tablet' ), | |
| 86 | + $this->get_tabs_subtitle_css( $attributes, 'Mobile' ) | |
| 87 | + ); | |
| 88 | + | |
| 89 | + $css_generator->add_class_styles( | |
| 90 | + '{{WRAPPER}} .ablocks-block-tabs__tab--active .ablocks-block-tabs__tab-menu-subtitle', | |
| 91 | + $this->get_tabs_active_subtitle_text_css( $attributes ), | |
| 92 | + $this->get_tabs_active_subtitle_text_css( $attributes, 'Tablet' ), | |
| 93 | + $this->get_tabs_active_subtitle_text_css( $attributes, 'Mobile' ) | |
| 94 | + ); | |
| 95 | + if ( isset( $attributes['showActiveSubTitle'] ) && $attributes['showActiveSubTitle'] === false ) { | |
| 96 | + $css_generator->add_class_styles( | |
| 97 | + '{{WRAPPER}} .ablocks-block-tabs__icon', | |
| 98 | + $this->get_icon_position_css( $attributes ), | |
| 99 | + $this->get_icon_position_css( $attributes, 'Tablet' ), | |
| 100 | + $this->get_icon_position_css( $attributes, 'Mobile' ) | |
| 101 | + ); | |
| 102 | + } else { | |
| 103 | + $css_generator->add_class_styles( | |
| 104 | + '{{WRAPPER}} .ablocks-block-tabs__tab--active .ablocks-block-tabs__icon', | |
| 105 | + $this->get_icon_position_css( $attributes ), | |
| 106 | + $this->get_icon_position_css( $attributes, 'Tablet' ), | |
| 107 | + $this->get_icon_position_css( $attributes, 'Mobile' ) | |
| 108 | + ); | |
| 109 | + } | |
| 110 | + $css_generator->add_class_styles( | |
| 111 | + '{{WRAPPER}} .ablocks-block-tabs__tab--active .ablocks-block-tabs__progressbar', | |
| 112 | + $this->progress_bar_style_css( $attributes ), | |
| 113 | + $this->progress_bar_style_css( $attributes, 'Tablet' ), | |
| 114 | + $this->progress_bar_style_css( $attributes, 'Mobile' ) | |
| 115 | + ); | |
| 116 | + $tabs_element_icon_wrapper_styles = Icon::get_wrapper_css( $attributes ); | |
| 117 | + | |
| 118 | + $spacing_value = []; | |
| 119 | + | |
| 120 | + switch ( $attributes['iconPosition'] ) { | |
| 121 | + case 'left': | |
| 122 | + $spacing_value = Range::get_css([ | |
| 123 | + 'attributeValue' => $attributes['spacing'] ?? null, | |
| 124 | + 'attributeObjectKey' => 'value', | |
| 125 | + 'defaultValue' => 0, | |
| 126 | + 'isResponsive' => true, | |
| 127 | + 'hasUnit' => true, | |
| 128 | + 'property' => 'margin-right', | |
| 129 | + 'unitDefaultValue' => 'px', | |
| 130 | + ]); | |
| 131 | + break; | |
| 132 | + case 'right': | |
| 133 | + $spacing_value = Range::get_css([ | |
| 134 | + 'attributeValue' => $attributes['spacing'] ?? null, | |
| 135 | + 'attributeObjectKey' => 'value', | |
| 136 | + 'defaultValue' => 0, | |
| 137 | + 'isResponsive' => true, | |
| 138 | + 'hasUnit' => true, | |
| 139 | + 'property' => 'margin-left', | |
| 140 | + 'unitDefaultValue' => 'px', | |
| 141 | + ]); | |
| 142 | + break; | |
| 143 | + case 'bottom': | |
| 144 | + $spacing_value = Range::get_css([ | |
| 145 | + 'attributeValue' => $attributes['spacing'] ?? null, | |
| 146 | + 'attributeObjectKey' => 'value', | |
| 147 | + 'defaultValue' => 0, | |
| 148 | + 'isResponsive' => true, | |
| 149 | + 'hasUnit' => true, | |
| 150 | + 'property' => 'margin-top', | |
| 151 | + 'unitDefaultValue' => 'px', | |
| 152 | + ]); | |
| 153 | + break; | |
| 154 | + case 'top': | |
| 155 | + $spacing_value = Range::get_css([ | |
| 156 | + 'attributeValue' => $attributes['spacing'] ?? null, | |
| 157 | + 'attributeObjectKey' => 'value', | |
| 158 | + 'defaultValue' => 0, | |
| 159 | + 'isResponsive' => true, | |
| 160 | + 'hasUnit' => true, | |
| 161 | + 'property' => 'margin-bottom', | |
| 162 | + 'unitDefaultValue' => 'px', | |
| 163 | + ]); | |
| 164 | + break; | |
| 165 | + }//end switch | |
| 166 | + | |
| 167 | + // Merge $spacing_value into icon wrapper styles | |
| 168 | + $tabs_element_icon_wrapper_styles = array_merge( | |
| 169 | + Icon::get_wrapper_css( $attributes ), | |
| 170 | + $spacing_value | |
| 171 | + ); | |
| 172 | + | |
| 173 | + // Generate tablet and mobile styles for the icon wrapper | |
| 174 | + $tablet_styles = array_merge( | |
| 175 | + Icon::get_wrapper_css( $attributes, 'Tablet' ), | |
| 176 | + $spacing_value | |
| 177 | + ); | |
| 178 | + $mobile_styles = array_merge( | |
| 179 | + Icon::get_wrapper_css( $attributes, 'Mobile' ), | |
| 180 | + $spacing_value | |
| 181 | + ); | |
| 182 | + | |
| 183 | + // Add icon wrapper styles to the CSS generator | |
| 184 | + if ( ! empty( $tabs_element_icon_wrapper_styles ) || ! empty( $tablet_styles ) || ! empty( $mobile_styles ) ) { | |
| 185 | + $css_generator->add_class_styles( | |
| 186 | + '{{WRAPPER}} .ablocks-block-tabs__icon .ablocks-icon-wrap', | |
| 187 | + $tabs_element_icon_wrapper_styles, | |
| 188 | + $tablet_styles, | |
| 189 | + $mobile_styles | |
| 190 | + ); | |
| 191 | + } | |
| 192 | + $css_generator->add_class_styles( | |
| 193 | + '{{WRAPPER}} .ablocks-block-tabs__icon .ablocks-icon-wrap:hover', | |
| 194 | + Icon::get_wrapper_hover_css( $attributes ), | |
| 195 | + Icon::get_wrapper_hover_css( $attributes, 'Tablet' ), | |
| 196 | + Icon::get_wrapper_hover_css( $attributes, 'Mobile' ), | |
| 197 | + ); | |
| 198 | + | |
| 199 | + $css_generator->add_class_styles( | |
| 200 | + '{{WRAPPER}} .ablocks-block-tabs__icon .ablocks-icon-wrap img.ablocks-image-icon', | |
| 201 | + Icon::get_element_image_css( $attributes ), | |
| 202 | + Icon::get_element_image_css( $attributes, 'Tablet' ), | |
| 203 | + Icon::get_element_image_css( $attributes, 'Mobile' ), | |
| 204 | + ); | |
| 205 | + $css_generator->add_class_styles( | |
| 206 | + '{{WRAPPER}} .ablocks-block-tabs__icon .ablocks-icon-wrap img.ablocks-image-icon:hover', | |
| 207 | + Icon::get_element_image_hover_css( $attributes ), | |
| 208 | + Icon::get_element_image_hover_css( $attributes, 'Tablet' ), | |
| 209 | + Icon::get_element_image_hover_css( $attributes, 'Mobile' ), | |
| 210 | + ); | |
| 211 | + $css_generator->add_class_styles( | |
| 212 | + '{{WRAPPER}} .ablocks-block-tabs__icon .ablocks-icon-wrap svg.ablocks-svg-icon', | |
| 213 | + Icon::get_element_css( $attributes ), | |
| 214 | + Icon::get_element_css( $attributes, 'Tablet' ), | |
| 215 | + Icon::get_element_css( $attributes, 'Mobile' ), | |
| 216 | + ); | |
| 217 | + $css_generator->add_class_styles( | |
| 218 | + '{{WRAPPER}} .ablocks-block-tabs__icon .ablocks-icon-wrap svg.ablocks-svg-icon:hover', | |
| 219 | + Icon::get_element_image_hover_css( $attributes ), | |
| 220 | + Icon::get_element_image_hover_css( $attributes, 'Tablet' ), | |
| 221 | + Icon::get_element_image_hover_css( $attributes, 'Mobile' ), | |
| 222 | + ); | |
| 223 | + | |
| 224 | + $css_generator->add_class_styles( | |
| 225 | + '{{WRAPPER}} .ablocks-block-tabs__body', | |
| 226 | + $this->get_tabs_content_css( $attributes ), | |
| 227 | + $this->get_tabs_content_css( $attributes, 'Tablet' ), | |
| 228 | + $this->get_tabs_content_css( $attributes, 'Mobile' ) | |
| 229 | + ); | |
| 230 | + | |
| 231 | + $css_generator->add_class_styles( | |
| 232 | + '{{WRAPPER}} .ablocks-block-tabs__body:hover', | |
| 233 | + $this->get_tabs_content_hover_css( $attributes ), | |
| 234 | + $this->get_tabs_content_hover_css( $attributes, 'Tablet' ), | |
| 235 | + $this->get_tabs_content_hover_css( $attributes, 'Mobile' ) | |
| 236 | + ); | |
| 237 | + $css_generator->add_class_styles( | |
| 238 | + '{{WRAPPER}} .ablocks-block-tabs__tab-menu-content', | |
| 239 | + $this->get_content_css( $attributes ), | |
| 240 | + $this->get_content_css( $attributes, 'Tablet' ), | |
| 241 | + $this->get_content_css( $attributes, 'Mobile' ) | |
| 242 | + ); | |
| 243 | + $css_generator->add_class_styles( | |
| 244 | + '{{WRAPPER}} .ablocks-block-tabs__tab-panel', | |
| 245 | + $this->get_tabs_width_css( $attributes ), | |
| 246 | + $this->get_tabs_width_css( $attributes, 'Tablet' ), | |
| 247 | + $this->get_tabs_width_css( $attributes, 'Mobile' ) | |
| 248 | + ); | |
| 249 | + $css_generator->add_class_styles( | |
| 250 | + '{{WRAPPER}} .ablocks-block-tabs__body', | |
| 251 | + $this->get_content_width_css( $attributes ), | |
| 252 | + $this->get_content_width_css( $attributes, 'Tablet' ), | |
| 253 | + $this->get_content_width_css( $attributes, 'Mobile' ) | |
| 254 | + ); | |
| 255 | + | |
| 256 | + return $css_generator->generate_css(); | |
| 257 | + } | |
| 258 | + public function build_css_v2( $attributes ) { | |
| 259 | + $css_generator = new CssGeneratorV2( $attributes, $this->block_name ); | |
| 260 | + | |
| 261 | + $css_generator->add_class_styles( | |
| 262 | + '{{WRAPPER}} .ablocks-block-tabs', | |
| 263 | + $this->get_tabs_css( $attributes ), | |
| 264 | + $this->get_tabs_css( $attributes, 'Tablet' ), | |
| 265 | + $this->get_tabs_css( $attributes, 'Mobile' ) | |
| 266 | + ); | |
| 267 | + | |
| 268 | + $css_generator->add_class_styles( | |
| 269 | + '{{WRAPPER}} .ablocks-block-tabs__tab-panel', | |
| 270 | + $this->get_tabs_panel_css( $attributes ), | |
| 271 | + $this->get_tabs_panel_css( $attributes, 'Tablet' ), | |
| 272 | + $this->get_tabs_panel_css( $attributes, 'Mobile' ) | |
| 273 | + ); | |
| 274 | + | |
| 275 | + $css_generator->add_class_styles( | |
| 276 | + '{{WRAPPER}} .ablocks-block-tabs__tab-panel:hover', | |
| 277 | + $this->get_tabs_panel_hover_css( $attributes ), | |
| 278 | + $this->get_tabs_panel_hover_css( $attributes, 'Tablet' ), | |
| 279 | + $this->get_tabs_panel_hover_css( $attributes, 'Mobile' ) | |
| 280 | + ); | |
| 281 | + | |
| 282 | + $css_generator->add_class_styles( | |
| 283 | + '{{WRAPPER}} .ablocks-block-tabs__tab', | |
| 284 | + $this->get_tabs_menu_content_css( $attributes ), | |
| 285 | + $this->get_tabs_menu_content_css( $attributes, 'Tablet' ), | |
| 286 | + $this->get_tabs_menu_content_css( $attributes, 'Mobile' ) | |
| 287 | + ); | |
| 288 | + | |
| 289 | + $css_generator->add_class_styles( | |
| 290 | + '{{WRAPPER}} .ablocks-block-tabs__tab--active', | |
| 291 | + $this->get_tabs_menu_content_active_css( $attributes ), | |
| 292 | + $this->get_tabs_menu_content_active_css( $attributes, 'Tablet' ), | |
| 293 | + $this->get_tabs_menu_content_active_css( $attributes, 'Mobile' ) | |
| 294 | + ); | |
| 295 | + | |
| 296 | + $css_generator->add_class_styles( | |
| 297 | + '{{WRAPPER}} .ablocks-block-tabs__tab:hover', | |
| 298 | + $this->get_tabs_menu_content_hover_css( $attributes ), | |
| 299 | + $this->get_tabs_menu_content_hover_css( $attributes, 'Tablet' ), | |
| 300 | + $this->get_tabs_menu_content_hover_css( $attributes, 'Mobile' ) | |
| 301 | + ); | |
| 302 | + $css_generator->add_class_styles( | |
| 303 | + '{{WRAPPER}} .ablocks-block-tabs__tab-menu-title', | |
| 304 | + $this->get_tabs_title_css( $attributes ), | |
| 305 | + $this->get_tabs_title_css( $attributes, 'Tablet' ), | |
| 306 | + $this->get_tabs_title_css( $attributes, 'Mobile' ) | |
| 307 | + ); | |
| 308 | + | |
| 309 | + $css_generator->add_class_styles( | |
| 310 | + '{{WRAPPER}} .ablocks-block-tabs__tab--active .ablocks-block-tabs__tab-menu-title', | |
| 311 | + $this->get_tabs_active_title_css( $attributes ), | |
| 312 | + $this->get_tabs_active_title_css( $attributes, 'Tablet' ), | |
| 313 | + $this->get_tabs_active_title_css( $attributes, 'Mobile' ) | |
| 314 | + ); | |
| 315 | + | |
| 316 | + $css_generator->add_class_styles( | |
| 317 | + '{{WRAPPER}} .ablocks-block-tabs__tab-menu-subtitle', | |
| 318 | + $this->get_tabs_subtitle_css( $attributes ), | |
| 319 | + $this->get_tabs_subtitle_css( $attributes, 'Tablet' ), | |
| 320 | + $this->get_tabs_subtitle_css( $attributes, 'Mobile' ) | |
| 321 | + ); | |
| 322 | + | |
| 323 | + $css_generator->add_class_styles( | |
| 324 | + '{{WRAPPER}} .ablocks-block-tabs__tab--active .ablocks-block-tabs__tab-menu-subtitle', | |
| 325 | + $this->get_tabs_active_subtitle_text_css( $attributes ), | |
| 326 | + $this->get_tabs_active_subtitle_text_css( $attributes, 'Tablet' ), | |
| 327 | + $this->get_tabs_active_subtitle_text_css( $attributes, 'Mobile' ) | |
| 328 | + ); | |
| 329 | + if ( isset( $attributes['showActiveSubTitle'] ) && $attributes['showActiveSubTitle'] === false ) { | |
| 330 | + $css_generator->add_class_styles( | |
| 331 | + '{{WRAPPER}} .ablocks-block-tabs__icon', | |
| 332 | + $this->get_icon_position_css( $attributes ), | |
| 333 | + $this->get_icon_position_css( $attributes, 'Tablet' ), | |
| 334 | + $this->get_icon_position_css( $attributes, 'Mobile' ) | |
| 335 | + ); | |
| 336 | + } else { | |
| 337 | + $css_generator->add_class_styles( | |
| 338 | + '{{WRAPPER}} .ablocks-block-tabs__tab--active .ablocks-block-tabs__icon', | |
| 339 | + $this->get_icon_position_css( $attributes ), | |
| 340 | + $this->get_icon_position_css( $attributes, 'Tablet' ), | |
| 341 | + $this->get_icon_position_css( $attributes, 'Mobile' ) | |
| 342 | + ); | |
| 343 | + } | |
| 344 | + $css_generator->add_class_styles( | |
| 345 | + '{{WRAPPER}} .ablocks-block-tabs__tab--active .ablocks-block-tabs__progressbar', | |
| 346 | + $this->progress_bar_style_css( $attributes ), | |
| 347 | + $this->progress_bar_style_css( $attributes, 'Tablet' ), | |
| 348 | + $this->progress_bar_style_css( $attributes, 'Mobile' ) | |
| 349 | + ); | |
| 350 | + $css_generator->add_class_styles( | |
| 351 | + '{{WRAPPER}} .ablocks-block-tabs__icon .ablocks-icon-wrap', | |
| 352 | + Icon::get_wrapper_css( $attributes ), | |
| 353 | + Icon::get_wrapper_css( $attributes, 'Tablet' ), | |
| 354 | + Icon::get_wrapper_css( $attributes, 'Mobile' ) | |
| 355 | + ); | |
| 356 | + $css_generator->add_class_styles( | |
| 357 | + '{{WRAPPER}} .ablocks-block-tabs__icon .ablocks-icon-wrap:hover', | |
| 358 | + Icon::get_wrapper_hover_css( $attributes ), | |
| 359 | + Icon::get_wrapper_hover_css( $attributes, 'Tablet' ), | |
| 360 | + Icon::get_wrapper_hover_css( $attributes, 'Mobile' ), | |
| 361 | + ); | |
| 362 | + $css_generator->add_class_styles( | |
| 363 | + '{{WRAPPER}} .ablocks-block-tabs__icon .ablocks-icon-wrap', | |
| 364 | + $this->get_icon_spacing_css( $attributes ), | |
| 365 | + $this->get_icon_spacing_css( $attributes, 'Tablet' ), | |
| 366 | + $this->get_icon_spacing_css( $attributes, 'Mobile' ), | |
| 367 | + ); | |
| 368 | + | |
| 369 | + $css_generator->add_class_styles( | |
| 370 | + '{{WRAPPER}} .ablocks-block-tabs__icon .ablocks-icon-wrap img.ablocks-image-icon', | |
| 371 | + Icon::get_element_image_css( $attributes ), | |
| 372 | + Icon::get_element_image_css( $attributes, 'Tablet' ), | |
| 373 | + Icon::get_element_image_css( $attributes, 'Mobile' ), | |
| 374 | + ); | |
| 375 | + $css_generator->add_class_styles( | |
| 376 | + '{{WRAPPER}} .ablocks-block-tabs__icon .ablocks-icon-wrap img.ablocks-image-icon:hover', | |
| 377 | + Icon::get_element_image_hover_css( $attributes ), | |
| 378 | + Icon::get_element_image_hover_css( $attributes, 'Tablet' ), | |
| 379 | + Icon::get_element_image_hover_css( $attributes, 'Mobile' ), | |
| 380 | + ); | |
| 381 | + $css_generator->add_class_styles( | |
| 382 | + '{{WRAPPER}} .ablocks-block-tabs__icon .ablocks-icon-wrap svg.ablocks-svg-icon', | |
| 383 | + Icon::get_element_css( $attributes ), | |
| 384 | + Icon::get_element_css( $attributes, 'Tablet' ), | |
| 385 | + Icon::get_element_css( $attributes, 'Mobile' ), | |
| 386 | + ); | |
| 387 | + $css_generator->add_class_styles( | |
| 388 | + '{{WRAPPER}} .ablocks-block-tabs__icon .ablocks-icon-wrap svg.ablocks-svg-icon:hover', | |
| 389 | + Icon::get_element_image_hover_css( $attributes ), | |
| 390 | + Icon::get_element_image_hover_css( $attributes, 'Tablet' ), | |
| 391 | + Icon::get_element_image_hover_css( $attributes, 'Mobile' ), | |
| 392 | + ); | |
| 393 | + | |
| 394 | + $css_generator->add_class_styles( | |
| 395 | + '{{WRAPPER}} .ablocks-block-tabs__body', | |
| 396 | + $this->get_tabs_content_css( $attributes ), | |
| 397 | + $this->get_tabs_content_css( $attributes, 'Tablet' ), | |
| 398 | + $this->get_tabs_content_css( $attributes, 'Mobile' ) | |
| 399 | + ); | |
| 400 | + | |
| 401 | + $css_generator->add_class_styles( | |
| 402 | + '{{WRAPPER}} .ablocks-block-tabs__body:hover', | |
| 403 | + $this->get_tabs_content_hover_css( $attributes ), | |
| 404 | + $this->get_tabs_content_hover_css( $attributes, 'Tablet' ), | |
| 405 | + $this->get_tabs_content_hover_css( $attributes, 'Mobile' ) | |
| 406 | + ); | |
| 407 | + $css_generator->add_class_styles( | |
| 408 | + '{{WRAPPER}} .ablocks-block-tabs__tab-menu-content', | |
| 409 | + $this->get_content_css( $attributes ), | |
| 410 | + $this->get_content_css( $attributes, 'Tablet' ), | |
| 411 | + $this->get_content_css( $attributes, 'Mobile' ) | |
| 412 | + ); | |
| 413 | + $css_generator->add_class_styles( | |
| 414 | + '{{WRAPPER}} .ablocks-block-tabs__tab-panel', | |
| 415 | + $this->get_tabs_width_css( $attributes ), | |
| 416 | + $this->get_tabs_width_css( $attributes, 'Tablet' ), | |
| 417 | + $this->get_tabs_width_css( $attributes, 'Mobile' ) | |
| 418 | + ); | |
| 419 | + $css_generator->add_class_styles( | |
| 420 | + '{{WRAPPER}} .ablocks-block-tabs__body', | |
| 421 | + $this->get_content_width_css( $attributes ), | |
| 422 | + $this->get_content_width_css( $attributes, 'Tablet' ), | |
| 423 | + $this->get_content_width_css( $attributes, 'Mobile' ) | |
| 424 | + ); | |
| 425 | + | |
| 426 | + return $css_generator->generate_css(); | |
| 427 | + } | |
| 428 | + | |
| 429 | + public function build_css( $attributes ) { | |
| 430 | + if ( isset( $attributes['blockVersion'] ) && (int) $attributes['blockVersion'] === 2 ) { | |
| 431 | + return $this->build_css_v2( $attributes ); | |
| 432 | + } | |
| 433 | + return $this->build_css_v1( $attributes ); | |
| 434 | + } | |
| 435 | + | |
| 436 | + | |
| 437 | + public function get_tabs_css( $attributes, $device = '' ) { | |
| 438 | + $tabs_css = []; | |
| 439 | + $menuPosition = $attributes['tabsMenuPositioning'][ 'value' . $device ] ?? ''; | |
| 440 | + | |
| 441 | + if ( $menuPosition === 'top' ) { | |
| 442 | + $tabs_css['flex-direction'] = 'column'; | |
| 443 | + } elseif ( $menuPosition === 'bottom' ) { | |
| 444 | + $tabs_css['flex-direction'] = 'column-reverse'; | |
| 445 | + } elseif ( $menuPosition === 'left' ) { | |
| 446 | + $tabs_css['flex-direction'] = 'row'; | |
| 447 | + } elseif ( $menuPosition === 'right' ) { | |
| 448 | + $tabs_css['flex-direction'] = 'row-reverse'; | |
| 449 | + } | |
| 450 | + return $tabs_css; | |
| 451 | + } | |
| 452 | + | |
| 453 | + public function get_tabs_panel_css( $attributes, $device = '' ) { | |
| 454 | + $tabs_panel_css = []; | |
| 455 | + | |
| 456 | + $tabMenuAlignment = ! empty( $attributes['tabMenuAlignment'][ 'value' . $device ] ) ? $attributes['tabMenuAlignment'][ 'value' . $device ] : ''; | |
| 457 | + $tabsMenuPositioning = $this->get_responsive_attribute_value( $attributes['tabsMenuPositioning'], $device ); | |
| 458 | + $tabsMenuDirection = $this->get_responsive_attribute_value( $attributes['tabsMenuDirection'], $device ); | |
| 459 | + | |
| 460 | + // Handle tabMenuAlign for the given device | |
| 461 | + if ( $tabsMenuPositioning === 'top' || $tabsMenuPositioning === 'bottom' ) { | |
| 462 | + if ( $tabsMenuDirection === 'row' ) { | |
| 463 | + $tabs_panel_css['justify-content'] = $tabMenuAlignment; | |
| 464 | + } elseif ( $tabsMenuDirection === 'column' ) { | |
| 465 | + $tabs_panel_css['align-items'] = $tabMenuAlignment; | |
| 466 | + } | |
| 467 | + if ( $tabMenuAlignment && $attributes['tabsWidthType'][ 'value' . $device ] === 'auto' ) { | |
| 468 | + if ( $tabMenuAlignment === 'flex-start' ) { | |
| 469 | + $tabs_panel_css['margin-right'] = 'auto'; | |
| 470 | + } elseif ( $tabMenuAlignment === 'center' ) { | |
| 471 | + $tabs_panel_css['margin-inline'] = 'auto'; | |
| 472 | + }if ( $tabMenuAlignment === 'flex-end' ) { | |
| 473 | + $tabs_panel_css['margin-left'] = 'auto'; | |
| 474 | + } | |
| 475 | + } | |
| 476 | + } | |
| 477 | + | |
| 478 | + if ( $tabsMenuPositioning === 'left' || $tabsMenuPositioning === 'right' ) { | |
| 479 | + $tabs_panel_css['flex-direction'] = 'column'; | |
| 480 | + } elseif ( $tabsMenuPositioning === 'top' || $tabsMenuPositioning === 'bottom' ) { | |
| 481 | + $tabs_panel_css['flex-direction'] = $tabsMenuDirection; | |
| 482 | + if ( ! empty( $attributes['tabWrap'][ 'value' . $device ] ) ) { | |
| 483 | + $tabs_panel_css['flex-wrap'] = $attributes['tabWrap'][ 'value' . $device ]; | |
| 484 | + } | |
| 485 | + } | |
| 486 | + | |
| 487 | + return array_merge( | |
| 488 | + $tabs_panel_css, | |
| 489 | + [ 'background' => Color::get_css( isset( $attributes['tabMenusBackgroundColor'] ) ? $attributes['tabMenusBackgroundColor'] : '' ) ], | |
| 490 | + Dimensions::get_css( $attributes['tabMenusMargin'] ?? [], 'margin', $device ), | |
| 491 | + Dimensions::get_css( $attributes['tabMenusPadding'] ?? [], 'padding', $device ), | |
| 492 | + Border::get_css( $attributes['tabMenusBorder'] ?? [], '', $device ), | |
| 493 | + Range::get_css([ | |
| 494 | + 'attributeValue' => $attributes['tabsGap'], | |
| 495 | + 'attribute_object_key' => 'value', | |
| 496 | + 'isResponsive' => true, | |
| 497 | + 'defaultValue' => 10, | |
| 498 | + 'hasUnit' => true, | |
| 499 | + 'unitDefaultValue' => 'px', | |
| 500 | + 'property' => 'gap', | |
| 501 | + 'device' => $device, | |
| 502 | + ]), | |
| 503 | + ); | |
| 504 | + } | |
| 505 | + | |
| 506 | + public function get_tabs_panel_hover_css( $attributes, $device = '' ) { | |
| 507 | + | |
| 508 | + return array_merge( | |
| 509 | + Border::get_hover_css( $attributes['tabMenusBorder'] ?? [], '', $device ), | |
| 510 | + ); | |
| 511 | + } | |
| 512 | + | |
| 513 | + public function get_tabs_menu_content_css( $attributes, $device = '' ) { | |
| 514 | + $css = []; | |
| 515 | + $css['display'] = 'flex'; | |
| 516 | + | |
| 517 | + $iconPosition = $this->get_responsive_attribute_value( $attributes['iconPosition'], $device ); | |
| 518 | + $tabsMenuPositioning = $this->get_responsive_attribute_value( $attributes['tabsMenuPositioning'], $device ); | |
| 519 | + $tabsContentWidthType = ! empty( $attributes['tabsContentWidthType'][ 'value' . $device ] ) ? $attributes['tabsContentWidthType'][ 'value' . $device ] : ''; | |
| 520 | + $tabsMenuDirection = ! empty( $attributes['tabsMenuDirection'][ 'value' . $device ] ) ? $attributes['tabsMenuDirection'][ 'value' . $device ] : ''; | |
| 521 | + | |
| 522 | + if ( ( $tabsMenuPositioning === 'top' || $tabsMenuPositioning === 'bottom' ) && $tabsContentWidthType === '100%' ) { | |
| 523 | + $css['width'] = '100%'; | |
| 524 | + } | |
| 525 | + | |
| 526 | + // Handling icon position | |
| 527 | + if ( $iconPosition === 'top' ) { | |
| 528 | + $css['flex-direction'] = 'column'; | |
| 529 | + if ( isset( $attributes['menuContentAlignment'][ 'value' . $device ] ) ) { | |
| 530 | + $css['align-items'] = $attributes['menuContentAlignment'][ 'value' . $device ]; | |
| 531 | + } | |
| 532 | + } | |
| 533 | + if ( $iconPosition === 'bottom' ) { | |
| 534 | + $css['flex-direction'] = 'column-reverse'; | |
| 535 | + if ( isset( $attributes['menuContentAlignment'][ 'value' . $device ] ) ) { | |
| 536 | + $css['align-items'] = $attributes['menuContentAlignment'][ 'value' . $device ]; | |
| 537 | + } | |
| 538 | + } | |
| 539 | + if ( $iconPosition === 'left' ) { | |
| 540 | + $css['flex-direction'] = 'row'; | |
| 541 | + $css['align-items'] = 'center'; | |
| 542 | + if ( isset( $attributes['menuContentAlignment'][ 'value' . $device ] ) ) { | |
| 543 | + $css['justify-content'] = $attributes['menuContentAlignment'][ 'value' . $device ]; | |
| 544 | + } | |
| 545 | + } | |
| 546 | + if ( $iconPosition === 'right' ) { | |
| 547 | + $css['flex-direction'] = 'row-reverse'; | |
| 548 | + $css['align-items'] = 'center'; | |
| 549 | + if ( isset( $attributes['menuContentAlignment'][ 'value' . $device ] ) ) { | |
| 550 | + $css['justify-content'] = $attributes['menuContentAlignment'][ 'value' . $device ]; | |
| 551 | + } | |
| 552 | + } | |
| 553 | + | |
| 554 | + // Merging with margin, padding, and border styles | |
| 555 | + return array_merge( | |
| 556 | + [ 'background' => Color::get_css( isset( $attributes['tabBackgroundColor'] ) ? $attributes['tabBackgroundColor'] : '' ) ], | |
| 557 | + $css, | |
| 558 | + Dimensions::get_css( $attributes['menuContentPadding'] ?? [], 'padding', $device ), | |
| 559 | + Border::get_css( $attributes['menuContentBorder'] ?? [], '', $device ), | |
| 560 | + BoxShadow::get_css( $attributes['boxShadow'], '', $device ), | |
| 561 | + ); | |
| 562 | + } | |
| 563 | + | |
| 564 | + | |
| 565 | + public function get_tabs_menu_content_active_css( $attributes, $device = '' ) { | |
| 566 | + $tabs_menu_content_active_css = []; | |
| 567 | + | |
| 568 | + if ( isset( $attributes['activeColorOptions'] ) && $attributes['activeColorOptions'] === 'background' ) { | |
| 569 | + if ( isset( $attributes['tabActiveBackgroundColor'] ) ) { | |
| 570 | + $tabs_menu_content_active_css['background-color'] = Color::get_css( isset( $attributes['tabActiveBackgroundColor'] ) ? $attributes['tabActiveBackgroundColor'] : '' ) . ' !important'; | |
| 571 | + } | |
| 572 | + } elseif ( isset( $attributes['activeColorOptions'] ) && $attributes['activeColorOptions'] === 'border' ) { | |
| 573 | + if ( isset( $attributes['activeBorderColor'] ) ) { | |
| 574 | + $tabs_menu_content_active_css['border-color'] = Color::get_css( isset( $attributes['activeBorderColor'] ) ? $attributes['activeBorderColor'] : '' ) . ' !important'; | |
| 575 | + } | |
| 576 | + } | |
| 577 | + | |
| 578 | + return $tabs_menu_content_active_css; | |
| 579 | + } | |
| 580 | + | |
| 581 | + | |
| 582 | + public function get_tabs_menu_content_hover_css( $attributes, $device = '' ) { | |
| 583 | + | |
| 584 | + return array_merge( | |
| 585 | + Border::get_hover_css( $attributes['menuContentBorder'] ?? [], '', $device ), | |
| 586 | + BoxShadow::get_hover_css( $attributes['boxShadow'], '', $device ) | |
| 587 | + ); | |
| 588 | + } | |
| 589 | + public function get_tabs_title_css( $attributes, $device = '' ) { | |
| 590 | + $typographyValueGlobal = ! empty( $attributes['titleTypographyGlobal'] ) ? $attributes['titleTypographyGlobal'] : []; | |
| 591 | + return array_merge( | |
| 592 | + [ 'color' => Color::get_css( isset( $attributes['titleTextColor'] ) ? $attributes['titleTextColor'] : '' ) ], | |
| 593 | + Typography::get_css( $attributes['titleTypography'] ?? [], '', $device, $typographyValueGlobal )); | |
| 594 | + } | |
| 595 | + | |
| 596 | + public function get_tabs_active_title_css( $attributes, $device = '' ) { | |
| 597 | + | |
| 598 | + return [ 'color' => Color::get_css( isset( $attributes['titleTextActiveColor'] ) ? $attributes['titleTextActiveColor'] : '' ) ]; | |
| 599 | + } | |
| 600 | + | |
| 601 | + public function get_tabs_subtitle_css( $attributes, $device = '' ) { | |
| 602 | + $tabsSubtitleCSS = []; | |
| 603 | + if ( isset( $attributes['showActiveSubTitle'] ) && $attributes['showActiveSubTitle'] === true ) { | |
| 604 | + $tabsSubtitleCSS['display'] = 'none'; | |
| 605 | + } | |
| 606 | + // Get typography styles | |
| 607 | + $typographyValueGlobal = ! empty( $attributes['subTitleTypographyGlobal'] ) ? $attributes['subTitleTypographyGlobal'] : []; | |
| 608 | + $typographyStyles = Typography::get_css( $attributes['subTitleTypography'] ?? [], '', $device, $typographyValueGlobal ); | |
| 609 | + $tabsSubtitleCSS = array_merge( $tabsSubtitleCSS, $typographyStyles ); | |
| 610 | + | |
| 611 | + // Determine width based on menu position | |
| 612 | + $tabsContentWidthType = $this->get_responsive_attribute_value( $attributes['tabsContentWidthType'], $device ); | |
| 613 | + $position = $this->get_responsive_attribute_value( $attributes['tabsMenuPositioning'], $device ); | |
| 614 | + if ( $device === 'Mobile' ) { | |
| 615 | + $tabsSubtitleCSS['width'] = '100%'; | |
| 616 | + } elseif ( ( $position === 'top' || $position === 'bottom' ) && $tabsContentWidthType === 'auto' ) { | |
| 617 | + $tabsSubtitleCSS['max-width'] = '160px'; | |
| 618 | + } | |
| 619 | + | |
| 620 | + return array_merge( | |
| 621 | + [ 'color' => Color::get_css( isset( $attributes['subTitleTextColor'] ) ? $attributes['subTitleTextColor'] : '' ) ], | |
| 622 | + $tabsSubtitleCSS | |
| 623 | + ); | |
| 624 | + } | |
| 625 | + | |
| 626 | + | |
| 627 | + public function get_tabs_active_subtitle_text_css( $attributes, $device = '' ) { | |
| 628 | + $css = []; | |
| 629 | + if ( isset( $attributes['showActiveSubTitle'] ) && $attributes['showActiveSubTitle'] === true ) { | |
| 630 | + $css['display'] = 'block'; | |
| 631 | + } | |
| 632 | + if ( isset( $attributes['subTitleTextActiveColor'] ) ) { | |
| 633 | + $css['color'] = Color::get_css( isset( $attributes['subTitleTextActiveColor'] ) ? $attributes['subTitleTextActiveColor'] : '' ) . '!important'; | |
| 634 | + } | |
| 635 | + return $css; | |
| 636 | + } | |
| 637 | + public function get_icon_position_css( $attributes, $device = '' ) { | |
| 638 | + return array_merge( | |
| 639 | + Dimensions::get_css( $attributes['iconPositionMargin'] ?? [], 'margin', $device ) | |
| 640 | + ); | |
| 641 | + } | |
| 642 | + public function progress_bar_style_css( $attributes, $device = '' ) { | |
| 643 | + return [ 'background' => Color::get_css( isset( $attributes['progressBarColor'] ) ? $attributes['progressBarColor'] : '' ) ]; | |
| 644 | + } | |
| 645 | + | |
| 646 | + public function get_tabs_icon_css( $attributes, $device = '' ) { | |
| 647 | + $css = []; | |
| 648 | + $iconType = $attributes['iconType'] ?? 'default'; | |
| 649 | + $iconShape = $attributes['iconShape'] ?? 'square'; | |
| 650 | + $iconColor = $attributes['iconColor'] ?? '#69727d'; | |
| 651 | + $iconBackground = $attributes['iconBackground'] ?? 'transparent'; | |
| 652 | + $size = $attributes['size'][ 'value' . $device ] ?? null; | |
| 653 | + $spacing = $attributes['spacing'][ 'value' . $device ] ?? null; | |
| 654 | + $iconPosition = $attributes['iconPosition'] ?? ''; | |
| 655 | + | |
| 656 | + // Determine icon view CSS based on type and shape | |
| 657 | + $iconViewCSS = []; | |
| 658 | + | |
| 659 | + if ( $iconType !== 'default' ) { | |
| 660 | + if ( $iconType === 'stacked' ) { | |
| 661 | + $iconViewCSS['background'] = $iconBackground; | |
| 662 | + $iconViewCSS['padding'] = '.5em'; | |
| 663 | + | |
| 664 | + if ( $iconShape === 'circle' ) { | |
| 665 | + $iconViewCSS['border-radius'] = '50px'; | |
| 666 | + } | |
| 667 | + } elseif ( $iconType === 'framed' ) { | |
| 668 | + $iconViewCSS['background'] = 'transparent'; | |
| 669 | + $iconViewCSS['padding'] = '.5em'; | |
| 670 | + $iconViewCSS['border'] = '2px solid ' . ( $iconColor ? $iconColor : '#69727d' ); | |
| 671 | + | |
| 672 | + if ( $iconShape === 'circle' ) { | |
| 673 | + $iconViewCSS['border-radius'] = '50px'; | |
| 674 | + } | |
| 675 | + } | |
| 676 | + } | |
| 677 | + | |
| 678 | + // Apply size CSS if available | |
| 679 | + if ( $size ) { | |
| 680 | + $css['width'] = $size . 'px !important'; | |
| 681 | + $css['height'] = $size . 'px !important'; | |
| 682 | + } | |
| 683 | + // Apply spacing based on position | |
| 684 | + if ( $spacing ) { | |
| 685 | + switch ( $iconPosition ) { | |
| 686 | + case 'left': | |
| 687 | + $css['margin-right'] = $spacing . 'px'; | |
| 688 | + break; | |
| 689 | + case 'right': | |
| 690 | + $css['margin-left'] = $spacing . 'px'; | |
| 691 | + break; | |
| 692 | + case 'bottom': | |
| 693 | + $css['margin-top'] = $spacing . 'px'; | |
| 694 | + break; | |
| 695 | + case 'top': | |
| 696 | + $css['margin-bottom'] = $spacing . 'px'; | |
| 697 | + break; | |
| 698 | + } | |
| 699 | + } | |
| 700 | + // Merge the icon view CSS with the main CSS | |
| 701 | + return array_merge( | |
| 702 | + [ 'fill' => Color::get_css( isset( $attributes['iconColor'] ) ? $attributes['iconColor'] : '' ) ], | |
| 703 | + $css, | |
| 704 | + $iconViewCSS ); | |
| 705 | + } | |
| 706 | + | |
| 707 | + public function get_tabs_active_icon_css( $attributes ) { | |
| 708 | + $css = []; | |
| 709 | + | |
| 710 | + // Check for active icon color | |
| 711 | + if ( isset( $attributes['iconActiveColor'] ) ) { | |
| 712 | + $css['fill'] = Color::get_css( isset( $attributes['iconActiveColor'] ) ? $attributes['iconActiveColor'] : '' ); | |
| 713 | + } | |
| 714 | + | |
| 715 | + // Check for icon type and active background color | |
| 716 | + if ( isset( $attributes['iconType'] ) && $attributes['iconType'] !== 'default' && $attributes['iconType'] !== 'framed' ) { | |
| 717 | + $css['background-color'] = Color::get_css( isset( $attributes['iconActiveBackground'] ) ? $attributes['iconActiveBackground'] : '' ); | |
| 718 | + } | |
| 719 | + | |
| 720 | + return $css; | |
| 721 | + } | |
| 722 | + | |
| 723 | + public function get_tabs_content_css( $attributes, $device = '' ) { | |
| 724 | + $tabs_content_css = []; | |
| 725 | + // Merge margin, padding, and border CSS | |
| 726 | + $tabs_content_css = array_merge( | |
| 727 | + [ 'background' => Color::get_css( isset( $attributes['contentBackgroundColor'] ) ? $attributes['contentBackgroundColor'] : '' ) ], | |
| 728 | + $tabs_content_css, | |
| 729 | + Dimensions::get_css( $attributes['contentMargin'] ?? [], 'margin', $device ), | |
| 730 | + Dimensions::get_css( $attributes['contentPadding'] ?? [], 'padding', $device ), | |
| 731 | + Border::get_css( $attributes['contentBorder'] ?? [], '', $device ) | |
| 732 | + ); | |
| 733 | + // Apply max-width based on device and tabsMenuPosition | |
| 734 | + if ( $device === 'Mobile' ) { | |
| 735 | + $tabs_content_css['max-width'] = '100%'; | |
| 736 | + } else { | |
| 737 | + $menuPosition = $attributes['tabsMenuPositioning'][ 'value' . $device ] ?? ''; | |
| 738 | + if ( $menuPosition === 'top' || $menuPosition === 'bottom' ) { | |
| 739 | + $tabs_content_css['max-width'] = '100% !important'; | |
| 740 | + } elseif ( $menuPosition === 'left' || $menuPosition === 'right' ) { | |
| 741 | + $tabs_content_css['max-width'] = '70%'; | |
| 742 | + $tabs_content_css['flex-grow'] = 3; | |
| 743 | + } | |
| 744 | + } | |
| 745 | + | |
| 746 | + return $tabs_content_css; | |
| 747 | + } | |
| 748 | + | |
| 749 | + | |
| 750 | + public function get_tabs_content_hover_css( $attributes, $device = '' ) { | |
| 751 | + return array_merge( | |
| 752 | + Border::get_hover_css( $attributes['contentBorder'] ?? [], '', $device ), | |
| 753 | + ); | |
| 754 | + } | |
| 755 | + | |
| 756 | + public function get_content_css( $attributes, $device = '' ) { | |
| 757 | + $css = []; | |
| 758 | + if ( isset( $attributes['menuContentAlignment'][ 'value' . $device ] ) ) { | |
| 759 | + $css['text-align'] = $attributes['menuContentAlignment'][ 'value' . $device ]; | |
| 760 | + } | |
| 761 | + return array_merge( | |
| 762 | + Range::get_css([ | |
| 763 | + 'attributeValue' => $attributes['contentGap'], | |
| 764 | + 'attribute_object_key' => 'value', | |
| 765 | + 'isResponsive' => true, | |
| 766 | + 'defaultValue' => 10, | |
| 767 | + 'hasUnit' => true, | |
| 768 | + 'unitDefaultValue' => 'px', | |
| 769 | + 'property' => 'gap', | |
| 770 | + 'device' => $device, | |
| 771 | + ]), | |
| 772 | + $css, | |
| 773 | + ); | |
| 774 | + } | |
| 775 | + public function get_tabs_width_css( $attributes, $device = '' ) { | |
| 776 | + $css = []; | |
| 777 | + | |
| 778 | + $tabsWidthType = $this->get_responsive_attribute_value( $attributes['tabsWidthType'], $device ); | |
| 779 | + $tabsMenuPositioning = $this->get_responsive_attribute_value( $attributes['tabsMenuPositioning'], $device ); | |
| 780 | + | |
| 781 | + if ( | |
| 782 | + $tabsMenuPositioning === 'top' || | |
| 783 | + $tabsMenuPositioning === 'bottom' | |
| 784 | + ) { | |
| 785 | + $css['width'] = $tabsWidthType; | |
| 786 | + return $css; | |
| 787 | + } | |
| 788 | + | |
| 789 | + if ( | |
| 790 | + $tabsMenuPositioning === 'left' || | |
| 791 | + $tabsMenuPositioning === 'right' | |
| 792 | + ) { | |
| 793 | + return array_merge( | |
| 794 | + Range::get_css([ | |
| 795 | + 'attributeValue' => $attributes['tabsWidth'], | |
| 796 | + 'attribute_object_key' => 'value', | |
| 797 | + 'isResponsive' => true, | |
| 798 | + 'defaultValue' => 30, | |
| 799 | + 'hasUnit' => false, | |
| 800 | + 'unitDefaultValue' => '%', | |
| 801 | + 'property' => 'width', | |
| 802 | + 'device' => $device, | |
| 803 | + ]), | |
| 804 | + ); | |
| 805 | + } | |
| 806 | + } | |
| 807 | + | |
| 808 | + public function get_content_width_css( $attributes, $device = '' ) { | |
| 809 | + $css = []; | |
| 810 | + if ( | |
| 811 | + isset( $attributes['tabsMenuPositioning'][ 'value' . $device ] ) && | |
| 812 | + ( | |
| 813 | + $attributes['tabsMenuPositioning'][ 'value' . $device ] === 'top' || | |
| 814 | + $attributes['tabsMenuPositioning'][ 'value' . $device ] === 'bottom' | |
| 815 | + ) | |
| 816 | + ) { | |
| 817 | + $css['max-width'] = '100% !important'; | |
| 818 | + } | |
| 819 | + return array_merge( | |
| 820 | + Range::get_css([ | |
| 821 | + 'attributeValue' => $attributes['contentWidth'], | |
| 822 | + 'attribute_object_key' => 'value', | |
| 823 | + 'isResponsive' => true, | |
| 824 | + 'defaultValue' => 70, | |
| 825 | + 'hasUnit' => false, | |
| 826 | + 'unitDefaultValue' => '%', | |
| 827 | + 'property' => 'max-width', | |
| 828 | + 'device' => $device, | |
| 829 | + ]), | |
| 830 | + $css, | |
| 831 | + ); | |
| 832 | + } | |
| 833 | + public function get_icon_spacing_css( $attributes, $device = '' ) { | |
| 834 | + $spacing_css = []; | |
| 835 | + | |
| 836 | + if ( isset( $attributes['iconPosition'][ 'value' . $device ] ) ) { | |
| 837 | + $position = $attributes['iconPosition'][ 'value' . $device ]; | |
| 838 | + | |
| 839 | + if ( $position === 'left' ) { | |
| 840 | + $spacing_css = Range::get_css([ | |
| 841 | + 'attributeValue' => $attributes['spacing'] ?? null, | |
| 842 | + 'attributeObjectKey' => 'value', | |
| 843 | + 'defaultValue' => 0, | |
| 844 | + 'isResponsive' => true, | |
| 845 | + 'hasUnit' => true, | |
| 846 | + 'property' => 'margin-right', | |
| 847 | + 'unitDefaultValue' => 'px', | |
| 848 | + ]); | |
| 849 | + } elseif ( $position === 'right' ) { | |
| 850 | + $spacing_css = Range::get_css([ | |
| 851 | + 'attributeValue' => $attributes['spacing'] ?? null, | |
| 852 | + 'attributeObjectKey' => 'value', | |
| 853 | + 'defaultValue' => 0, | |
| 854 | + 'isResponsive' => true, | |
| 855 | + 'hasUnit' => true, | |
| 856 | + 'property' => 'margin-left', | |
| 857 | + 'unitDefaultValue' => 'px', | |
| 858 | + ]); | |
| 859 | + } elseif ( $position === 'bottom' ) { | |
| 860 | + $spacing_css = Range::get_css([ | |
| 861 | + 'attributeValue' => $attributes['spacing'] ?? null, | |
| 862 | + 'attributeObjectKey' => 'value', | |
| 863 | + 'defaultValue' => 0, | |
| 864 | + 'isResponsive' => true, | |
| 865 | + 'hasUnit' => true, | |
| 866 | + 'property' => 'margin-top', | |
| 867 | + 'unitDefaultValue' => 'px', | |
| 868 | + ]); | |
| 869 | + } elseif ( $position === 'top' ) { | |
| 870 | + $spacing_css = Range::get_css([ | |
| 871 | + 'attributeValue' => $attributes['spacing'] ?? null, | |
| 872 | + 'attributeObjectKey' => 'value', | |
| 873 | + 'defaultValue' => 0, | |
| 874 | + 'isResponsive' => true, | |
| 875 | + 'hasUnit' => true, | |
| 876 | + 'property' => 'margin-bottom', | |
| 877 | + 'unitDefaultValue' => 'px', | |
| 878 | + ]); | |
| 879 | + }//end if | |
| 880 | + }//end if | |
| 881 | + | |
| 882 | + return $spacing_css; | |
| 883 | + } | |
| 884 | + | |
| 885 | + // don't delete this function, it's used in the render method to get responsive attribute values | |
| 886 | + public function get_responsive_attribute_value( $attribute, $device ) { | |
| 887 | + | |
| 888 | + if ( $device === 'Mobile' ) { | |
| 889 | + return ! empty( $attribute['valueMobile'] ) ? $attribute['valueMobile'] | |
| 890 | + : ( ! empty( $attribute['valueTablet'] ) ? $attribute['valueTablet'] | |
| 891 | + : ( $attribute['value'] ?? '' ) ); | |
| 892 | + } | |
| 893 | + | |
| 894 | + if ( $device === 'Tablet' ) { | |
| 895 | + return ! empty( $attribute['valueTablet'] ) ? $attribute['valueTablet'] | |
| 896 | + : ( $attribute['value'] ?? '' ); | |
| 897 | + } | |
| 898 | + | |
| 899 | + // Default (Desktop or others) | |
| 900 | + return $attribute['value'] ?? ''; | |
| 901 | + } | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | +} | |