| 1 |
<?php |
| 2 |
|
| 3 |
namespace ABlocks\Blocks\ContentTimeline; |
| 4 |
|
| 5 |
use ABlocks\Controls\Range; |
| 6 |
|
| 7 |
if ( ! defined( 'ABSPATH' ) ) { |
| 8 |
exit; |
| 9 |
} |
| 10 |
use ABlocks\Classes\BlockBaseAbstract; |
| 11 |
use ABlocks\Classes\CssGenerator; |
| 12 |
use ABlocks\Classes\CssGeneratorV2; |
| 13 |
use ABlocks\Controls\Dimensions; |
| 14 |
use ABlocks\Controls\Typography; |
| 15 |
use ABlocks\Controls\Border; |
| 16 |
use ABlocks\Controls\Color; |
| 17 |
|
| 18 |
|
| 19 |
class Block extends BlockBaseAbstract { |
| 20 |
|
| 21 |
protected $block_name = 'content-timeline'; |
| 22 |
|
| 23 |
public function build_css_v1( $attributes ) { |
| 24 |
$css_generator = new CssGenerator( $attributes ); |
| 25 |
|
| 26 |
// Generate and add CSS styles for different parts of the block |
| 27 |
$css_generator->add_class_styles( |
| 28 |
'{{WRAPPER}} .ablocks-block-content-timeline--outer-wrap .ablocks-icon-maker svg', |
| 29 |
$this->get_content_timeline_icon_css( $attributes ), |
| 30 |
$this->get_content_timeline_icon_css( $attributes, 'Tablet' ), |
| 31 |
$this->get_content_timeline_icon_css( $attributes, 'Mobile' ) |
| 32 |
); |
| 33 |
$css_generator->add_class_styles( |
| 34 |
'{{WRAPPER}} .ablocks-block-content-timeline--outer-wrap .ablocks__in-view-icon .ablocks-icon-wrap', |
| 35 |
$this->get_content_timeline_icon_background_css( $attributes ), |
| 36 |
$this->get_content_timeline_icon_background_css( $attributes, 'Tablet' ), |
| 37 |
$this->get_content_timeline_icon_background_css( $attributes, 'Mobile' ) |
| 38 |
); |
| 39 |
$css_generator->add_class_styles( |
| 40 |
'{{WRAPPER}} .ablocks-block-content-timeline .ablocks-block-content-timeline__line', |
| 41 |
$this->get_content_timeline_connector_css( $attributes ), |
| 42 |
$this->get_content_timeline_connector_css( $attributes, 'Tablet' ), |
| 43 |
$this->get_content_timeline_connector_css( $attributes, 'Mobile' ) |
| 44 |
); |
| 45 |
$css_generator->add_class_styles( |
| 46 |
'{{WRAPPER}} .ablocks-block-content-timeline--outer-wrap .ablocks-block-content-timeline-child--field', |
| 47 |
$this->get_content_timeline_item_gap_css( $attributes ), |
| 48 |
$this->get_content_timeline_item_gap_css( $attributes, 'Tablet' ), |
| 49 |
$this->get_content_timeline_item_gap_css( $attributes, 'Mobile' ) |
| 50 |
); |
| 51 |
$css_generator->add_class_styles( |
| 52 |
'{{WRAPPER}} .ablocks-block-content-timeline--outer-wrap .ablocks-block-content-timeline-child--field .ablocks-block-content-timeline-child__content-part', |
| 53 |
$this->get_content_timeline_content_css( $attributes ), |
| 54 |
$this->get_content_timeline_content_css( $attributes, 'Tablet' ), |
| 55 |
$this->get_content_timeline_content_css( $attributes, 'Mobile' ) |
| 56 |
); |
| 57 |
$css_generator->add_class_styles( |
| 58 |
'{{WRAPPER}} .ablocks-block-content-timeline-child__content-part .ablocks-block-content-timeline-child__arrow::after', |
| 59 |
$this->get_content_timeline_content_background_css( $attributes ), |
| 60 |
$this->get_content_timeline_content_background_css( $attributes, 'Tablet' ), |
| 61 |
$this->get_content_timeline_content_background_css( $attributes, 'Mobile' ) |
| 62 |
); |
| 63 |
$css_generator->add_class_styles( |
| 64 |
'{{WRAPPER}} .ablocks-block-content-timeline--outer-wrap .ablocks__in-view-icon', |
| 65 |
$this->get_content_timeline_connector_alignment_css( $attributes ), |
| 66 |
$this->get_content_timeline_connector_alignment_css( $attributes, 'Tablet' ), |
| 67 |
$this->get_content_timeline_connector_alignment_css( $attributes, 'Mobile' ) |
| 68 |
); |
| 69 |
$css_generator->add_class_styles( |
| 70 |
'{{WRAPPER}} .ablocks-block-content-timeline-child__date', |
| 71 |
$this->get_content_timeline_date_alignment_css( $attributes ), |
| 72 |
$this->get_content_timeline_date_alignment_css( $attributes, 'Tablet' ), |
| 73 |
$this->get_content_timeline_date_alignment_css( $attributes, 'Mobile' ) |
| 74 |
); |
| 75 |
// Conditional CSS generation based on arrowAlignment |
| 76 |
|
| 77 |
$css_generator->add_class_styles( |
| 78 |
'{{WRAPPER}} .ablocks-block-content-timeline-child--line-center .ablocks-block-content-timeline-child__arrow', |
| 79 |
$this->get_content_timeline_arrow_css( $attributes ), |
| 80 |
$this->get_content_timeline_arrow_css( $attributes, 'Tablet' ), |
| 81 |
$this->get_content_timeline_arrow_css( $attributes, 'Mobile' ) |
| 82 |
); |
| 83 |
$css_generator->add_class_styles( |
| 84 |
'{{WRAPPER}} .ablocks-block-content-timeline-child__date,.ablocks-block-content-timeline-child__inner-content-date', |
| 85 |
$this->get_content_timeline_date_css( $attributes ), |
| 86 |
$this->get_content_timeline_date_css( $attributes, 'Tablet' ), |
| 87 |
$this->get_content_timeline_date_css( $attributes, 'Mobile' ) |
| 88 |
); |
| 89 |
$css_generator->add_class_styles( |
| 90 |
'{{WRAPPER}} .ablocks-block-content-timeline-child__inner-content-date', |
| 91 |
$this->get_content_timeline_date_mobile_css( $attributes, 'Mobile' ) |
| 92 |
); |
| 93 |
$css_generator->add_class_styles( |
| 94 |
'{{WRAPPER}} .ablocks-block-content-timeline-child__inner-content-date:hover', |
| 95 |
$this->get_content_timeline_date_hover_mobile_css( $attributes, 'Mobile' ) |
| 96 |
); |
| 97 |
$css_generator->add_class_styles( |
| 98 |
'{{WRAPPER}} .ablocks-block-content-timeline-child__date-inner', |
| 99 |
$this->get_content_timeline_show_date_center_css( $attributes, '' ), |
| 100 |
$this->get_content_timeline_show_date_center_css( $attributes, 'Tablet' ), |
| 101 |
$this->get_content_timeline_show_date_center_css( $attributes, 'Mobile' ) |
| 102 |
); |
| 103 |
$css_generator->add_class_styles( |
| 104 |
'{{WRAPPER}} .ablocks-block-content-timeline-child__date', |
| 105 |
$this->get_content_timeline_show_date_left_right_css( $attributes, '' ), |
| 106 |
$this->get_content_timeline_show_date_left_right_css( $attributes, 'Tablet' ), |
| 107 |
$this->get_content_timeline_show_date_left_right_css( $attributes, 'Mobile' ) |
| 108 |
); |
| 109 |
$css_generator->add_class_styles( |
| 110 |
'{{WRAPPER}} .ablocks-block-content-timeline--left .ablocks-block-content-timeline__line,.ablocks-block-content-timeline--right .ablocks-block-content-timeline__line', |
| 111 |
$this->get_content_timeline_show_date_left_right_line_css( $attributes, '' ), |
| 112 |
$this->get_content_timeline_show_date_left_right_line_css( $attributes, 'Tablet' ), |
| 113 |
$this->get_content_timeline_show_date_left_right_line_css( $attributes, 'Mobile' ) |
| 114 |
); |
| 115 |
$css_generator->add_class_styles( |
| 116 |
'{{WRAPPER}} .ablocks-block-content-timeline-child__inner-content-date', |
| 117 |
$this->get_content_timeline_show_date_mobile_css( $attributes, '' ), |
| 118 |
$this->get_content_timeline_show_date_mobile_css( $attributes, 'Tablet' ), |
| 119 |
$this->get_content_timeline_show_date_mobile_css( $attributes, 'Mobile' ) |
| 120 |
); |
| 121 |
|
| 122 |
return $css_generator->generate_css(); |
| 123 |
} |
| 124 |
public function build_css_v2( $attributes ) { |
| 125 |
$css_generator = new CssGeneratorV2( $attributes, $this->block_name ); |
| 126 |
|
| 127 |
// Generate and add CSS styles for different parts of the block |
| 128 |
$css_generator->add_class_styles( |
| 129 |
'{{WRAPPER}} .ablocks-icon-maker svg', |
| 130 |
$this->get_content_timeline_icon_css( $attributes ), |
| 131 |
$this->get_content_timeline_icon_css( $attributes, 'Tablet' ), |
| 132 |
$this->get_content_timeline_icon_css( $attributes, 'Mobile' ) |
| 133 |
); |
| 134 |
$css_generator->add_class_styles( |
| 135 |
'{{WRAPPER}} .ablocks-block-content-timeline--outer-wrap .ablocks__in-view-icon', |
| 136 |
$this->get_content_timeline_icon_background_css( $attributes ), |
| 137 |
$this->get_content_timeline_icon_background_css( $attributes, 'Tablet' ), |
| 138 |
$this->get_content_timeline_icon_background_css( $attributes, 'Mobile' ) |
| 139 |
); |
| 140 |
$css_generator->add_class_styles( |
| 141 |
'{{WRAPPER}} .ablocks-block-content-timeline .ablocks-block-content-timeline__line', |
| 142 |
$this->get_content_timeline_connector_css( $attributes ), |
| 143 |
$this->get_content_timeline_connector_css( $attributes, 'Tablet' ), |
| 144 |
$this->get_content_timeline_connector_css( $attributes, 'Mobile' ) |
| 145 |
); |
| 146 |
$css_generator->add_class_styles( |
| 147 |
'{{WRAPPER}} .ablocks-block-content-timeline--outer-wrap .ablocks-block-content-timeline-child--field', |
| 148 |
$this->get_content_timeline_item_gap_css( $attributes ), |
| 149 |
$this->get_content_timeline_item_gap_css( $attributes, 'Tablet' ), |
| 150 |
$this->get_content_timeline_item_gap_css( $attributes, 'Mobile' ) |
| 151 |
); |
| 152 |
$css_generator->add_class_styles( |
| 153 |
'{{WRAPPER}} .ablocks-block-content-timeline--outer-wrap .ablocks-block-content-timeline-child--field .ablocks-block-content-timeline-child__content-part', |
| 154 |
$this->get_content_timeline_content_css( $attributes ), |
| 155 |
$this->get_content_timeline_content_css( $attributes, 'Tablet' ), |
| 156 |
$this->get_content_timeline_content_css( $attributes, 'Mobile' ) |
| 157 |
); |
| 158 |
$css_generator->add_class_styles( |
| 159 |
'{{WRAPPER}} .ablocks-block-content-timeline-child__content-part .ablocks-block-content-timeline-child__arrow::after', |
| 160 |
$this->get_content_timeline_content_background_css( $attributes ), |
| 161 |
$this->get_content_timeline_content_background_css( $attributes, 'Tablet' ), |
| 162 |
$this->get_content_timeline_content_background_css( $attributes, 'Mobile' ) |
| 163 |
); |
| 164 |
$css_generator->add_class_styles( |
| 165 |
'{{WRAPPER}} .ablocks-block-content-timeline--outer-wrap .ablocks__in-view-icon', |
| 166 |
$this->get_content_timeline_connector_alignment_css( $attributes ), |
| 167 |
$this->get_content_timeline_connector_alignment_css( $attributes, 'Tablet' ), |
| 168 |
$this->get_content_timeline_connector_alignment_css( $attributes, 'Mobile' ) |
| 169 |
); |
| 170 |
$css_generator->add_class_styles( |
| 171 |
'{{WRAPPER}} .ablocks-block-content-timeline-child__date', |
| 172 |
$this->get_content_timeline_date_alignment_css( $attributes ), |
| 173 |
$this->get_content_timeline_date_alignment_css( $attributes, 'Tablet' ), |
| 174 |
$this->get_content_timeline_date_alignment_css( $attributes, 'Mobile' ) |
| 175 |
); |
| 176 |
// Conditional CSS generation based on arrowAlignment |
| 177 |
|
| 178 |
$css_generator->add_class_styles( |
| 179 |
'{{WRAPPER}} .ablocks-block-content-timeline-child--line-center .ablocks-block-content-timeline-child__arrow', |
| 180 |
$this->get_content_timeline_arrow_css( $attributes ), |
| 181 |
$this->get_content_timeline_arrow_css( $attributes, 'Tablet' ), |
| 182 |
$this->get_content_timeline_arrow_css( $attributes, 'Mobile' ) |
| 183 |
); |
| 184 |
$css_generator->add_class_styles( |
| 185 |
'{{WRAPPER}} .ablocks-block-content-timeline-child__date,.ablocks-block-content-timeline-child__inner-content-date', |
| 186 |
$this->get_content_timeline_date_css( $attributes ), |
| 187 |
$this->get_content_timeline_date_css( $attributes, 'Tablet' ), |
| 188 |
$this->get_content_timeline_date_css( $attributes, 'Mobile' ) |
| 189 |
); |
| 190 |
$css_generator->add_class_styles( |
| 191 |
'{{WRAPPER}} .ablocks-block-content-timeline-child__inner-content-date', |
| 192 |
$this->get_content_timeline_date_mobile_css( $attributes, 'Mobile' ) |
| 193 |
); |
| 194 |
$css_generator->add_class_styles( |
| 195 |
'{{WRAPPER}} .ablocks-block-content-timeline-child__inner-content-date:hover', |
| 196 |
$this->get_content_timeline_date_hover_mobile_css( $attributes, 'Mobile' ) |
| 197 |
); |
| 198 |
$css_generator->add_class_styles( |
| 199 |
'{{WRAPPER}} .ablocks-block-content-timeline-child__date-inner', |
| 200 |
$this->get_content_timeline_show_date_center_css( $attributes, '' ), |
| 201 |
$this->get_content_timeline_show_date_center_css( $attributes, 'Tablet' ), |
| 202 |
$this->get_content_timeline_show_date_center_css( $attributes, 'Mobile' ) |
| 203 |
); |
| 204 |
$css_generator->add_class_styles( |
| 205 |
'{{WRAPPER}} .ablocks-block-content-timeline-child__date', |
| 206 |
$this->get_content_timeline_show_date_left_right_css( $attributes, '' ), |
| 207 |
$this->get_content_timeline_show_date_left_right_css( $attributes, 'Tablet' ), |
| 208 |
$this->get_content_timeline_show_date_left_right_css( $attributes, 'Mobile' ) |
| 209 |
); |
| 210 |
$css_generator->add_class_styles( |
| 211 |
'{{WRAPPER}} .ablocks-block-content-timeline--left .ablocks-block-content-timeline__line,.ablocks-block-content-timeline--right .ablocks-block-content-timeline__line', |
| 212 |
$this->get_content_timeline_show_date_left_right_line_css( $attributes, '' ), |
| 213 |
$this->get_content_timeline_show_date_left_right_line_css( $attributes, 'Tablet' ), |
| 214 |
$this->get_content_timeline_show_date_left_right_line_css( $attributes, 'Mobile' ) |
| 215 |
); |
| 216 |
$css_generator->add_class_styles( |
| 217 |
'{{WRAPPER}} .ablocks-block-content-timeline-child__inner-content-date', |
| 218 |
$this->get_content_timeline_show_date_mobile_css( $attributes, '' ), |
| 219 |
$this->get_content_timeline_show_date_mobile_css( $attributes, 'Tablet' ), |
| 220 |
$this->get_content_timeline_show_date_mobile_css( $attributes, 'Mobile' ) |
| 221 |
); |
| 222 |
|
| 223 |
return $css_generator->generate_css(); |
| 224 |
} |
| 225 |
public function build_css( $attributes ) { |
| 226 |
if ( isset( $attributes['blockVersion'] ) && (int) $attributes['blockVersion'] === 2 ) { |
| 227 |
return $this->build_css_v2( $attributes ); |
| 228 |
} |
| 229 |
return $this->build_css_v1( $attributes ); |
| 230 |
} |
| 231 |
public function get_content_timeline_show_date_mobile_css( $attributes, $device = '' ) { |
| 232 |
$css = []; |
| 233 |
if ( $device === '' || $device === 'Tablet' ) { |
| 234 |
$css['display'] = 'none'; |
| 235 |
} |
| 236 |
if ( $device === 'Mobile' ) { |
| 237 |
if ( isset( $attributes[ "showDate{$device}" ] ) && $attributes[ "showDate{$device}" ] === false ) { |
| 238 |
$css['display'] = 'none'; |
| 239 |
} elseif ( isset( $attributes[ "showDate{$device}" ] ) && $attributes[ "showDate{$device}" ] === true ) { |
| 240 |
$css['display'] = 'block'; |
| 241 |
} |
| 242 |
} |
| 243 |
|
| 244 |
return $css; |
| 245 |
} |
| 246 |
public function get_content_timeline_show_date_center_css( $attribute, $device ) { |
| 247 |
$css = []; |
| 248 |
$showDateKey = $device ? "showDate{$device}" : 'showDate'; |
| 249 |
$showDate = $attribute[ $showDateKey ] ?? null; |
| 250 |
$isCentered = $attribute['contentPosition'] === 'center'; |
| 251 |
|
| 252 |
if ( $isCentered ) { |
| 253 |
$css['display'] = $showDate ? 'block' : 'none'; |
| 254 |
} |
| 255 |
|
| 256 |
return $css; |
| 257 |
} |
| 258 |
|
| 259 |
public function get_content_timeline_show_date_left_right_css( $attribute, $device ) { |
| 260 |
$css = []; |
| 261 |
$showDateKey = $device ? "showDate{$device}" : 'showDate'; |
| 262 |
$showDate = $attribute[ $showDateKey ] ?? null; |
| 263 |
$isLeftOrRight = in_array( $attribute['contentPosition'], [ 'left', 'right' ], true ); |
| 264 |
|
| 265 |
if ( $isLeftOrRight ) { |
| 266 |
if ( $device !== 'Mobile' ) { |
| 267 |
$css['display'] = $showDate ? 'block !important' : 'none !important'; |
| 268 |
} elseif ( $device === 'Mobile' ) { |
| 269 |
$css['display'] = 'none !important'; |
| 270 |
|
| 271 |
} |
| 272 |
} |
| 273 |
if ( $attribute['contentPosition'] === 'center' ) { |
| 274 |
$css['display'] = 'block'; |
| 275 |
} |
| 276 |
|
| 277 |
return $css; |
| 278 |
} |
| 279 |
public function get_content_timeline_show_date_left_right_line_css( $attribute, $device ) { |
| 280 |
$css = []; |
| 281 |
$showDate = $attribute[ "showDate{$device}" ] ?? null; |
| 282 |
if ( $device === 'Mobile' ) { |
| 283 |
// Specific case for mobile content position left/right without date |
| 284 |
if ( $attribute['contentPosition'] === 'left' ) { |
| 285 |
$css['left'] = 'calc(35px / 2) !important'; // fallback for left without date |
| 286 |
} elseif ( $attribute['contentPosition'] === 'right' ) { |
| 287 |
$css['right'] = 'calc(35px / 2) !important'; // fallback for right without date |
| 288 |
} |
| 289 |
} elseif ( $device ) { |
| 290 |
// Non-mobile styles (if needed) |
| 291 |
if ( $attribute['contentPosition'] === 'left' ) { |
| 292 |
$css['left'] = $showDate ? 'calc(30% / 2) !important' : 'calc(61px / 2) !important'; |
| 293 |
$css['right'] = 'auto !important'; |
| 294 |
} elseif ( $attribute['contentPosition'] === 'right' ) { |
| 295 |
$css['right'] = $showDate ? 'calc(30% / 2) !important' : 'calc(61px / 2) !important'; |
| 296 |
$css['left'] = 'auto !important'; |
| 297 |
} |
| 298 |
} else { |
| 299 |
if ( $attribute['contentPosition'] === 'left' ) { |
| 300 |
$css['left'] = $showDate ? 'calc(30% / 2) !important' : 'calc(61px / 2) !important'; |
| 301 |
$css['right'] = 'auto !important'; |
| 302 |
} elseif ( $attribute['contentPosition'] === 'right' ) { |
| 303 |
$css['right'] = $showDate ? 'calc(30% / 2) !important' : 'calc(61px / 2) !important'; |
| 304 |
$css['left'] = 'auto !important'; |
| 305 |
} |
| 306 |
}//end if |
| 307 |
|
| 308 |
return $css; |
| 309 |
} |
| 310 |
public function get_content_timeline_icon_css( $attributes, $device = '' ) { |
| 311 |
$css = []; |
| 312 |
return array_merge( |
| 313 |
[ 'fill' => Color::get_css( isset( $attributes['iconColor'] ) ? $attributes['iconColor'] : '' ) ], |
| 314 |
Range::get_css([ |
| 315 |
'attributeValue' => $attributes['iconSize'], |
| 316 |
'attribute_object_key' => 'value', |
| 317 |
'isResponsive' => true, |
| 318 |
'hasUnit' => true, |
| 319 |
'defaultValue' => 18, |
| 320 |
'unitDefaultValue' => 'px', |
| 321 |
'property' => 'width', |
| 322 |
'device' => $device, |
| 323 |
]), |
| 324 |
Range::get_css([ |
| 325 |
'attributeValue' => $attributes['iconSize'], |
| 326 |
'attribute_object_key' => 'value', |
| 327 |
'isResponsive' => true, |
| 328 |
'hasUnit' => true, |
| 329 |
'defaultValue' => 18, |
| 330 |
'unitDefaultValue' => 'px', |
| 331 |
'property' => 'height', |
| 332 |
'device' => $device, |
| 333 |
]), |
| 334 |
$css, |
| 335 |
); |
| 336 |
} |
| 337 |
|
| 338 |
public function get_content_timeline_icon_background_css( $attributes, $device = '' ) { |
| 339 |
return array_merge( |
| 340 |
[ 'background' => Color::get_css( isset( $attributes['iconBackgroundColor'] ) ? $attributes['iconBackgroundColor'] : '' ) ], |
| 341 |
Range::get_css([ |
| 342 |
'attributeValue' => $attributes['iconBackgroundSize'], |
| 343 |
'attribute_object_key' => 'value', |
| 344 |
'defaultValue' => 48, |
| 345 |
'property' => 'width', |
| 346 |
]), |
| 347 |
Range::get_css([ |
| 348 |
'attributeValue' => $attributes['iconBackgroundSize'], |
| 349 |
'attribute_object_key' => 'value', |
| 350 |
'defaultValue' => 48, |
| 351 |
'property' => 'height', |
| 352 |
]), |
| 353 |
); |
| 354 |
} |
| 355 |
|
| 356 |
public function get_content_timeline_connector_css( $attributes, $device = '' ) { |
| 357 |
return array_merge( |
| 358 |
[ 'background' => Color::get_css( isset( $attributes['thicknessColor'] ) ? $attributes['thicknessColor'] : '' ) ], |
| 359 |
Range::get_css([ |
| 360 |
'attributeValue' => $attributes['thickness'], |
| 361 |
'attribute_object_key' => 'value', |
| 362 |
'defaultValue' => 3, |
| 363 |
'property' => 'width', |
| 364 |
]), |
| 365 |
Range::get_css([ |
| 366 |
'attributeValue' => $attributes['lineLeft'], |
| 367 |
'attribute_object_key' => 'value', |
| 368 |
'isResponsive' => true, |
| 369 |
'hasUnit' => true, |
| 370 |
'defaultValue' => 0, |
| 371 |
'unitDefaultValue' => 'px', |
| 372 |
'property' => 'margin-left', |
| 373 |
'device' => $device, |
| 374 |
]), |
| 375 |
Range::get_css([ |
| 376 |
'attributeValue' => $attributes['lineRight'], |
| 377 |
'attribute_object_key' => 'value', |
| 378 |
'isResponsive' => true, |
| 379 |
'hasUnit' => true, |
| 380 |
'defaultValue' => 0, |
| 381 |
'unitDefaultValue' => 'px', |
| 382 |
'property' => 'margin-right', |
| 383 |
'device' => $device, |
| 384 |
]), |
| 385 |
); |
| 386 |
} |
| 387 |
|
| 388 |
public function get_content_timeline_item_gap_css( $attributes, $device = '' ) { |
| 389 |
$css = []; |
| 390 |
return array_merge( |
| 391 |
Range::get_css([ |
| 392 |
'attributeValue' => $attributes['itemGap'], |
| 393 |
'attribute_object_key' => 'value', |
| 394 |
'defaultValue' => 10, |
| 395 |
'isResponsive' => true, |
| 396 |
'hasUnit' => true, |
| 397 |
'unitDefaultValue' => 'px', |
| 398 |
'property' => 'margin-top', |
| 399 |
'device' => $device, |
| 400 |
]), |
| 401 |
$css, |
| 402 |
); |
| 403 |
} |
| 404 |
|
| 405 |
public function get_content_timeline_content_css( $attributes, $device = '' ) { |
| 406 |
$css = []; |
| 407 |
$css['padding'] = '15px'; |
| 408 |
return array_merge( |
| 409 |
[ 'background' => Color::get_css( isset( $attributes['contentBackgroundColor'] ) ? $attributes['contentBackgroundColor'] : '' ) ], |
| 410 |
$css, |
| 411 |
Dimensions::get_css( $attributes['contentPadding'] ?? [], 'padding', $device ) |
| 412 |
); |
| 413 |
} |
| 414 |
|
| 415 |
public function get_content_timeline_content_background_css( $attributes, $device = '' ) { |
| 416 |
$css = []; |
| 417 |
if ( ! empty( $attributes['contentBackgroundColor'] ) ) { |
| 418 |
$css['border-left-color'] = Color::get_css( |
| 419 |
isset( $attributes['contentBackgroundColor'] ) ? $attributes['contentBackgroundColor'] : ''); |
| 420 |
$css['border-right-color'] = Color::get_css( |
| 421 |
isset( $attributes['contentBackgroundColor'] ) ? $attributes['contentBackgroundColor'] : ''); |
| 422 |
} |
| 423 |
return $css; |
| 424 |
} |
| 425 |
// public function get_content_timeline_arrow_css( $attributes, $device = '' ) { |
| 426 |
// $css = []; |
| 427 |
// $arrowAlignment = $attributes['arrowAlignment'] ?? ''; |
| 428 |
// $iconBackgroundSize = $attributes['iconBackgroundSize'] ?? ''; |
| 429 |
|
| 430 |
// if ( $arrowAlignment === 'top' ) { |
| 431 |
// $css['height'] = '0px'; |
| 432 |
// $css['top'] = $iconBackgroundSize ? ( $iconBackgroundSize / 2 ) . 'px' : '0'; |
| 433 |
// } elseif ( $arrowAlignment === 'bottom' ) { |
| 434 |
// $css['height'] = $iconBackgroundSize ? ( $iconBackgroundSize / 2 ) . 'px' : '0'; |
| 435 |
// $css['bottom'] = '0'; |
| 436 |
// } |
| 437 |
|
| 438 |
// return $css; |
| 439 |
// } |
| 440 |
|
| 441 |
public function get_content_timeline_arrow_css( $attributes, $device = '' ) { |
| 442 |
$css = []; |
| 443 |
$arrowAlignment = $attributes['arrowAlignment'] ?? ''; |
| 444 |
$iconBackgroundSize = $attributes['iconBackgroundSize'] ?? ''; |
| 445 |
|
| 446 |
// Existing logic + updated styles |
| 447 |
if ( $arrowAlignment === 'top' ) { |
| 448 |
$css['height'] = '35px'; |
| 449 |
$css['top'] = '10%'; |
| 450 |
$css['transform'] = 'translateY(-50%)'; |
| 451 |
$css['-webkit-transform'] = 'translateY(-50%)'; |
| 452 |
|
| 453 |
} elseif ( $arrowAlignment === 'bottom' ) { |
| 454 |
$css['height'] = '35px'; |
| 455 |
$css['top'] = '90%'; |
| 456 |
$css['transform'] = 'translateY(-50%)'; |
| 457 |
$css['-webkit-transform'] = 'translateY(-50%)'; |
| 458 |
|
| 459 |
} elseif ( $arrowAlignment === 'centre' ) { |
| 460 |
$css['height'] = '35px'; |
| 461 |
$css['top'] = '50%'; |
| 462 |
$css['transform'] = 'translateY(-50%)'; |
| 463 |
$css['-webkit-transform'] = 'translateY(-50%)'; |
| 464 |
} |
| 465 |
|
| 466 |
return $css; |
| 467 |
} |
| 468 |
public function get_content_timeline_connector_alignment_css( $attributes, $device = '' ) { |
| 469 |
$css = []; |
| 470 |
$arrowAlignment = $attributes['arrowAlignment'] ?? ''; |
| 471 |
|
| 472 |
if ( $arrowAlignment === 'top' ) { |
| 473 |
$css['align-self'] = 'flex-start'; |
| 474 |
} elseif ( $arrowAlignment === 'bottom' ) { |
| 475 |
$css['align-self'] = 'flex-end'; |
| 476 |
} else { |
| 477 |
$css['align-self'] = 'center'; |
| 478 |
} |
| 479 |
|
| 480 |
return $css; |
| 481 |
} |
| 482 |
public function get_content_timeline_date_alignment_css( $attributes, $device = '' ) { |
| 483 |
$css = []; |
| 484 |
|
| 485 |
$arrowAlignment = $attributes['arrowAlignment'] ?? ''; |
| 486 |
$iconBackgroundSize = $attributes['iconBackgroundSize'] ?? ''; |
| 487 |
|
| 488 |
if ( $arrowAlignment === 'top' ) { |
| 489 |
$css['align-self'] = 'flex-start'; |
| 490 |
} elseif ( $arrowAlignment === 'bottom' ) { |
| 491 |
$css['align-self'] = 'flex-end'; |
| 492 |
} else { |
| 493 |
$css['align-self'] = 'center'; |
| 494 |
} |
| 495 |
|
| 496 |
if ( $arrowAlignment === 'top' ) { |
| 497 |
$css['margin-top'] = $iconBackgroundSize ? ( $iconBackgroundSize / 4 ) . 'px' : '0'; |
| 498 |
} elseif ( $arrowAlignment === 'bottom' ) { |
| 499 |
$css['margin-bottom'] = $iconBackgroundSize ? ( $iconBackgroundSize / 4 ) . 'px' : '0'; |
| 500 |
} |
| 501 |
|
| 502 |
return $css; |
| 503 |
} |
| 504 |
|
| 505 |
public function get_content_timeline_date_css( $attributes, $device = '' ) { |
| 506 |
$typographyValueGlobal = $attributes['dateTypographyGlobal'] ? $attributes['dateTypographyGlobal'] : []; |
| 507 |
return array_merge( |
| 508 |
[ 'color' => Color::get_css( isset( $attributes['dateColor'] ) ? $attributes['dateColor'] : '' ) ], |
| 509 |
Typography::get_css( $attributes['dateTypography'] ?? [], '', $device, $typographyValueGlobal ) |
| 510 |
); |
| 511 |
} |
| 512 |
public function get_content_timeline_date_mobile_css( $attributes, $device = '' ) { |
| 513 |
$css = []; |
| 514 |
if ( ! empty( $attributes['dateAlign'] ) ) { |
| 515 |
$css['text-align'] = $attributes['dateAlign']; |
| 516 |
} |
| 517 |
return array_merge( |
| 518 |
[ 'background' => Color::get_css( isset( $attributes['dateBackground'] ) ? $attributes['dateBackground'] : '' ) ], |
| 519 |
$css, |
| 520 |
Dimensions::get_css( $attributes['datePadding'] ?? [], 'padding', $device ), |
| 521 |
Border::get_css( $attributes['dateBorder'] ?? [], '', $device ) |
| 522 |
); |
| 523 |
} |
| 524 |
public function get_content_timeline_date_hover_mobile_css( $attributes, $device = '' ) { |
| 525 |
return array_merge( |
| 526 |
Border::get_hover_css( $attributes['dateBorder'] ?? [], '', $device ) |
| 527 |
); |
| 528 |
} |
| 529 |
} |
| 530 |
|