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