PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.9.1
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.9.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 / chart / block.php

block.php in aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder 2.9.1, at includes/blocks/chart/block.php

65 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace ABlocks\Blocks\Chart;
3
4 use ABlocks\Controls\Range;
5
6
7 if ( ! defined( 'ABSPATH' ) ) {
8 exit;
9 }
10
11 use ABlocks\Classes\BlockBaseAbstract;
12 use ABlocks\Classes\CssGenerator;
13 use ABlocks\Controls\Alignment;
14
15 class Block extends BlockBaseAbstract {
16 protected $block_name = 'chart';
17 protected $script_depends = [ 'ablocks-chart.js-script' ];
18 public function build_css( $attributes ) {
19 $css_generator = new CssGenerator( $attributes, $this->block_name );
20 $css_generator->add_class_styles(
21 '{{WRAPPER}}',
22 $this->get_wrapper_css( $attributes ),
23 $this->get_wrapper_css( $attributes, 'Tablet' ),
24 $this->get_wrapper_css( $attributes, 'Mobile' )
25 );
26
27 $css_generator->add_class_styles(
28 '{{WRAPPER}} .ablocks-chart-canvas',
29 $this->get_chart_css( $attributes ),
30 $this->get_chart_css( $attributes, 'Tablet' ),
31 $this->get_chart_css( $attributes, 'Mobile' )
32 );
33
34 return $css_generator->generate_css();
35 }
36
37 public function get_wrapper_css( $attributes, $device = '' ) {
38 return isset( $attributes['alignment'] ) ? Alignment::get_css( $attributes['alignment'], 'text-align', $device ) : [];
39 }
40
41 public function get_chart_css( $attributes, $device = '' ) {
42 $css = [];
43 $widthCSS = Range::get_css([
44 'attributeValue' => $attributes['chartWidth'],
45 'attribute_object_key' => 'value',
46 'isResponsive' => true,
47 'defaultValue' => 95,
48 'hasUnit' => true,
49 'unitDefaultValue' => '%',
50 'property' => 'width',
51 'device' => $device,
52 ]);
53 if ( ! empty( $widthCSS['width'] ) ) {
54 $widthCSS['width'] = $widthCSS['width'] . ' !important';
55 }
56 $heightCSS = [];
57 $heightCSS['height'] = 'auto' . ' !important';
58 return array_merge(
59 $widthCSS,
60 $heightCSS
61 );
62 }
63
64 }
65