PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.16.0
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.16.0
2.16.0 2.15.0 2.14.0 2.13.0 2.13.1 2.12.0 2.11.1 2.11.0 2.10.0 2.9.0 2.7.4 2.7.5 2.7.6 2.7.7 2.8.0 2.8.1 2.9.1 trunk 1.0 1.0-beta1 1.0-beta2 1.0-beta3 1.0.1 1.0.2 1.0.3 All 83 releases
← All changes | includes/blocks/content-timeline/block.php +222 -113 2.9.1 → 2.16.0 View file →
@@ -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,73 @@
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 );
60 - // Conditional CSS generation based on arrowAlignment
61 - $arrowAlignment = $attributes['arrowAlignment'] ?? 'top';
62 -
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',
66 - $this->get_content_timeline_arrow_css( $attributes ),
67 - $this->get_content_timeline_arrow_css( $attributes, 'Tablet' ),
68 - $this->get_content_timeline_arrow_css( $attributes, 'Mobile' )
69 - );
70 - $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',
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--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 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 + );
90 + $css_generator->add_class_styles(
91 91 '{{WRAPPER}} .ablocks-block-content-timeline-child__date,.ablocks-block-content-timeline-child__inner-content-date',
92 92 $this->get_content_timeline_date_css( $attributes ),
93 93 $this->get_content_timeline_date_css( $attributes, 'Tablet' ),
94 - $this->get_content_timeline_date_css( $attributes, 'Mobile' )
94 + $this->get_content_timeline_date_css( $attributes, 'Mobile' ),
95 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_content_timeline_date_css( $attributes, $device ); } )
95 96 );
96 97 $css_generator->add_class_styles(
97 98 '{{WRAPPER}} .ablocks-block-content-timeline-child__inner-content-date',
98 99 $this->get_content_timeline_date_mobile_css( $attributes, 'Mobile' )
@@ -104,31 +105,161 @@
104 105 $css_generator->add_class_styles(
105 106 '{{WRAPPER}} .ablocks-block-content-timeline-child__date-inner',
106 107 $this->get_content_timeline_show_date_center_css( $attributes, '' ),
107 108 $this->get_content_timeline_show_date_center_css( $attributes, 'Tablet' ),
108 - $this->get_content_timeline_show_date_center_css( $attributes, 'Mobile' )
109 + $this->get_content_timeline_show_date_center_css( $attributes, 'Mobile' ),
110 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_content_timeline_show_date_center_css( $attributes, $device ); } )
109 111 );
110 112 $css_generator->add_class_styles(
111 113 '{{WRAPPER}} .ablocks-block-content-timeline-child__date',
112 114 $this->get_content_timeline_show_date_left_right_css( $attributes, '' ),
113 115 $this->get_content_timeline_show_date_left_right_css( $attributes, 'Tablet' ),
114 - $this->get_content_timeline_show_date_left_right_css( $attributes, 'Mobile' )
116 + $this->get_content_timeline_show_date_left_right_css( $attributes, 'Mobile' ),
117 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_content_timeline_show_date_left_right_css( $attributes, $device ); } )
115 118 );
116 119 $css_generator->add_class_styles(
117 - '{{WRAPPER}} .ablocks-block-content-timeline--left .ablocks-block-content-timeline__line,.ablocks-block-content-timeline--right .ablocks-block-content-timeline__line',
118 - $this->get_content_timeline_show_date_left_right_line_css( $attributes, '' ),
119 - $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' )
120 + '{{WRAPPER}} .ablocks-block-content-timeline-child__inner-content-date',
121 + $this->get_content_timeline_show_date_mobile_css( $attributes, '' ),
122 + $this->get_content_timeline_show_date_mobile_css( $attributes, 'Tablet' ),
123 + $this->get_content_timeline_show_date_mobile_css( $attributes, 'Mobile' ),
124 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_content_timeline_show_date_mobile_css( $attributes, $device ); } )
121 125 );
126 +
127 + return $css_generator->generate_css();
128 + }
129 + public function build_css_v2( $attributes ) {
130 + $css_generator = new CssGeneratorV2( $attributes, $this->block_name );
131 +
132 + // Generate and add CSS styles for different parts of the block
122 133 $css_generator->add_class_styles(
134 + '{{WRAPPER}} .ablocks-icon-maker svg',
135 + $this->get_content_timeline_icon_css( $attributes ),
136 + $this->get_content_timeline_icon_css( $attributes, 'Tablet' ),
137 + $this->get_content_timeline_icon_css( $attributes, 'Mobile' ),
138 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_content_timeline_icon_css( $attributes, $device ); } )
139 + );
140 + $css_generator->add_class_styles(
141 + '{{WRAPPER}} .ablocks-block-content-timeline--outer-wrap .ablocks__in-view-icon',
142 + $this->get_content_timeline_icon_background_css( $attributes ),
143 + $this->get_content_timeline_icon_background_css( $attributes, 'Tablet' ),
144 + $this->get_content_timeline_icon_background_css( $attributes, 'Mobile' ),
145 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_content_timeline_icon_background_css( $attributes, $device ); } )
146 + );
147 + $css_generator->add_class_styles(
148 + '{{WRAPPER}} .ablocks-block-content-timeline .ablocks-block-content-timeline__line',
149 + $this->get_content_timeline_connector_css( $attributes ),
150 + $this->get_content_timeline_connector_css( $attributes, 'Tablet' ),
151 + $this->get_content_timeline_connector_css( $attributes, 'Mobile' ),
152 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_content_timeline_connector_css( $attributes, $device ); } )
153 + );
154 + $css_generator->add_class_styles(
155 + '{{WRAPPER}} .ablocks-block-content-timeline--outer-wrap .ablocks-block-content-timeline-child--field',
156 + $this->get_content_timeline_item_gap_css( $attributes ),
157 + $this->get_content_timeline_item_gap_css( $attributes, 'Tablet' ),
158 + $this->get_content_timeline_item_gap_css( $attributes, 'Mobile' ),
159 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_content_timeline_item_gap_css( $attributes, $device ); } )
160 + );
161 + $css_generator->add_class_styles(
162 + '{{WRAPPER}} .ablocks-block-content-timeline--outer-wrap',
163 + $this->get_content_timeline_horizontal_gap_css( $attributes ),
164 + $this->get_content_timeline_horizontal_gap_css( $attributes, 'Tablet' ),
165 + $this->get_content_timeline_horizontal_gap_css( $attributes, 'Mobile' ),
166 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_content_timeline_horizontal_gap_css( $attributes, $device ); } )
167 + );
168 + $css_generator->add_class_styles(
169 + '{{WRAPPER}} .ablocks-block-content-timeline--outer-wrap .ablocks-block-content-timeline-child--field .ablocks-block-content-timeline-child__content-part',
170 + $this->get_content_timeline_content_css( $attributes ),
171 + $this->get_content_timeline_content_css( $attributes, 'Tablet' ),
172 + $this->get_content_timeline_content_css( $attributes, 'Mobile' ),
173 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_content_timeline_content_css( $attributes, $device ); } )
174 + );
175 + $css_generator->add_class_styles(
176 + '{{WRAPPER}} .ablocks-block-content-timeline-child__content-part .ablocks-block-content-timeline-child__arrow::after',
177 + $this->get_content_timeline_content_background_css( $attributes ),
178 + $this->get_content_timeline_content_background_css( $attributes, 'Tablet' ),
179 + $this->get_content_timeline_content_background_css( $attributes, 'Mobile' ),
180 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_content_timeline_content_background_css( $attributes, $device ); } )
181 + );
182 + $css_generator->add_class_styles(
183 + '{{WRAPPER}} .ablocks-block-content-timeline--outer-wrap .ablocks__in-view-icon',
184 + $this->get_content_timeline_connector_alignment_css( $attributes ),
185 + $this->get_content_timeline_connector_alignment_css( $attributes, 'Tablet' ),
186 + $this->get_content_timeline_connector_alignment_css( $attributes, 'Mobile' ),
187 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_content_timeline_connector_alignment_css( $attributes, $device ); } )
188 + );
189 + $css_generator->add_class_styles(
190 + '{{WRAPPER}} .ablocks-block-content-timeline-child__date',
191 + $this->get_content_timeline_date_alignment_css( $attributes ),
192 + $this->get_content_timeline_date_alignment_css( $attributes, 'Tablet' ),
193 + $this->get_content_timeline_date_alignment_css( $attributes, 'Mobile' ),
194 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_content_timeline_date_alignment_css( $attributes, $device ); } )
195 + );
196 + $css_generator->add_class_styles(
197 + '{{WRAPPER}} .ablocks-block-content-timeline-child__date,.ablocks-block-content-timeline-child__inner-content-date',
198 + $this->get_content_timeline_date_css( $attributes ),
199 + $this->get_content_timeline_date_css( $attributes, 'Tablet' ),
200 + $this->get_content_timeline_date_css( $attributes, 'Mobile' ),
201 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_content_timeline_date_css( $attributes, $device ); } )
202 + );
203 + $css_generator->add_class_styles(
123 204 '{{WRAPPER}} .ablocks-block-content-timeline-child__inner-content-date',
205 + $this->get_content_timeline_date_mobile_css( $attributes, 'Mobile' )
206 + );
207 + $css_generator->add_class_styles(
208 + '{{WRAPPER}} .ablocks-block-content-timeline-child__inner-content-date:hover',
209 + $this->get_content_timeline_date_hover_mobile_css( $attributes, 'Mobile' )
210 + );
211 + $css_generator->add_class_styles(
212 + '{{WRAPPER}} .ablocks-block-content-timeline-child__date-inner',
213 + $this->get_content_timeline_show_date_center_css( $attributes, '' ),
214 + $this->get_content_timeline_show_date_center_css( $attributes, 'Tablet' ),
215 + $this->get_content_timeline_show_date_center_css( $attributes, 'Mobile' ),
216 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_content_timeline_show_date_center_css( $attributes, $device ); } )
217 + );
218 + $css_generator->add_class_styles(
219 + '{{WRAPPER}} .ablocks-block-content-timeline-child__date',
220 + $this->get_content_timeline_show_date_left_right_css( $attributes, '' ),
221 + $this->get_content_timeline_show_date_left_right_css( $attributes, 'Tablet' ),
222 + $this->get_content_timeline_show_date_left_right_css( $attributes, 'Mobile' ),
223 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_content_timeline_show_date_left_right_css( $attributes, $device ); } )
224 + );
225 + $css_generator->add_class_styles(
226 + '{{WRAPPER}} .ablocks-block-content-timeline-child__inner-content-date',
124 227 $this->get_content_timeline_show_date_mobile_css( $attributes, '' ),
125 228 $this->get_content_timeline_show_date_mobile_css( $attributes, 'Tablet' ),
126 - $this->get_content_timeline_show_date_mobile_css( $attributes, 'Mobile' )
229 + $this->get_content_timeline_show_date_mobile_css( $attributes, 'Mobile' ),
230 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_content_timeline_show_date_mobile_css( $attributes, $device ); } )
127 231 );
128 232
129 233 return $css_generator->generate_css();
130 234 }
235 + public function build_css( $attributes ) {
236 + if ( isset( $attributes['blockVersion'] ) && (int) $attributes['blockVersion'] === 2 ) {
237 + return $this->build_css_v2( $attributes );
238 + }
239 + return $this->build_css_v1( $attributes );
240 + }
241 + // Top / Bottom content positions lay the timeline out horizontally.
242 + public function is_horizontal_timeline( $attributes ) {
243 + return in_array( $attributes['contentPosition'] ?? '', [ 'top', 'bottom' ], true );
244 + }
245 +
246 + public function get_content_timeline_horizontal_gap_css( $attributes, $device = '' ) {
247 + if ( ! $this->is_horizontal_timeline( $attributes ) ) {
248 + return [];
249 + }
250 + return Range::get_css([
251 + 'attributeValue' => $attributes['itemGap'],
252 + 'attribute_object_key' => 'value',
253 + 'defaultValue' => 10,
254 + 'isResponsive' => true,
255 + 'hasUnit' => true,
256 + 'unitDefaultValue' => 'px',
257 + 'property' => 'gap',
258 + 'device' => $device,
259 + ]);
260 + }
261 +
131 262 public function get_content_timeline_show_date_mobile_css( $attributes, $device = '' ) {
132 263 $css = [];
133 264 if ( $device === '' || $device === 'Tablet' ) {
134 265 $css['display'] = 'none';
@@ -159,9 +290,9 @@
159 290 public function get_content_timeline_show_date_left_right_css( $attribute, $device ) {
160 291 $css = [];
161 292 $showDateKey = $device ? "showDate{$device}" : 'showDate';
162 293 $showDate = $attribute[ $showDateKey ] ?? null;
163 - $isLeftOrRight = in_array( $attribute['contentPosition'], [ 'left', 'right' ], true );
294 + $isLeftOrRight = in_array( $attribute['contentPosition'], [ 'left', 'right', 'top', 'bottom' ], true );
164 295
165 296 if ( $isLeftOrRight ) {
166 297 if ( $device !== 'Mobile' ) {
167 298 $css['display'] = $showDate ? 'block !important' : 'none !important';
@@ -175,58 +306,31 @@
175 306 }
176 307
177 308 return $css;
178 309 }
179 - public function get_content_timeline_show_date_left_right_line_css( $attribute, $device ) {
180 - $css = [];
181 - $showDate = $attribute[ "showDate{$device}" ] ?? null;
182 - if ( $device === 'Mobile' ) {
183 - // Specific case for mobile content position left/right without date
184 - if ( $attribute['contentPosition'] === 'left' ) {
185 - $css['left'] = 'calc(61px / 2) !important'; // fallback for left without date
186 - } elseif ( $attribute['contentPosition'] === 'right' ) {
187 - $css['right'] = 'calc(61px / 2) !important'; // fallback for right without date
188 - }
189 - } elseif ( $device ) {
190 - // Non-mobile styles (if needed)
191 - if ( $attribute['contentPosition'] === 'left' ) {
192 - $css['left'] = $showDate ? 'calc(33% / 2) !important' : 'calc(61px / 2) !important';
193 - $css['right'] = 'auto !important';
194 - } elseif ( $attribute['contentPosition'] === 'right' ) {
195 - $css['right'] = $showDate ? 'calc(33% / 2) !important' : 'calc(61px / 2) !important';
196 - $css['left'] = 'auto !important';
197 - }
198 - } else {
199 - if ( $attribute['contentPosition'] === 'left' ) {
200 - $css['left'] = $showDate ? 'calc(30% / 2) !important' : 'calc(61px / 2) !important';
201 - $css['right'] = 'auto !important';
202 - } elseif ( $attribute['contentPosition'] === 'right' ) {
203 - $css['right'] = $showDate ? 'calc(30% / 2) !important' : 'calc(61px / 2) !important';
204 - $css['left'] = 'auto !important';
205 - }
206 - }//end if
207 -
208 - return $css;
209 - }
210 310 public function get_content_timeline_icon_css( $attributes, $device = '' ) {
211 311 $css = [];
212 - if ( ! empty( $attributes['iconColor'] ) ) {
213 - $css['fill'] = $attributes['iconColor'];
214 - }
215 312 return array_merge(
313 + [ 'fill' => Color::get_css( isset( $attributes['iconColor'] ) ? $attributes['iconColor'] : '' ) ],
216 314 Range::get_css([
217 315 'attributeValue' => $attributes['iconSize'],
218 316 'attribute_object_key' => 'value',
317 + 'isResponsive' => true,
318 + 'hasUnit' => true,
319 + 'defaultValue' => 18,
219 320 'unitDefaultValue' => 'px',
220 - 'defaultValue' => 18,
221 321 'property' => 'width',
322 + 'device' => $device,
222 323 ]),
223 324 Range::get_css([
224 325 'attributeValue' => $attributes['iconSize'],
225 326 'attribute_object_key' => 'value',
327 + 'isResponsive' => true,
328 + 'hasUnit' => true,
329 + 'defaultValue' => 18,
226 330 'unitDefaultValue' => 'px',
227 - 'defaultValue' => 18,
228 331 'property' => 'height',
332 + 'device' => $device,
229 333 ]),
230 334 $css,
231 335 );
232 336 }
@@ -231,13 +335,10 @@
231 335 );
232 336 }
233 337
234 338 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 339 return array_merge(
340 + [ 'background' => Color::get_css( isset( $attributes['iconBackgroundColor'] ) ? $attributes['iconBackgroundColor'] : '' ) ],
240 341 Range::get_css([
241 342 'attributeValue' => $attributes['iconBackgroundSize'],
242 343 'attribute_object_key' => 'value',
243 344 'defaultValue' => 48,
@@ -248,18 +349,14 @@
248 349 'attribute_object_key' => 'value',
249 350 'defaultValue' => 48,
250 351 'property' => 'height',
251 352 ]),
252 - $css,
253 353 );
254 354 }
255 355
256 356 public function get_content_timeline_connector_css( $attributes, $device = '' ) {
257 - $css = [];
258 - if ( ! empty( $attributes['thicknessColor'] ) ) {
259 - $css['background-color'] = $attributes['thicknessColor'];
260 - }
261 357 return array_merge(
358 + [ 'background' => Color::get_css( isset( $attributes['thicknessColor'] ) ? $attributes['thicknessColor'] : '' ) ],
262 359 Range::get_css([
263 360 'attributeValue' => $attributes['thickness'],
264 361 'attribute_object_key' => 'value',
265 362 'defaultValue' => 3,
@@ -264,14 +361,17 @@
264 361 'attribute_object_key' => 'value',
265 362 'defaultValue' => 3,
266 363 'property' => 'width',
267 364 ]),
268 - $css,
269 365 );
270 366 }
271 367
272 368 public function get_content_timeline_item_gap_css( $attributes, $device = '' ) {
273 - $css = [];
369 + $icon_size_css = [ '--ablocks-content-timeline-icon-size' => ( ! empty( $attributes['iconBackgroundSize'] ) ? $attributes['iconBackgroundSize'] : 48 ) . 'px' ];
370 + if ( $this->is_horizontal_timeline( $attributes ) ) {
371 + return $icon_size_css;
372 + }
373 + $css = '' === $device ? $icon_size_css : [];
274 374 return array_merge(
275 375 Range::get_css([
276 376 'attributeValue' => $attributes['itemGap'],
277 377 'attribute_object_key' => 'value',
@@ -279,8 +379,9 @@
279 379 'isResponsive' => true,
280 380 'hasUnit' => true,
281 381 'unitDefaultValue' => 'px',
282 382 'property' => 'margin-top',
383 + 'device' => $device,
283 384 ]),
284 385 $css,
285 386 );
286 387 }
@@ -287,12 +388,10 @@
287 388
288 389 public function get_content_timeline_content_css( $attributes, $device = '' ) {
289 390 $css = [];
290 391 $css['padding'] = '15px';
291 - if ( ! empty( $attributes['contentBackgroundColor'] ) ) {
292 - $css['background-color'] = $attributes['contentBackgroundColor'];
293 - }
294 392 return array_merge(
393 + [ 'background' => Color::get_css( isset( $attributes['contentBackgroundColor'] ) ? $attributes['contentBackgroundColor'] : '' ) ],
295 394 $css,
296 395 Dimensions::get_css( $attributes['contentPadding'] ?? [], 'padding', $device )
297 396 );
298 397 }
@@ -299,24 +398,25 @@
299 398
300 399 public function get_content_timeline_content_background_css( $attributes, $device = '' ) {
301 400 $css = [];
302 401 if ( ! empty( $attributes['contentBackgroundColor'] ) ) {
303 - $css['border-left-color'] = $attributes['contentBackgroundColor'];
304 - $css['border-right-color'] = $attributes['contentBackgroundColor'];
402 + $css['border-left-color'] = Color::get_css(
403 + isset( $attributes['contentBackgroundColor'] ) ? $attributes['contentBackgroundColor'] : '');
404 + $css['border-right-color'] = Color::get_css(
405 + isset( $attributes['contentBackgroundColor'] ) ? $attributes['contentBackgroundColor'] : '');
305 406 }
306 407 return $css;
307 408 }
308 - public function get_content_timeline_arrow_css( $attributes, $device = '' ) {
409 + public function get_content_timeline_connector_alignment_css( $attributes, $device = '' ) {
309 410 $css = [];
310 411 $arrowAlignment = $attributes['arrowAlignment'] ?? '';
311 - $iconBackgroundSize = $attributes['iconBackgroundSize'] ?? '';
312 412
313 413 if ( $arrowAlignment === 'top' ) {
314 - $css['height'] = '0px';
315 - $css['top'] = $iconBackgroundSize ? ( $iconBackgroundSize / 2 ) . 'px' : '0';
414 + $css['align-self'] = 'flex-start';
316 415 } elseif ( $arrowAlignment === 'bottom' ) {
317 - $css['height'] = $iconBackgroundSize ? ( $iconBackgroundSize / 2 ) . 'px' : '0';
318 - $css['bottom'] = '0';
416 + $css['align-self'] = 'flex-end';
417 + } else {
418 + $css['align-self'] = 'center';
319 419 }
320 420
321 421 return $css;
322 422 }
@@ -321,13 +421,27 @@
321 421 return $css;
322 422 }
323 423 public function get_content_timeline_date_alignment_css( $attributes, $device = '' ) {
324 424 $css = [];
425 + if ( $this->is_horizontal_timeline( $attributes ) ) {
426 + return [
427 + 'align-self' => 'stretch',
428 + 'text-align' => ! empty( $attributes['dateAlign'] ) ? $attributes['dateAlign'] : 'left',
429 + ];
430 + }
325 431
326 432 $arrowAlignment = $attributes['arrowAlignment'] ?? '';
327 433 $iconBackgroundSize = $attributes['iconBackgroundSize'] ?? '';
328 434
329 435 if ( $arrowAlignment === 'top' ) {
436 + $css['align-self'] = 'flex-start';
437 + } elseif ( $arrowAlignment === 'bottom' ) {
438 + $css['align-self'] = 'flex-end';
439 + } else {
440 + $css['align-self'] = 'center';
441 + }
442 +
443 + if ( $arrowAlignment === 'top' ) {
330 444 $css['margin-top'] = $iconBackgroundSize ? ( $iconBackgroundSize / 4 ) . 'px' : '0';
331 445 } elseif ( $arrowAlignment === 'bottom' ) {
332 446 $css['margin-bottom'] = $iconBackgroundSize ? ( $iconBackgroundSize / 4 ) . 'px' : '0';
333 447 }
@@ -335,15 +449,12 @@
335 449 return $css;
336 450 }
337 451
338 452 public function get_content_timeline_date_css( $attributes, $device = '' ) {
339 - $css = [];
340 - if ( ! empty( $attributes['dateColor'] ) ) {
341 - $css['color'] = $attributes['dateColor'];
342 - }
453 + $typographyValueGlobal = $attributes['dateTypographyGlobal'] ? $attributes['dateTypographyGlobal'] : [];
343 454 return array_merge(
344 - $css,
345 - Typography::get_css( $attributes['dateTypography'] ?? [], '', $device )
455 + [ 'color' => Color::get_css( isset( $attributes['dateColor'] ) ? $attributes['dateColor'] : '' ) ],
456 + Typography::get_css( $attributes['dateTypography'] ?? [], '', $device, $typographyValueGlobal )
346 457 );
347 458 }
348 459 public function get_content_timeline_date_mobile_css( $attributes, $device = '' ) {
349 460 $css = [];
@@ -349,12 +460,10 @@
349 460 $css = [];
350 461 if ( ! empty( $attributes['dateAlign'] ) ) {
351 462 $css['text-align'] = $attributes['dateAlign'];
352 463 }
353 - if ( ! empty( $attributes['dateBackground'] ) ) {
354 - $css['background'] = $attributes['dateBackground'];
355 - }
356 464 return array_merge(
465 + [ 'background' => Color::get_css( isset( $attributes['dateBackground'] ) ? $attributes['dateBackground'] : '' ) ],
357 466 $css,
358 467 Dimensions::get_css( $attributes['datePadding'] ?? [], 'padding', $device ),
359 468 Border::get_css( $attributes['dateBorder'] ?? [], '', $device )
360 469 );