PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.11.1
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.11.1
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 1.1.0 1.1.1 1.1.2 All 80 releases
ablocks / includes / blocks / interactive-circle-infographic / block.php

block.php in aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder 2.11.1, at includes/blocks/interactive-circle-infographic/block.php

495 lines 17.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace ABlocks\Blocks\InteractiveCircleInfographic;
3
4 use ABlocks\Classes\BlockBaseAbstract;
5 use ABlocks\Classes\CssGenerator;
6 use ABlocks\Controls\Alignment;
7 use ABlocks\Controls\Dimensions;
8 use ABlocks\Controls\Typography;
9 use ABlocks\Controls\Width;
10 use ABlocks\Controls\Border;
11 use ABlocks\Controls\Range;
12 use ABlocks\Controls\BoxShadow;
13
14 use ABlocks\Controls\Color;
15
16 class Block extends BlockBaseAbstract {
17
18 protected $block_name = 'interactive-circle-infographic';
19
20 public function build_css( $attributes ) {
21 $css_generator = new CssGenerator( $attributes, $this->block_name );
22 // Wrapper CSS
23 $css_generator->add_class_styles(
24 '{{WRAPPER}}',
25 $this->blockAlignment( $attributes, '' ),
26 $this->blockAlignment( $attributes, 'Tablet' ),
27 $this->blockAlignment( $attributes, 'Mobile' ),
28 );
29 // List CSS
30 $css_generator->add_class_styles(
31 '{{WRAPPER}} .ablocks-interactive-circle-wrapper',
32 $this->get_circle_radius( $attributes, '' ),
33 $this->get_circle_radius( $attributes, 'Tablet' ),
34 $this->get_circle_radius( $attributes, 'Mobile' ),
35 );
36 $css_generator->add_class_styles(
37 '{{WRAPPER}} .ablocks-interactive-circle',
38 $this->get_circle_style( $attributes, '' ),
39 $this->get_circle_style( $attributes, 'Tablet' ),
40 $this->get_circle_style( $attributes, 'Mobile' ),
41 );
42 $css_generator->add_class_styles(
43 '{{WRAPPER}} .ablocks-interactive-segment-content.ablocks-interactive-item-content',
44 $this->get_segment_adjustable_margin( $attributes, '' ),
45 $this->get_segment_adjustable_margin( $attributes, 'Tablet' ),
46 $this->get_segment_adjustable_margin( $attributes, 'Mobile' ),
47 );
48 $css_generator->add_class_styles(
49 '{{WRAPPER}} .ablocks-interactive-circle:hover',
50 $this->get_circle_style_hover( $attributes, '' ),
51 $this->get_circle_style_hover( $attributes, 'Tablet' ),
52 $this->get_circle_style_hover( $attributes, 'Mobile' ),
53 );
54 $css_generator->add_class_styles(
55 '{{WRAPPER}} .ablocks-interactive-item-inner',
56 $this->get_item_button_css( $attributes, '' ),
57 $this->get_item_button_css( $attributes, 'Tablet' ),
58 $this->get_item_button_css( $attributes, 'Mobile' ),
59 );
60
61 $css_generator->add_class_styles(
62 '{{WRAPPER}} .ablocks-interactive-segment',
63 $this->get_item_button_css( $attributes, '' ),
64 $this->get_item_button_css( $attributes, 'Tablet' ),
65 $this->get_item_button_css( $attributes, 'Mobile' ),
66 );
67
68 // Inner Circle CSS
69 $css_generator->add_class_styles(
70 '{{WRAPPER}} .ablocks-interactive-circle-inner',
71 $this->get_inner_circle_css( $attributes, '' ),
72 $this->get_inner_circle_css( $attributes, 'Tablet' ),
73 $this->get_inner_circle_css( $attributes, 'Mobile' ),
74 );
75 // Inner hover Circle CSS
76 $css_generator->add_class_styles(
77 '{{WRAPPER}} .ablocks-interactive-circle-inner:hover',
78 $this->get_inner_circle_css_hover( $attributes, '' ),
79 $this->get_inner_circle_css_hover( $attributes, 'Tablet' ),
80 $this->get_inner_circle_css_hover( $attributes, 'Mobile' ),
81 );
82 // Inner Circle Title CSS
83 $css_generator->add_class_styles(
84 '{{WRAPPER}} .ablocks-interactive-circle-inner h2',
85 $this->get_inner_circle_title_css( $attributes, '' ),
86 $this->get_inner_circle_title_css( $attributes, 'Tablet' ),
87 $this->get_inner_circle_title_css( $attributes, 'Mobile' ),
88 );
89 $css_generator->add_class_styles(
90 '{{WRAPPER}} .ablocks-interactive-circle-inner .ablocks-divider__pattern-css',
91 $this->get_inner_circle_divider_css( $attributes, '' ),
92 $this->get_inner_circle_divider_css( $attributes, 'Tablet' ),
93 $this->get_inner_circle_divider_css( $attributes, 'Mobile' ),
94 );
95 // Inner Circle Description CSS
96 $css_generator->add_class_styles(
97 '{{WRAPPER}} .ablocks-interactive-circle-inner p',
98 $this->get_inner_circle_description_css( $attributes, '' ),
99 $this->get_inner_circle_description_css( $attributes, 'Tablet' ),
100 $this->get_inner_circle_description_css( $attributes, 'Mobile' ),
101 );
102 // Inner Circle Description CSS
103 $css_generator->add_class_styles(
104 '{{WRAPPER}} .ablocks-interactive-circle-inner img',
105 $this->get_inner_circle_img_css( $attributes, '' ),
106 $this->get_inner_circle_img_css( $attributes, 'Tablet' ),
107 $this->get_inner_circle_img_css( $attributes, 'Mobile' ),
108 );
109
110 // Inner Circle CSS
111 $css_generator->add_class_styles(
112 '{{WRAPPER}} .ablocks-interactive-circle-content',
113 $this->get_inner_circle_css( $attributes, '' ),
114 $this->get_inner_circle_css( $attributes, 'Tablet' ),
115 $this->get_inner_circle_css( $attributes, 'Mobile' ),
116 );
117
118 // Inner Circle Title CSS
119 $css_generator->add_class_styles(
120 '{{WRAPPER}} .ablocks-interactive-circle-content h2',
121 $this->get_inner_circle_title_css( $attributes, '' ),
122 $this->get_inner_circle_title_css( $attributes, 'Tablet' ),
123 $this->get_inner_circle_title_css( $attributes, 'Mobile' ),
124 );
125 $css_generator->add_class_styles(
126 '{{WRAPPER}} .ablocks-interactive-circle-content .ablocks-divider__pattern-css',
127 $this->get_inner_circle_divider_css( $attributes, '' ),
128 $this->get_inner_circle_divider_css( $attributes, 'Tablet' ),
129 $this->get_inner_circle_divider_css( $attributes, 'Mobile' ),
130 );
131 // Inner Circle Description CSS
132 $css_generator->add_class_styles(
133 '{{WRAPPER}} .ablocks-interactive-circle-content p',
134 $this->get_inner_circle_description_css( $attributes, '' ),
135 $this->get_inner_circle_description_css( $attributes, 'Tablet' ),
136 $this->get_inner_circle_description_css( $attributes, 'Mobile' ),
137 );
138 // Inner Circle Description CSS
139 $css_generator->add_class_styles(
140 '{{WRAPPER}} .ablocks-interactive-circle-content img',
141 $this->get_inner_circle_img_css( $attributes, '' ),
142 $this->get_inner_circle_img_css( $attributes, 'Tablet' ),
143 $this->get_inner_circle_img_css( $attributes, 'Mobile' ),
144 );
145 // List Wrapper CSS
146 $css_generator->add_class_styles(
147 '{{WRAPPER}} .ablocks-interactive-item-content',
148 $this->get_list_wrapper_css( $attributes, '' ),
149 $this->get_list_wrapper_css( $attributes, 'Tablet' ),
150 $this->get_list_wrapper_css( $attributes, 'Mobile' ),
151 );
152
153 // Icon CSS
154 $css_generator->add_class_styles(
155 '{{WRAPPER}} .ablocks-interactive-item-content .ablocks-svg-icon',
156 $this->get_icon_css( $attributes, '' ),
157 $this->get_icon_css( $attributes, 'Tablet' ),
158 $this->get_icon_css( $attributes, 'Mobile' ),
159 );
160 // Icon hover css
161 $css_generator->add_class_styles(
162 '{{WRAPPER}} .ablocks-interactive-item-content .ablocks-svg-icon:hover',
163 $this->get_icon_hover_css( $attributes, '' ),
164 $this->get_icon_hover_css( $attributes, 'Tablet' ),
165 $this->get_icon_hover_css( $attributes, 'Mobile' ),
166 );
167
168 // List text CSS
169 $css_generator->add_class_styles(
170 '{{WRAPPER}} .ablocks-interactive-item-content .ablocks-interactive__item-text',
171 $this->get_list_text_css( $attributes ),
172 $this->get_list_text_css( $attributes, 'Tablet' ),
173 $this->get_list_text_css( $attributes, 'Mobile' ),
174 );
175
176 return $css_generator->generate_css();
177 }
178
179
180
181 public function blockAlignment( $attributes, $device = '' ) {
182 $css = [];
183 if ( empty( $attributes['alignment'] ) ) {
184 return $css;
185 }
186
187 $alignment = $attributes['alignment'];
188 $key = 'value' . $device;
189
190 $css['display'] = 'flex';
191 $css['justify-content'] = isset( $alignment[ $key ] )
192 ? $alignment[ $key ]
193 : 'center';
194 return $css;
195 }
196
197
198 public function get_circle_radius( $attributes, $device = '' ) {
199 $css = [];
200
201 if ( isset( $attributes['circleSize'][ 'value' . $device ] ) && ! empty( $attributes['circleSize'][ 'value' . $device ] )
202 && ( ! isset( $attributes['enableSegments'] ) || $attributes['enableSegments'] === false )
203 ) {
204 $css['height'] = $attributes['circleSize'][ 'value' . $device ] . 'px';
205 $css['width'] = $attributes['circleSize'][ 'value' . $device ] . 'px';
206 }
207
208 $alignment = isset( $attributes['alignment'] ) ? $attributes['alignment'] : '';
209 $css = array_merge(
210 $css,
211 Alignment::get_css( $alignment, 'justify-content', $device )
212 );
213
214 return $css;
215 }
216
217 public function get_circle_style( $attributes, $device = '' ) {
218 $css = [];
219 $circlePaddingUnit = isset($attributes['circlePadding']) ? $attributes['circlePadding'] : '';
220 $circleBorderUnit = isset($attributes['circleBorder']) ? $attributes['circleBorder'] : '';
221
222 return array_merge(
223 $css,
224 isset( $attributes['circleBorder'] ) ? Border::get_css( $attributes['circleBorder'], '', $device ) : [],
225 Dimensions::get_css( $circlePaddingUnit, 'padding', $device ) ,
226 BoxShadow::get_css( $attributes['circleBoxShadow'], '', $device ),
227
228 );
229 }
230 public function get_segment_adjustable_margin( $attributes, $device = '' ) {
231 $segMarginUnit = isset($attributes['segMargin']) ? $attributes['segMargin'] : '';
232 return array_merge(
233 Dimensions::get_css( $segMarginUnit, 'margin', $device ) ,
234
235 );
236 }
237
238 public function get_circle_style_hover( $attributes, $device = '' ) {
239 return array_merge(
240 Border::get_hover_css( $attributes['circleBorder'], '', $device ),
241 BoxShadow::get_hover_css( $attributes['circleBoxShadow'], '', $device )
242
243 );
244 }
245 public function get_item_button_css( $attributes, $device = '' ) {
246 $css = [] ;
247 $css['background'] = Color::get_css( $attributes['itemButtonColor'] ?? '' );
248
249 return array_merge(
250 $css
251 );
252 }
253 public function innerCircleStyle( $attributes, $device = '' ) {
254 $css = [];
255 $innerCirclePaddingUnit = isset($attributes['layoutPadding']) ? $attributes['layoutPadding'] : '';
256 $innerCircleBorderUnit = isset($attributes['layoutBorder']) ? $attributes['layoutBorder'] : '';
257
258 return array_merge(
259 $css,
260 isset( $attributes['layoutBorder'] ) ? Border::get_css( $attributes['layoutBorder'], '', $device ) : [],
261 Dimensions::get_css( $innerCirclePaddingUnit, 'padding', $device ) ,
262 BoxShadow::get_css( $attributes['circleBoxShadow'], '', $device ),
263
264 );
265 }
266
267
268 public function get_list_wrapper_css( $attributes, $device = '' ) {
269 $css = [];
270 $item_button = $attributes['itemButtonSize'][ 'value' . $device ] ?? '';
271 if ( ! empty( $item_button ) ) {
272 $css['height'] = $item_button . 'px';
273 $css['width'] = $item_button . 'px';
274 $css['text-align'] = 'center';
275 }
276 return $css;
277 }
278
279 public function get_inner_circle_css( $attributes, $device = '' ) {
280 $css = [];
281 $innerCirclePaddingUnit = isset($attributes['layoutPadding']) ? $attributes['layoutPadding'] : '';
282 $innerCircleBorderUnit = isset($attributes['layoutBorder']) ? $attributes['layoutBorder'] : '';
283
284 $css['background'] = Color::get_css( $attributes['layoutColor'] ?? '' );
285 $css['display'] = 'flex';
286 $css['flex-direction'] = 'column';
287 $css['border-radius'] = '50%';
288 $css['align-items'] = 'center';
289 $css['justify-content'] = 'center';
290 $css['text-align'] = 'center';
291 $css['overflow'] = 'hidden';
292
293 $inner_circle_css = Range::get_css([
294 'attributeValue' => $attributes['innerCircleSize'] ?? [],
295 'attribute_object_key' => 'value',
296 'isResponsive' => true,
297 'defaultValue' => 200,
298 'hasUnit' => true,
299 'unitDefaultValue' => 'px',
300 'property' => 'width',
301 'device' => $device,
302 ]);
303
304 $inner_circle_height_css = Range::get_css([
305 'attributeValue' => $attributes['innerCircleSize'] ?? [],
306 'attribute_object_key' => 'value',
307 'isResponsive' => true,
308 'defaultValue' => 200,
309 'hasUnit' => true,
310 'unitDefaultValue' => 'px',
311 'property' => 'height',
312 'device' => $device,
313 ]);
314 $inner_circle_item_gap_css = Range::get_css([
315 'attributeValue' => $attributes['itemSpacing'] ?? [],
316 'attribute_object_key' => 'value',
317 'isResponsive' => true,
318 'defaultValue' => 1,
319 'hasUnit' => true,
320 'unitDefaultValue' => 'px',
321 'property' => 'row-gap',
322 'device' => $device,
323 ]);
324
325 return array_merge( $css, $inner_circle_css, $inner_circle_height_css , $inner_circle_item_gap_css ,
326 Border::get_css( $innerCircleBorderUnit, 'border', $device ) ,
327 Dimensions::get_css( $innerCirclePaddingUnit, 'padding', $device ) ,
328 BoxShadow::get_css( $attributes['layoutBoxShadow'], '', $device ),
329
330 );
331 }
332
333 public function get_inner_circle_css_hover( $attributes, $device = '' ) {
334 return array_merge(
335 Border::get_hover_css( $attributes['layoutBorder'], '', $device ),
336 BoxShadow::get_hover_css( $attributes['layoutBoxShadow'], '', $device )
337
338 );
339
340 }
341 public function get_inner_circle_title_css( $attributes, $device = '' ) {
342 $css = [];
343 $css['color'] = Color::get_css( $attributes['titleColor'] ?? '' );
344 $typography = $attributes['titleTypography'] ?? [];
345 $typographyGlobal = ( isset( $attributes['titleTypographyGlobal'] ) ? $attributes['titleTypographyGlobal'] : '' );
346 return array_merge( $css, Typography::get_css( $typography, '', $device, $typographyGlobal ) );
347 }
348 public function get_inner_circle_divider_css( $attributes, $device = '' ) {
349 $css = [];
350 $css['border-bottom-color'] = Color::get_css( $attributes['borderColor'] ?? '' );
351 $css['border-bottom-style'] = ( $attributes['dividerPatternUrl'] ?? '' );
352 $inner_circle_divider_width_css = Range::get_css([
353 'attributeValue' => $attributes['dividerWidth'] ?? [],
354 'attribute_object_key' => 'value',
355 'isResponsive' => true,
356 'defaultValue' => 20,
357 'hasUnit' => true,
358 'unitDefaultValue' => 'px',
359 'property' => 'width',
360 'device' => $device,
361 ]);
362
363 $inner_circle_divider_height_css = Range::get_css([
364 'attributeValue' => $attributes['dividerWeight'] ?? [],
365 'attribute_object_key' => 'value',
366 'isResponsive' => true,
367 'defaultValue' => 20,
368 'hasUnit' => true,
369 'unitDefaultValue' => 'px',
370 'property' => 'border-bottom-width',
371 'device' => $device,
372 ]);
373 return array_merge( $css , $inner_circle_divider_width_css , $inner_circle_divider_height_css );
374 }
375 public function get_inner_circle_description_css( $attributes, $device = '' ) {
376 $css = [];
377 $css['color'] = Color::get_css( $attributes['textColor'] ?? '' );
378 $typography = $attributes['textTypography'] ?? [];
379 $typographyGlobal = ( isset( $attributes['textTypographyGlobal'] ) ? $attributes['textTypographyGlobal'] : '' );
380 return array_merge( $css, Typography::get_css( $typography, '', $device, $typographyGlobal ) );
381 }
382
383 public function get_inner_circle_img_css( $attributes, $device = '' ) {
384 $css = [];
385 $css['object-fit'] = ( $attributes['layoutImageType'] ?? '' );
386 $inner_circle_img_radius_css = Range::get_css([
387 'attributeValue' => $attributes['imgRadius'] ?? [],
388 'attribute_object_key' => 'value',
389 'isResponsive' => true,
390 'defaultValue' => 20,
391 'hasUnit' => true,
392 'unitDefaultValue' => 'px',
393 'property' => 'border-radius',
394 'device' => $device,
395 ]);
396 $inner_circle_img_width_css = Range::get_css([
397 'attributeValue' => $attributes['imgWidth'] ?? [],
398 'attribute_object_key' => 'value',
399 'isResponsive' => true,
400 'defaultValue' => 20,
401 'hasUnit' => true,
402 'unitDefaultValue' => 'px',
403 'property' => 'width',
404 'device' => $device,
405 ]);
406
407 $inner_circle_img_height_css = Range::get_css([
408 'attributeValue' => $attributes['imgHeight'] ?? [],
409 'attribute_object_key' => 'value',
410 'isResponsive' => true,
411 'defaultValue' => 20,
412 'hasUnit' => true,
413 'unitDefaultValue' => 'px',
414 'property' => 'height',
415 'device' => $device,
416 ]);
417 return array_merge( $css , $inner_circle_img_radius_css ?? [] , $inner_circle_img_width_css ?? [] , $inner_circle_img_height_css ?? [] );
418 }
419
420 public function get_icon_css( $attributes, $device = '' ) {
421 $css = [];
422 $border = isset( $attributes['border'] ) ? $attributes['border'] : '';
423 $padding = isset( $attributes['padding'] ) ? $attributes['padding'] : '';
424 $css['box-sizing'] = 'content-box';
425
426 if ( $attributes['iconType'] === 'stacked' ) {
427 $css['background'] = ! empty( $attributes['iconBackgroundColor'] ) ? $attributes['iconBackgroundColor'] : '#ddd';
428 $css['padding'] = '.2em';
429 $css['color'] = Color::get_css(
430 isset( $attributes['iconColor'] ) ? $attributes['iconColor'] : '#000000');
431
432 if ( $attributes['iconShape'] === 'circle' ) {
433 $css['border-radius'] = '50px';
434 }
435 } elseif ( $attributes['iconType'] === 'framed' ) {
436 $css['background'] = ! empty( $attributes['iconBackgroundColor'] ) ? $attributes['iconBackgroundColor'] : 'transparent';
437 $css['padding'] = '.2em';
438 $css['color'] = Color::get_css(
439 isset( $attributes['iconColor'] ) ? $attributes['iconColor'] : '#69727d');
440 $css['border'] = '2px solid ' . ( ! empty( $attributes['iconColor'] ) ? $attributes['iconColor'] : '#69727d' );
441
442 if ( $attributes['iconShape'] === 'circle' ) {
443 $css['border-radius'] = '50px';
444 }
445 }
446
447 if ( ! empty( $attributes[ 'iconColor' . $device ] ) && isset( $attributes[ 'iconColor' . $device ] ) ) {
448 $css['color'] = Color::get_css(
449 isset( $attributes['iconColor'] ) ? $attributes['iconColor'] : '');
450 $css['fill'] = Color::get_css(
451 isset( $attributes['iconColor'] ) ? $attributes['iconColor'] : '');
452
453 }
454
455 if ( ! empty( $attributes['iconBackgroundColor'] ) ) {
456 $css['background'] = Color::get_css(
457 isset( $attributes['iconBackgroundColor'] ) ? $attributes['iconBackgroundColor'] : '');
458
459 }
460
461
462 return array_merge(
463 $css,
464 Range::get_css([
465 'attributeValue' => $attributes['iconSize'],
466 'attribute_object_key' => 'value',
467 'isResponsive' => true,
468 'defaultValue' => 20,
469 'hasUnit' => true,
470 'unitDefaultValue' => 'px',
471 'property' => 'font-size',
472 'device' => $device,
473 ]),
474 isset( $attributes['border'] ) ? Border::get_css( $attributes['border'], '', $device ) : [],
475 Dimensions::get_css( $padding, 'padding', $device )
476 );
477 }
478
479
480 public function get_icon_hover_css( $attributes, $device = '' ) {
481 $border = isset( $attributes['border'] ) ? $attributes['border'] : '';
482 return array_merge(
483 isset( $attributes['border'] ) ? Border::get_hover_css( $attributes['border'], '', $device ) : []
484 );
485 }
486
487 public function get_list_text_css( $attributes, $device = '' ) {
488 $css = [];
489 $css['color'] = Color::get_css( $attributes['textColor'] ?? '' );
490 $typography = $attributes['itemTypography'] ?? [];
491 $typographyGlobal = ( isset( $attributes['itemTypographyGlobal'] ) ? $attributes['itemTypographyGlobal'] : '' );
492 return array_merge( $css, Typography::get_css( $typography, '', $device, $typographyGlobal ) );
493 }
494 }
495