| 1 |
<?php |
| 2 |
namespace ABlocks\Blocks\InfoBox; |
| 3 |
|
| 4 |
if ( ! defined( 'ABSPATH' ) ) { |
| 5 |
exit; |
| 6 |
} |
| 7 |
|
| 8 |
use ABlocks\Classes\BlockBaseAbstract; |
| 9 |
use ABlocks\Classes\CssGenerator; |
| 10 |
use ABlocks\Controls\Alignment; |
| 11 |
use ABlocks\Controls\Typography; |
| 12 |
use ABlocks\Controls\TextShadow; |
| 13 |
use ABlocks\Controls\TextStroke; |
| 14 |
use ABlocks\Controls\Border; |
| 15 |
use ABlocks\Controls\Dimensions; |
| 16 |
use ABlocks\Controls\Icon; |
| 17 |
use ABlocks\Controls\Range; |
| 18 |
|
| 19 |
class Block extends BlockBaseAbstract { |
| 20 |
protected $block_name = 'info-box'; |
| 21 |
|
| 22 |
public function build_css( $attributes ) { |
| 23 |
$css_generator = new CssGenerator( $attributes, $this->block_name ); |
| 24 |
$css_generator->add_class_styles( |
| 25 |
'{{WRAPPER}}', |
| 26 |
$this->get_wrapper_css( $attributes ), |
| 27 |
$this->get_wrapper_css( $attributes, 'Tablet' ), |
| 28 |
$this->get_wrapper_css( $attributes, 'Mobile' ) |
| 29 |
); |
| 30 |
|
| 31 |
$css_generator->add_class_styles( |
| 32 |
'{{WRAPPER}}.ablocks-block--info-box > .ablocks-block-container', |
| 33 |
$this->get_info_box( $attributes ), |
| 34 |
$this->get_info_box( $attributes, 'Tablet' ), |
| 35 |
$this->get_info_box( $attributes, 'Mobile' ) |
| 36 |
); |
| 37 |
$css_generator->add_class_styles( |
| 38 |
'{{WRAPPER}}.ablocks-block--info-box > .ablocks-block-container > .ablocks-block--info-box__content', |
| 39 |
$this->get_info_box_content( $attributes ), |
| 40 |
$this->get_info_box_content( $attributes, 'Tablet' ), |
| 41 |
$this->get_info_box_content( $attributes, 'Mobile' ) |
| 42 |
); |
| 43 |
|
| 44 |
// badge starts |
| 45 |
$css_generator->add_class_styles( |
| 46 |
'{{WRAPPER}}.ablocks-block--info-box > .ablocks-block-container > .ablocks-info-box-badge-link', |
| 47 |
$this->get_badge_css( $attributes ), |
| 48 |
$this->get_badge_css( $attributes, 'Tablet' ), |
| 49 |
$this->get_badge_css( $attributes, 'Mobile' ) |
| 50 |
); |
| 51 |
$css_generator->add_class_styles( |
| 52 |
'{{WRAPPER}}.ablocks-block--info-box > .ablocks-block-container > .ablocks-info-box-badge-link:hover', |
| 53 |
$this->get_badge_hover_css( $attributes ), |
| 54 |
$this->get_badge_hover_css( $attributes, 'Tablet' ), |
| 55 |
$this->get_badge_hover_css( $attributes, 'Mobile' ) |
| 56 |
); |
| 57 |
$css_generator->add_class_styles( |
| 58 |
'{{WRAPPER}}.ablocks-block--info-box > .ablocks-block-container > .ablocks-info-box-badge-link > .ablocks-info-box-badge-link-text', |
| 59 |
$this->get_badge_text_css( $attributes ) |
| 60 |
); |
| 61 |
|
| 62 |
// Icon Style |
| 63 |
$css_generator->add_class_styles( |
| 64 |
'{{WRAPPER}}.ablocks-block--info-box .ablocks-block-container > .ablocks-icon-wrap, {{WRAPPER}}.ablocks-block--info-box .ablocks-block-container > a .ablocks-icon-wrap', |
| 65 |
Icon::get_wrapper_css( $attributes ), |
| 66 |
Icon::get_wrapper_css( $attributes, 'Tablet' ), |
| 67 |
Icon::get_wrapper_css( $attributes, 'Mobile' ) |
| 68 |
); |
| 69 |
$css_generator->add_class_styles( |
| 70 |
'{{WRAPPER}}.ablocks-block--info-box > .ablocks-block-container > .ablocks-icon-wrap > img.ablocks-image-icon', |
| 71 |
Icon::get_element_image_css( $attributes ), |
| 72 |
Icon::get_element_image_css( $attributes, 'Tablet' ), |
| 73 |
Icon::get_element_image_css( $attributes, 'Mobile' ), |
| 74 |
); |
| 75 |
$css_generator->add_class_styles( |
| 76 |
'{{WRAPPER}}.ablocks-block--info-box > .ablocks-block-container > .ablocks-icon-wrap > img.ablocks-image-icon:hover', |
| 77 |
Icon::get_element_image_hover_css( $attributes ), |
| 78 |
Icon::get_element_image_hover_css( $attributes, 'Tablet' ), |
| 79 |
Icon::get_element_image_hover_css( $attributes, 'Mobile' ), |
| 80 |
); |
| 81 |
$css_generator->add_class_styles( |
| 82 |
'{{WRAPPER}}.ablocks-block--info-box > .ablocks-block-container > .ablocks-icon-wrap > svg.ablocks-svg-icon', |
| 83 |
Icon::get_element_css( $attributes ), |
| 84 |
Icon::get_element_css( $attributes, 'Tablet' ), |
| 85 |
Icon::get_element_css( $attributes, 'Mobile' ), |
| 86 |
); |
| 87 |
$css_generator->add_class_styles( |
| 88 |
'{{WRAPPER}}.ablocks-block--info-box > .ablocks-block-container > .ablocks-icon-wrap > svg.ablocks-svg-icon:hover', |
| 89 |
Icon::get_element_image_hover_css( $attributes ), |
| 90 |
Icon::get_element_image_hover_css( $attributes, 'Tablet' ), |
| 91 |
Icon::get_element_image_hover_css( $attributes, 'Mobile' ), |
| 92 |
); |
| 93 |
$css_generator->add_class_styles( |
| 94 |
'{{WRAPPER}}.ablocks-block--info-box:hover .ablocks-block-container > .ablocks-icon-wrap svg.ablocks-svg-icon , {{WRAPPER}}.ablocks-block--info-box:hover .ablocks-block-container > a .ablocks-icon-wrap svg.ablocks-svg-icon', |
| 95 |
$this->get_icon_css_hover( $attributes ), |
| 96 |
); |
| 97 |
|
| 98 |
// Heading starts |
| 99 |
$desktop_heading_text_styles = $this->get_heading_text_css( $attributes ); |
| 100 |
if ( ! empty( $attributes['headingTextColor'] ) ) { |
| 101 |
$desktop_heading_text_styles['color'] = $attributes['headingTextColor']; |
| 102 |
} |
| 103 |
$css_generator->add_class_styles( |
| 104 |
'{{WRAPPER}}.ablocks-block--info-box > .ablocks-block-container > .ablocks-block--info-box__content > .ablocks-info-box-heading', |
| 105 |
$desktop_heading_text_styles, |
| 106 |
$this->get_heading_text_css( $attributes, 'Tablet' ), |
| 107 |
$this->get_heading_text_css( $attributes, 'Mobile' ) |
| 108 |
); |
| 109 |
$css_generator->add_class_styles( |
| 110 |
'{{WRAPPER}}.ablocks-block--info-box:hover > .ablocks-block-container > .ablocks-block--info-box__content > .ablocks-info-box-heading', |
| 111 |
$this->get_heading_text_css_hover( $attributes ), |
| 112 |
$this->get_heading_text_css_hover( $attributes, 'Tablet' ), |
| 113 |
$this->get_heading_text_css_hover( $attributes, 'Mobile' ) |
| 114 |
); |
| 115 |
|
| 116 |
// Sub Heading starts |
| 117 |
$desktop_sub_heading_text_styles = $this->get_sub_heading_text_css( $attributes ); |
| 118 |
if ( ! empty( $attributes['subHeadingTextColor'] ) ) { |
| 119 |
$desktop_sub_heading_text_styles['color'] = $attributes['subHeadingTextColor']; |
| 120 |
} |
| 121 |
$css_generator->add_class_styles( |
| 122 |
'{{WRAPPER}}.ablocks-block--info-box > .ablocks-block-container > .ablocks-block--info-box__content > .ablocks-info-box-sub-heading', |
| 123 |
$desktop_sub_heading_text_styles, |
| 124 |
$this->get_sub_heading_text_css( $attributes, 'Tablet' ), |
| 125 |
$this->get_sub_heading_text_css( $attributes, 'Mobile' ) |
| 126 |
); |
| 127 |
$css_generator->add_class_styles( |
| 128 |
'{{WRAPPER}}.ablocks-block--info-box:hover > .ablocks-block-container > .ablocks-block--info-box__content > .ablocks-info-box-sub-heading', |
| 129 |
$this->get_sub_heading_text_css_hover( $attributes ), |
| 130 |
$this->get_sub_heading_text_css_hover( $attributes, 'Tablet' ), |
| 131 |
$this->get_sub_heading_text_css_hover( $attributes, 'Mobile' ) |
| 132 |
); |
| 133 |
|
| 134 |
// Description starts |
| 135 |
$desktop_des_text_style = $this->get_des_text_css( $attributes ); |
| 136 |
if ( ! empty( $attributes['desTextColor'] ) ) { |
| 137 |
$desktop_des_text_style['color'] = $attributes['desTextColor']; |
| 138 |
} |
| 139 |
$css_generator->add_class_styles( |
| 140 |
'{{WRAPPER}}.ablocks-block--info-box > .ablocks-block-container > .ablocks-block--info-box__content > .ablocks-info-box-text', |
| 141 |
$desktop_des_text_style, |
| 142 |
$this->get_des_text_css( $attributes, 'Tablet' ), |
| 143 |
$this->get_des_text_css( $attributes, 'Mobile' ), |
| 144 |
); |
| 145 |
$css_generator->add_class_styles( |
| 146 |
'{{WRAPPER}}.ablocks-block--info-box:hover > .ablocks-block-container > .ablocks-block--info-box__content > .ablocks-info-box-text', |
| 147 |
$this->get_des_text_css_hover( $attributes ), |
| 148 |
$this->get_des_text_css_hover( $attributes, 'Tablet' ), |
| 149 |
$this->get_des_text_css_hover( $attributes, 'Mobile' ) |
| 150 |
); |
| 151 |
$css_generator->add_class_styles( |
| 152 |
'{{WRAPPER}}.ablocks-block--info-box > .ablocks-block-container > .ablocks-block--info-box__content > .ablocks-info-box-text-drop-caps::first-letter', |
| 153 |
$this->get_des_drop_text_css( $attributes ), |
| 154 |
$this->get_des_drop_text_css( $attributes, 'Tablet' ), |
| 155 |
$this->get_des_drop_text_css( $attributes, 'Mobile' ), |
| 156 |
); |
| 157 |
|
| 158 |
// rating icon css |
| 159 |
$css_generator->add_class_styles( |
| 160 |
'{{WRAPPER}} .ablocks-info-box-star-ratings', |
| 161 |
$this->get_container_css( $attributes ), |
| 162 |
$this->get_container_css( $attributes, 'Tablet' ), |
| 163 |
$this->get_container_css( $attributes, 'Mobile' ), |
| 164 |
); |
| 165 |
$css_generator->add_class_styles( |
| 166 |
'{{WRAPPER}} .ablocks-info-box-star-ratings', |
| 167 |
$this->get_rating_css( $attributes ), |
| 168 |
$this->get_rating_css( $attributes, 'Tablet' ), |
| 169 |
$this->get_rating_css( $attributes, 'Mobile' ), |
| 170 |
); |
| 171 |
$css_generator->add_class_styles( |
| 172 |
'{{WRAPPER}} .ablocks-info-box-star-ratings-icons > .ablocks-info-box-rating > .ablocks-info-box-rating__fill > .ablocks-icon-wrap, {{WRAPPER}} .ablocks-info-box-star-ratings-icons > .ablocks-info-box-rating > .ablocks-info-box-rating__unfill > .ablocks-icon-wrap', |
| 173 |
Icon::get_wrapper_css( $attributes, '', 'starIcon' ), |
| 174 |
Icon::get_wrapper_css( $attributes, 'Tablet', 'starIcon' ), |
| 175 |
Icon::get_wrapper_css( $attributes, 'Mobile', 'starIcon' ) |
| 176 |
); |
| 177 |
// rating icon spacing css |
| 178 |
$css_generator->add_class_styles( |
| 179 |
'{{WRAPPER}} .ablocks-info-box-star-ratings-icons', |
| 180 |
$this->get_rating_icon_spacing_css( $attributes ), |
| 181 |
$this->get_rating_icon_spacing_css( $attributes, 'Tablet' ), |
| 182 |
$this->get_rating_icon_spacing_css( $attributes, 'Mobile' ), |
| 183 |
); |
| 184 |
$css_generator->add_class_styles( |
| 185 |
'{{WRAPPER}} .ablocks-info-box-star-ratings-icons > .ablocks-info-box-rating > .ablocks-info-box-rating__fill > .ablocks-icon-wrap > svg', |
| 186 |
$this->get_fill_rating_css( $attributes ), |
| 187 |
$this->get_fill_rating_css( $attributes, 'Tablet' ), |
| 188 |
$this->get_fill_rating_css( $attributes, 'Mobile' ), |
| 189 |
); |
| 190 |
$css_generator->add_class_styles( |
| 191 |
'{{WRAPPER}} .ablocks-info-box-star-ratings-icons > .ablocks-info-box-rating > .ablocks-info-box-rating__unfill > .ablocks-icon-wrap > svg', |
| 192 |
$this->get_unfill_rating_css( $attributes ), |
| 193 |
$this->get_unfill_rating_css( $attributes, 'Tablet' ), |
| 194 |
$this->get_unfill_rating_css( $attributes, 'Mobile' ), |
| 195 |
); |
| 196 |
$css_generator->add_class_styles( |
| 197 |
'{{WRAPPER}}.ablocks-block--info-box:hover > .ablocks-block-container > .ablocks-block--info-box__content > .ablocks-info-box-star-ratings > .ablocks-info-box-star-ratings-icons > .ablocks-info-box-rating > .ablocks-info-box-rating__fill > .ablocks-icon-wrap > svg', |
| 198 |
$this->get_fill_rating_css_hover( $attributes ), |
| 199 |
$this->get_fill_rating_css_hover( $attributes, 'Tablet' ), |
| 200 |
$this->get_fill_rating_css_hover( $attributes, 'Mobile' ), |
| 201 |
); |
| 202 |
$css_generator->add_class_styles( |
| 203 |
'{{WRAPPER}}.ablocks-block--info-box:hover > .ablocks-block-container > .ablocks-block--info-box__content > .ablocks-info-box-star-ratings > .ablocks-info-box-star-ratings-icons > .ablocks-info-box-rating > .ablocks-info-box-rating__unfill > .ablocks-icon-wrap > svg', |
| 204 |
$this->get_unfill_rating_css_hover( $attributes ), |
| 205 |
$this->get_unfill_rating_css_hover( $attributes, 'Tablet' ), |
| 206 |
$this->get_unfill_rating_css_hover( $attributes, 'Mobile' ), |
| 207 |
); |
| 208 |
// rating number css |
| 209 |
$css_generator->add_class_styles( |
| 210 |
'{{WRAPPER}} .ablocks-info-box-star-rating-number', |
| 211 |
$this->get_rating_number_css( $attributes ), |
| 212 |
$this->get_rating_number_css( $attributes, 'Tablet' ), |
| 213 |
$this->get_rating_number_css( $attributes, 'Mobile' ), |
| 214 |
); |
| 215 |
|
| 216 |
// Generate button CSS start |
| 217 |
$css_generator->add_class_styles( |
| 218 |
'{{WRAPPER}}.ablocks-block--info-box > .ablocks-block-container > .ablocks-block--info-box__content > .ablocks-info-box-btn-link', |
| 219 |
$this->get_button_css( $attributes ), |
| 220 |
$this->get_button_css( $attributes, 'Tablet' ), |
| 221 |
$this->get_button_css( $attributes, 'Mobile' ) |
| 222 |
); |
| 223 |
// Generate button CSS end |
| 224 |
// Generate button hover CSS start |
| 225 |
$css_generator->add_class_styles( |
| 226 |
'{{WRAPPER}}.ablocks-block--info-box > .ablocks-block-container > .ablocks-block--info-box__content > .ablocks-info-box-btn-link:hover', |
| 227 |
$this->get_button_hover_css( $attributes ), |
| 228 |
$this->get_button_hover_css( $attributes, 'Tablet' ), |
| 229 |
$this->get_button_hover_css( $attributes, 'Mobile' ) |
| 230 |
); |
| 231 |
// Generate button icon hover CSS |
| 232 |
$css_generator->add_class_styles( |
| 233 |
'{{WRAPPER}}.ablocks-block--info-box > .ablocks-block-container > .ablocks-block--info-box__content > .ablocks-info-box-btn-link:hover > .ablocks-icon-wrap > svg.ablocks-svg-icon', |
| 234 |
$this->get_button_icon_hover_css( $attributes ), |
| 235 |
$this->get_button_icon_hover_css( $attributes, 'Tablet' ), |
| 236 |
$this->get_button_icon_hover_css( $attributes, 'Mobile' ) |
| 237 |
); |
| 238 |
// Generate button text CSS start |
| 239 |
$css_generator->add_class_styles( |
| 240 |
'{{WRAPPER}}.ablocks-block--info-box > .ablocks-block-container > .ablocks-block--info-box__content > .ablocks-info-box-btn-link > .ablocks-info-box-btn-link-text', |
| 241 |
$this->get_button_text_css( $attributes ) |
| 242 |
); |
| 243 |
// Generate button icon CSS start |
| 244 |
$css_generator->add_class_styles( |
| 245 |
'{{WRAPPER}} .ablocks-info-box-btn-link > .ablocks-icon-wrap', |
| 246 |
Icon::get_wrapper_css( $attributes, '', 'btnIcon' ), |
| 247 |
Icon::get_wrapper_css( $attributes, 'Tablet', 'btnIcon' ), |
| 248 |
Icon::get_wrapper_css( $attributes, 'Mobile', 'btnIcon' ) |
| 249 |
); |
| 250 |
$css_generator->add_class_styles( |
| 251 |
'{{WRAPPER}} .ablocks-info-box-btn-link > .ablocks-icon-wrap > svg.ablocks-svg-icon', |
| 252 |
Icon::get_element_css( $attributes, '', 'btnIcon' ), |
| 253 |
Icon::get_element_css( $attributes, 'Tablet', 'btnIcon' ), |
| 254 |
Icon::get_element_css( $attributes, 'Mobile', 'btnIcon' ), |
| 255 |
); |
| 256 |
$css_generator->add_class_styles( |
| 257 |
'{{WRAPPER}} .ablocks-info-box-btn-link > .ablocks-icon-wrap > svg.ablocks-svg-icon:hover', |
| 258 |
Icon::get_element_image_hover_css( $attributes, '', 'btnIcon' ), |
| 259 |
Icon::get_element_image_hover_css( $attributes, 'Tablet', 'btnIcon' ), |
| 260 |
Icon::get_element_image_hover_css( $attributes, 'Mobile', 'btnIcon' ), |
| 261 |
); |
| 262 |
|
| 263 |
return $css_generator->generate_css(); |
| 264 |
} |
| 265 |
|
| 266 |
public function get_wrapper_css( $attributes, $device = '' ) { |
| 267 |
return isset( $attributes['alignment'] ) ? Alignment::get_css( $attributes['alignment'], 'text-align', $device ) : []; |
| 268 |
} |
| 269 |
|
| 270 |
public function get_info_box( $attributes, $device = '' ) { |
| 271 |
$css = []; |
| 272 |
|
| 273 |
if ( isset( $attributes['stack'] ) ) { |
| 274 |
$css['display'] = 'flex'; |
| 275 |
$css['flex-direction'] = $attributes['stack']; |
| 276 |
} |
| 277 |
|
| 278 |
if ( isset( $attributes['iconAlignment'][ 'value' . $device ] ) ) { |
| 279 |
$css['align-items'] = $attributes['iconAlignment'][ 'value' . $device ]; |
| 280 |
} |
| 281 |
|
| 282 |
return array_merge( |
| 283 |
Range::get_css([ |
| 284 |
'attributeValue' => $attributes['iconGap'], |
| 285 |
'attribute_object_key' => 'value', |
| 286 |
'isResponsive' => true, |
| 287 |
'defaultValue' => 16, |
| 288 |
'hasUnit' => true, |
| 289 |
'unitDefaultValue' => 'px', |
| 290 |
'property' => 'gap', |
| 291 |
'device' => $device, |
| 292 |
]), |
| 293 |
$css, |
| 294 |
); |
| 295 |
} |
| 296 |
|
| 297 |
public function get_badge_css( $attributes, $device = '' ) { |
| 298 |
$css = []; |
| 299 |
|
| 300 |
if ( ! empty( $attributes['badgePosition'][ 'value' . $device ] ) ) { |
| 301 |
$position = $attributes['badgePosition'][ 'value' . $device ]; |
| 302 |
if ( $position === 'top-left' ) { |
| 303 |
$css['top'] = '0'; |
| 304 |
$css['left'] = '0'; |
| 305 |
$css['bottom'] = 'auto'; |
| 306 |
$css['right'] = 'auto'; |
| 307 |
} elseif ( $position === 'top-right' ) { |
| 308 |
$css['top'] = '0'; |
| 309 |
$css['right'] = '0'; |
| 310 |
$css['bottom'] = 'auto'; |
| 311 |
$css['left'] = 'auto'; |
| 312 |
} elseif ( $position === 'bottom-left' ) { |
| 313 |
$css['bottom'] = '0'; |
| 314 |
$css['left'] = '0'; |
| 315 |
$css['top'] = 'auto'; |
| 316 |
$css['right'] = 'auto'; |
| 317 |
} elseif ( $position === 'bottom-right' ) { |
| 318 |
$css['bottom'] = '0'; |
| 319 |
$css['right'] = '0'; |
| 320 |
$css['top'] = 'auto'; |
| 321 |
$css['left'] = 'auto'; |
| 322 |
}//end if |
| 323 |
}//end if |
| 324 |
if ( ! empty( $attributes['badgeTextColor'] ) ) { |
| 325 |
$css['color'] = $attributes['badgeTextColor']; |
| 326 |
} |
| 327 |
if ( ! empty( $attributes['badgeBackground'] ) ) { |
| 328 |
$css['background'] = $attributes['badgeBackground']; |
| 329 |
} elseif ( ! empty( $attributes['badgeType'] ) ) { |
| 330 |
$css['background'] = $attributes['badgeType']; |
| 331 |
} |
| 332 |
|
| 333 |
return array_merge( |
| 334 |
Range::get_css([ |
| 335 |
'attributeValue' => $attributes['badgeTransition'], |
| 336 |
'attribute_object_key' => 'value', |
| 337 |
'defaultValue' => 0, |
| 338 |
'unitDefaultValue' => 's', |
| 339 |
'property' => 'transition-duration', |
| 340 |
'device' => $device, |
| 341 |
]), |
| 342 |
$css, |
| 343 |
Border::get_css( $attributes['badgeBorder'], '', $device ), |
| 344 |
Typography::get_css( $attributes['badgeTypography'], '', $device ), |
| 345 |
Dimensions::get_css( $attributes['badgePadding'], 'padding', $device ), |
| 346 |
); |
| 347 |
} |
| 348 |
public function get_badge_hover_css( $attributes, $device = '' ) { |
| 349 |
$css = []; |
| 350 |
|
| 351 |
if ( ! empty( $attributes['badgeTextColorH'] ) ) { |
| 352 |
$css['color'] = $attributes['badgeTextColorH']; |
| 353 |
} |
| 354 |
if ( ! empty( $attributes['badgeBackgroundH'] ) ) { |
| 355 |
$css['background'] = $attributes['badgeBackgroundH']; |
| 356 |
} |
| 357 |
|
| 358 |
return array_merge( |
| 359 |
$css, |
| 360 |
Border::get_css( $attributes['badgeBorder'], '', $device ), |
| 361 |
); |
| 362 |
} |
| 363 |
public function get_badge_text_css( $attributes, $device = '' ) { |
| 364 |
return TextShadow::get_css( $attributes['badgeTextShadow'] ); |
| 365 |
} |
| 366 |
|
| 367 |
|
| 368 |
|
| 369 |
public function get_icon_css_hover( $attributes, $device = '' ) { |
| 370 |
$css = []; |
| 371 |
if ( ! empty( $attributes['iconPrimaryColorH'] ) ) { |
| 372 |
$css['fill'] = $attributes['iconPrimaryColorH']; |
| 373 |
} |
| 374 |
return array_merge( |
| 375 |
Range::get_css([ |
| 376 |
'attributeValue' => $attributes['iconTransition'], |
| 377 |
'attribute_object_key' => 'value', |
| 378 |
'defaultValue' => 0, |
| 379 |
'unitDefaultValue' => 's', |
| 380 |
'property' => 'transition-duration', |
| 381 |
'device' => $device, |
| 382 |
]), |
| 383 |
$css |
| 384 |
); |
| 385 |
} |
| 386 |
|
| 387 |
public function get_info_box_content( $attributes, $device = '' ) { |
| 388 |
$css = []; |
| 389 |
|
| 390 |
if ( isset( $attributes['alignment'][ 'value' . $device ] ) ) { |
| 391 |
$css['align-items'] = $attributes['alignment'][ 'value' . $device ]; |
| 392 |
} |
| 393 |
|
| 394 |
return array_merge( |
| 395 |
Range::get_css([ |
| 396 |
'attributeValue' => $attributes['contentGap'], |
| 397 |
'attribute_object_key' => 'value', |
| 398 |
'isResponsive' => true, |
| 399 |
'defaultValue' => 10, |
| 400 |
'hasUnit' => true, |
| 401 |
'unitDefaultValue' => 'px', |
| 402 |
'property' => 'gap', |
| 403 |
'device' => $device, |
| 404 |
]), |
| 405 |
$css, |
| 406 |
); |
| 407 |
} |
| 408 |
|
| 409 |
public function get_heading_text_css( $attributes, $device = '' ) { |
| 410 |
$typography_css = ! empty( $attributes['headingTypography'] ) ? Typography::get_css( $attributes['headingTypography'], '', $device ) : array(); |
| 411 |
$textShadowCss = ! empty( $attributes['headingTextShadow'] ) ? TextShadow::get_css( $attributes['headingTextShadow'], '', $device ) : array(); |
| 412 |
$textStrokeCss = ! empty( $attributes['headingTextStroke'] ) ? TextStroke::get_css( $attributes['headingTextStroke'], '', $device ) : array(); |
| 413 |
|
| 414 |
$css = []; |
| 415 |
|
| 416 |
if ( ! empty( $attributes['alignment'][ 'value' . $device ] ) ) { |
| 417 |
if ( $attributes['alignment'][ 'value' . $device ] === 'flex-start' ) { |
| 418 |
$css['text-align'] = 'left'; |
| 419 |
} elseif ( $attributes['alignment'][ 'value' . $device ] === 'flex-end' ) { |
| 420 |
$css['text-align'] = 'right'; |
| 421 |
} else { |
| 422 |
$css['text-align'] = $attributes['alignment'][ 'value' . $device ]; |
| 423 |
} |
| 424 |
} |
| 425 |
|
| 426 |
return array_merge( $css, $typography_css, $textShadowCss, $textStrokeCss ); |
| 427 |
} |
| 428 |
public function get_heading_text_css_hover( $attributes, $device = '' ) { |
| 429 |
$css = []; |
| 430 |
if ( ! empty( $attributes['headingTextColorHover'] ) ) { |
| 431 |
$css['color'] = $attributes['headingTextColorHover']; |
| 432 |
} |
| 433 |
if ( ! empty( $attributes['headingTransition'] ) ) { |
| 434 |
$css['transition-duration'] = $attributes['headingTransition'] . 's'; |
| 435 |
} |
| 436 |
|
| 437 |
return array_merge( |
| 438 |
Range::get_css([ |
| 439 |
'attributeValue' => $attributes['headingTransition'], |
| 440 |
'attribute_object_key' => 'value', |
| 441 |
'defaultValue' => 0, |
| 442 |
'unitDefaultValue' => 's', |
| 443 |
'property' => 'transition-duration', |
| 444 |
'device' => $device, |
| 445 |
]), |
| 446 |
$css |
| 447 |
); |
| 448 |
} |
| 449 |
|
| 450 |
|
| 451 |
public function get_sub_heading_text_css( $attributes, $device = '' ) { |
| 452 |
$typography_css = ! empty( $attributes['subHeadingTypography'] ) ? Typography::get_css( $attributes['subHeadingTypography'], '', $device ) : array(); |
| 453 |
$textShadowCss = ! empty( $attributes['subHeadingTextShadow'] ) ? TextShadow::get_css( $attributes['subHeadingTextShadow'], '', $device ) : array(); |
| 454 |
$textStrokeCss = ! empty( $attributes['subHeadingTextStroke'] ) ? TextStroke::get_css( $attributes['subHeadingTextStroke'], '', $device ) : array(); |
| 455 |
|
| 456 |
$css = []; |
| 457 |
|
| 458 |
if ( ! empty( $attributes['alignment'][ 'value' . $device ] ) ) { |
| 459 |
if ( $attributes['alignment'][ 'value' . $device ] === 'flex-start' ) { |
| 460 |
$css['text-align'] = 'left'; |
| 461 |
} elseif ( $attributes['alignment'][ 'value' . $device ] === 'flex-end' ) { |
| 462 |
$css['text-align'] = 'right'; |
| 463 |
} else { |
| 464 |
$css['text-align'] = $attributes['alignment'][ 'value' . $device ]; |
| 465 |
} |
| 466 |
} |
| 467 |
|
| 468 |
return array_merge( $css, $typography_css, $textShadowCss, $textStrokeCss ); |
| 469 |
} |
| 470 |
public function get_sub_heading_text_css_hover( $attributes, $device = '' ) { |
| 471 |
$css = []; |
| 472 |
if ( ! empty( $attributes['subHeadingTextColorHover'] ) ) { |
| 473 |
$css['color'] = $attributes['subHeadingTextColorHover']; |
| 474 |
} |
| 475 |
return array_merge( |
| 476 |
Range::get_css([ |
| 477 |
'attributeValue' => $attributes['subHeadingTransition'], |
| 478 |
'attribute_object_key' => 'value', |
| 479 |
'defaultValue' => 0, |
| 480 |
'unitDefaultValue' => 's', |
| 481 |
'property' => 'transition-duration', |
| 482 |
'device' => $device, |
| 483 |
]), |
| 484 |
$css |
| 485 |
); |
| 486 |
} |
| 487 |
|
| 488 |
public function get_des_text_css( $attributes, $device = '' ) { |
| 489 |
$css = []; |
| 490 |
|
| 491 |
if ( ! empty( $attributes['alignment'][ 'value' . $device ] ) ) { |
| 492 |
if ( $attributes['alignment'][ 'value' . $device ] === 'flex-start' ) { |
| 493 |
$css['text-align'] = 'left'; |
| 494 |
} elseif ( $attributes['alignment'][ 'value' . $device ] === 'flex-end' ) { |
| 495 |
$css['text-align'] = 'right'; |
| 496 |
} else { |
| 497 |
$css['text-align'] = $attributes['alignment'][ 'value' . $device ]; |
| 498 |
} |
| 499 |
} |
| 500 |
return array_merge( |
| 501 |
$css, |
| 502 |
isset( $attributes['desTypography'] ) ? Typography::get_css( $attributes['desTypography'], '', $device ) : [], |
| 503 |
isset( $attributes['desTextStroke'] ) ? TextStroke::get_css( $attributes['desTextStroke'], '', $device ) : [], |
| 504 |
isset( $attributes['desTextShadow'] ) ? TextShadow::get_css( $attributes['desTextShadow'], '', $device ) : [], |
| 505 |
); |
| 506 |
} |
| 507 |
public function get_des_text_css_hover( $attributes, $device = '' ) { |
| 508 |
$css = []; |
| 509 |
if ( ! empty( $attributes['desTextColorHover'] ) ) { |
| 510 |
$css['color'] = $attributes['desTextColorHover']; |
| 511 |
} |
| 512 |
return array_merge( |
| 513 |
Range::get_css([ |
| 514 |
'attributeValue' => $attributes['desTransition'], |
| 515 |
'attribute_object_key' => 'value', |
| 516 |
'defaultValue' => 0, |
| 517 |
'unitDefaultValue' => 's', |
| 518 |
'property' => 'transition-duration', |
| 519 |
'device' => $device, |
| 520 |
]), |
| 521 |
$css |
| 522 |
); |
| 523 |
} |
| 524 |
public function get_des_drop_text_css( $attributes, $device = '' ) { |
| 525 |
$css = []; |
| 526 |
if ( ! empty( $attributes['desDropCapsTextColor'] ) ) { |
| 527 |
$css['color'] = $attributes['desDropCapsTextColor']; |
| 528 |
} |
| 529 |
return $css; |
| 530 |
} |
| 531 |
|
| 532 |
public function get_container_css( $attributes, $device = '' ) { |
| 533 |
$css = []; |
| 534 |
|
| 535 |
return array_merge( |
| 536 |
Range::get_css([ |
| 537 |
'attributeValue' => $attributes['ratingNumberGap'], |
| 538 |
'attribute_object_key' => 'value', |
| 539 |
'isResponsive' => true, |
| 540 |
'defaultValue' => 0, |
| 541 |
'hasUnit' => true, |
| 542 |
'unitDefaultValue' => 'px', |
| 543 |
'property' => 'gap', |
| 544 |
'device' => $device, |
| 545 |
]), |
| 546 |
$css, |
| 547 |
isset( $attributes['alignment'] ) ? Alignment::get_css( $attributes['alignment'], 'justify-content', $device ) : [], |
| 548 |
); |
| 549 |
} |
| 550 |
public function get_rating_number_css( $attributes, $device = '' ) { |
| 551 |
$css = []; |
| 552 |
if ( ! empty( $attributes['ratingNumberColor'] ) ) { |
| 553 |
$css['color'] = $attributes['ratingNumberColor']; |
| 554 |
} |
| 555 |
if ( ! empty( $attributes['ratingNumberPosition'] ) ) { |
| 556 |
if ( 'left' === $attributes['ratingNumberPosition'] ) { |
| 557 |
$css['order'] = '-5'; |
| 558 |
} else { |
| 559 |
$css['order'] = '10'; |
| 560 |
} |
| 561 |
} |
| 562 |
return array_merge( |
| 563 |
$css, |
| 564 |
isset( $attributes['ratingNumberTypography'] ) ? Typography::get_css( $attributes['ratingNumberTypography'], '', $device ) : [], |
| 565 |
); |
| 566 |
} |
| 567 |
public function get_rating_css( $attributes, $device = '' ) { |
| 568 |
$rating_css = []; |
| 569 |
return array_merge( |
| 570 |
Range::get_css([ |
| 571 |
'attributeValue' => $attributes['size'] ?? [], |
| 572 |
'attribute_object_key' => 'value', |
| 573 |
'isResponsive' => true, |
| 574 |
'defaultValue' => 0, |
| 575 |
'hasUnit' => true, |
| 576 |
'unitDefaultValue' => 'px', |
| 577 |
'property' => 'font-size', |
| 578 |
'device' => $device, |
| 579 |
]), |
| 580 |
$rating_css, |
| 581 |
); |
| 582 |
} |
| 583 |
|
| 584 |
|
| 585 |
public function get_rating_icon_spacing_css( $attributes, $device = '' ) { |
| 586 |
$rating_icon_spacing_css = []; |
| 587 |
|
| 588 |
return array_merge( |
| 589 |
Range::get_css([ |
| 590 |
'attributeValue' => $attributes['spacing'], |
| 591 |
'attribute_object_key' => 'value', |
| 592 |
'isResponsive' => true, |
| 593 |
'defaultValue' => 0, |
| 594 |
'hasUnit' => true, |
| 595 |
'unitDefaultValue' => 'px', |
| 596 |
'property' => 'gap', |
| 597 |
'device' => $device, |
| 598 |
]), |
| 599 |
$rating_icon_spacing_css |
| 600 |
); |
| 601 |
} |
| 602 |
|
| 603 |
public function get_fill_rating_css( $attributes, $device = '' ) { |
| 604 |
$css = []; |
| 605 |
if ( ! empty( $attributes['ratingColor'] ) ) { |
| 606 |
$css['fill'] = $attributes['ratingColor']; |
| 607 |
} |
| 608 |
|
| 609 |
return array_merge( |
| 610 |
Range::get_css([ |
| 611 |
'attributeValue' => $attributes['ratingTransition'], |
| 612 |
'attribute_object_key' => 'value', |
| 613 |
'defaultValue' => 0, |
| 614 |
'unitDefaultValue' => 's', |
| 615 |
'property' => 'transition-duration', |
| 616 |
'device' => $device, |
| 617 |
]), |
| 618 |
$css |
| 619 |
); |
| 620 |
} |
| 621 |
public function get_unfill_rating_css( $attributes, $device = '' ) { |
| 622 |
$css = []; |
| 623 |
if ( ! empty( $attributes['ratingColor'] ) ) { |
| 624 |
$css['fill'] = $attributes['ratingUnmarkedColor']; |
| 625 |
} |
| 626 |
return array_merge( |
| 627 |
Range::get_css([ |
| 628 |
'attributeValue' => $attributes['ratingTransition'], |
| 629 |
'attribute_object_key' => 'value', |
| 630 |
'defaultValue' => 0, |
| 631 |
'unitDefaultValue' => 's', |
| 632 |
'property' => 'transition-duration', |
| 633 |
'device' => $device, |
| 634 |
]), |
| 635 |
$css |
| 636 |
); |
| 637 |
} |
| 638 |
public function get_fill_rating_css_hover( $attributes, $device = '' ) { |
| 639 |
$css = []; |
| 640 |
if ( ! empty( $attributes['ratingColorHover'] ) ) { |
| 641 |
$css['fill'] = $attributes['ratingColorHover']; |
| 642 |
} |
| 643 |
|
| 644 |
return array_merge( |
| 645 |
Range::get_css([ |
| 646 |
'attributeValue' => $attributes['ratingTransition'], |
| 647 |
'attribute_object_key' => 'value', |
| 648 |
'defaultValue' => 0, |
| 649 |
'unitDefaultValue' => 's', |
| 650 |
'property' => 'transition-duration', |
| 651 |
'device' => $device, |
| 652 |
]), |
| 653 |
$css |
| 654 |
); |
| 655 |
} |
| 656 |
public function get_unfill_rating_css_hover( $attributes, $device = '' ) { |
| 657 |
$css = []; |
| 658 |
if ( ! empty( $attributes['ratingColorHover'] ) ) { |
| 659 |
$css['fill'] = $attributes['ratingUnmarkedColorHover']; |
| 660 |
} |
| 661 |
return array_merge( |
| 662 |
Range::get_css([ |
| 663 |
'attributeValue' => $attributes['ratingTransition'], |
| 664 |
'attribute_object_key' => 'value', |
| 665 |
'defaultValue' => 0, |
| 666 |
'unitDefaultValue' => 's', |
| 667 |
'property' => 'transition-duration', |
| 668 |
'device' => $device, |
| 669 |
]), |
| 670 |
$css |
| 671 |
); |
| 672 |
} |
| 673 |
|
| 674 |
public function get_button_css( $attributes, $device = '' ) { |
| 675 |
$css = []; |
| 676 |
|
| 677 |
if ( ! empty( $attributes['btnBackground'] ) ) { |
| 678 |
$css['background'] = $attributes['btnBackground']; |
| 679 |
} else { |
| 680 |
$css['background'] = $attributes['btnType']; |
| 681 |
} |
| 682 |
|
| 683 |
if ( isset( $attributes['btnAlignment'][ 'value' . $device ] ) ) { |
| 684 |
$css['justify-content'] = $attributes['btnAlignment'][ 'value' . $device ]; |
| 685 |
} |
| 686 |
|
| 687 |
return array_merge( |
| 688 |
Range::get_css([ |
| 689 |
'attributeValue' => $attributes['btnIconSpace'], |
| 690 |
'attribute_object_key' => 'value', |
| 691 |
'defaultValue' => 10, |
| 692 |
'property' => 'column-gap', |
| 693 |
'device' => $device, |
| 694 |
]), |
| 695 |
Range::get_css([ |
| 696 |
'attributeValue' => $attributes['btnTransition'], |
| 697 |
'attribute_object_key' => 'value', |
| 698 |
'defaultValue' => 0, |
| 699 |
'unitDefaultValue' => 's', |
| 700 |
'property' => 'transition-duration', |
| 701 |
'device' => $device, |
| 702 |
]), |
| 703 |
$css, |
| 704 |
[ 'color' => $attributes['btnTextColor'] ?? '#000000' ], |
| 705 |
Border::get_css( $attributes['btnBorder'], '', $device ), |
| 706 |
Typography::get_css( $attributes['btnTypography'], '', $device ), |
| 707 |
Dimensions::get_css( $attributes['btnPadding'], 'padding', $device ), |
| 708 |
); |
| 709 |
} |
| 710 |
public function get_button_hover_css( $attributes, $device = '' ) { |
| 711 |
$css = []; |
| 712 |
if ( ! empty( $attributes['btnTextColorH'] ) ) { |
| 713 |
$css['color'] = $attributes['btnTextColorH']; |
| 714 |
} |
| 715 |
|
| 716 |
if ( ! empty( $attributes['btnBackgroundH'] ) ) { |
| 717 |
$css['background'] = $attributes['btnBackgroundH']; |
| 718 |
} |
| 719 |
|
| 720 |
return array_merge( |
| 721 |
$css, |
| 722 |
Border::get_hover_css( $attributes['btnBorder'], '', $device ) |
| 723 |
); |
| 724 |
} |
| 725 |
public function get_button_text_css( $attributes, $device = '' ) { |
| 726 |
return TextShadow::get_css( $attributes['btnTextShadow'] ); |
| 727 |
} |
| 728 |
public function get_button_icon_hover_css( $attributes, $device = '' ) { |
| 729 |
$css = []; |
| 730 |
|
| 731 |
if ( ! empty( $attributes['btnTextColorH'] ) ) { |
| 732 |
$css['fill'] = $attributes['btnTextColorH']; |
| 733 |
} |
| 734 |
|
| 735 |
return $css; |
| 736 |
} |
| 737 |
} |
| 738 |
|