PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.13.0
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.13.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 1.1.0 1.1.1 1.1.2 All 80 releases
← All changes | includes/blocks/progress-tracker/block.php +220 -0 2.7.62.13.0 View file →
@@ -1,0 +1,220 @@
1 +<?php
2 +namespace ABlocks\Blocks\ProgressTracker;
3 +
4 +if ( ! defined( 'ABSPATH' ) ) {
5 + exit;
6 +}
7 +
8 +use ABlocks\Classes\BlockBaseAbstract;
9 +use ABlocks\Classes\CssGenerator;
10 +use ABlocks\Classes\CssGeneratorV2;
11 +use ABlocks\Controls\Alignment;
12 +use ABlocks\Controls\TextShadow;
13 +use ABlocks\Controls\TextStroke;
14 +use ABlocks\Controls\Typography;
15 +use Google\Service\Slides\Shadow;
16 +use ABlocks\Controls\Border;
17 +use ABlocks\Controls\Range;
18 +use ABlocks\Controls\Color;
19 +
20 +class Block extends BlockBaseAbstract {
21 + protected $block_name = 'progress-tracker';
22 +
23 +
24 + public function build_css_v1( $attributes ) {
25 + $css_generator = new CssGenerator( $attributes, $this->block_name );
26 +
27 + // Generate wrapper CSS start
28 + $css_generator->add_class_styles(
29 + '{{WRAPPER}} .ablocks-block-progress-circle',
30 + $this->get_wrapper_css( $attributes ),
31 + $this->get_wrapper_css( $attributes, 'Tablet' ),
32 + $this->get_wrapper_css( $attributes, 'Mobile' )
33 + );
34 +
35 + $css_generator->add_class_styles(
36 + '{{WRAPPER}} .ablocks-block-progress__text',
37 + $this->get_content_css( $attributes ),
38 + $this->get_content_css( $attributes, 'Tablet' ),
39 + $this->get_content_css( $attributes, 'Mobile' )
40 + );
41 + // Progress Bar Background CSS
42 + $css_generator->add_class_styles(
43 + '{{WRAPPER}} .ablocks-block-progress-bar-track',
44 + $this->get_progress_bar_track_css( $attributes ),
45 + $this->get_progress_bar_track_css( $attributes, 'Tablet' ),
46 + $this->get_progress_bar_track_css( $attributes, 'Mobile' )
47 + );
48 +
49 + $css_generator->add_class_styles(
50 + '{{WRAPPER}} .ablocks-block-progress-bar-track:hover',
51 + $this->get_progress_bar_hover_css( $attributes ),
52 + $this->get_progress_bar_hover_css( $attributes, 'Tablet' ),
53 + $this->get_progress_bar_hover_css( $attributes, 'Mobile' )
54 + );
55 +
56 + // Progress Bar Progress CSS
57 + $css_generator->add_class_styles(
58 + '{{WRAPPER}} .ablocks-block-progress-bar',
59 + $this->get_progress_bar_css( $attributes )
60 + );
61 +
62 + // circle css
63 + $css_generator->add_class_styles(
64 + '{{WRAPPER}} .ablocks-block-progress-circle__svg-bar',
65 + $this->get_progress_circle_css( $attributes ),
66 + );
67 + $css_generator->add_class_styles(
68 + '{{WRAPPER}} .ablocks-block-progress-circle__svg-track',
69 + $this->get_progress_circle_bg_css( $attributes ),
70 + );
71 +
72 + return $css_generator->generate_css();
73 + }
74 +
75 +
76 + public function build_css_v2( $attributes ) {
77 + $css_generator = new CssGeneratorV2( $attributes, $this->block_name );
78 + // Generate wrapper CSS start
79 + $css_generator->add_class_styles(
80 + '{{WRAPPER}} .ablocks-block-progress-circle',
81 + $this->get_wrapper_css( $attributes ),
82 + $this->get_wrapper_css( $attributes, 'Tablet' ),
83 + $this->get_wrapper_css( $attributes, 'Mobile' )
84 + );
85 +
86 + $css_generator->add_class_styles(
87 + '{{WRAPPER}} .ablocks-block-progress__text',
88 + $this->get_content_css( $attributes ),
89 + $this->get_content_css( $attributes, 'Tablet' ),
90 + $this->get_content_css( $attributes, 'Mobile' )
91 + );
92 + // Progress Bar Background CSS
93 + $css_generator->add_class_styles(
94 + '{{WRAPPER}} .ablocks-block-progress-bar-track',
95 + $this->get_progress_bar_track_css( $attributes ),
96 + $this->get_progress_bar_track_css( $attributes, 'Tablet' ),
97 + $this->get_progress_bar_track_css( $attributes, 'Mobile' )
98 + );
99 +
100 + $css_generator->add_class_styles(
101 + '{{WRAPPER}} .ablocks-block-progress-bar-track:hover',
102 + $this->get_progress_bar_hover_css( $attributes ),
103 + $this->get_progress_bar_hover_css( $attributes, 'Tablet' ),
104 + $this->get_progress_bar_hover_css( $attributes, 'Mobile' )
105 + );
106 +
107 + // Progress Bar Progress CSS
108 + $css_generator->add_class_styles(
109 + '{{WRAPPER}} .ablocks-block-progress-bar',
110 + $this->get_progress_bar_css( $attributes )
111 + );
112 +
113 + // circle css
114 + $css_generator->add_class_styles(
115 + '{{WRAPPER}} .ablocks-block-progress-circle__svg-bar',
116 + $this->get_progress_circle_css( $attributes ),
117 + );
118 + $css_generator->add_class_styles(
119 + '{{WRAPPER}} .ablocks-block-progress-circle__svg-track',
120 + $this->get_progress_circle_bg_css( $attributes ),
121 + );
122 +
123 + return $css_generator->generate_css();
124 + }
125 +
126 + public function build_css( $attributes ) {
127 + if ( isset( $attributes['blockVersion'] ) && (int) $attributes['blockVersion'] === 2 ) {
128 + return $this->build_css_v2( $attributes );
129 + }
130 + return $this->build_css_v1( $attributes );
131 + }
132 +
133 +
134 + public function get_wrapper_css( $attributes, $device = '' ) {
135 + $alignment_key = 'value' . $device;
136 + $alignment = isset( $attributes['alignment'][ $alignment_key ] )
137 + ? $attributes['alignment'][ $alignment_key ]
138 + : 'center';
139 + switch ( $alignment ) {
140 + case 'center':
141 + $justify_content_value = 'center';
142 + break;
143 + case 'right':
144 + $justify_content_value = 'flex-end';
145 + break;
146 + default:
147 + $justify_content_value = 'flex-start';
148 + break;
149 + }
150 + return array(
151 + 'display' => 'flex',
152 + 'justify-content' => $justify_content_value,
153 + );
154 + }
155 +
156 +
157 + public function get_content_css( $attributes, $device = '' ) {
158 + $typography = isset( $attributes['contentTypography'] ) ? $attributes['contentTypography'] : '';
159 + $text_stroke = isset( $attributes['contentTextStroke'] ) ? $attributes['contentTextStroke'] : '';
160 + $text_shadow = isset( $attributes['contentTextShadow'] ) ? $attributes['contentTextShadow'] : '';
161 + $typographyValueGlobal = ! empty( $attributes['contentTypographyGlobal'] ) ? $attributes['contentTypographyGlobal'] : array();
162 + return array_merge(
163 + [ 'color' => Color::get_css( isset( $attributes['contentColor'] ) ? $attributes['contentColor'] : '' ) ],
164 + Typography::get_css( $typography, '', $device, $typographyValueGlobal ),
165 + TextStroke::get_css( $text_stroke, '', $device ),
166 + TextShadow::get_css( $text_shadow, '', $device )
167 + );
168 + }
169 + public function get_progress_bar_track_css( $attributes, $device = '' ) {
170 + return array_merge(
171 + [ 'background' => Color::get_css( isset( $attributes['barBackgroundColor'] ) ? $attributes['barBackgroundColor'] : '' ) ],
172 + Range::get_css([
173 + 'attributeValue' => $attributes['barHeightSize'],
174 + 'attribute_object_key' => 'value',
175 + 'isResponsive' => true,
176 + 'defaultValue' => 40,
177 + 'hasUnit' => true,
178 + 'unitDefaultValue' => 'px',
179 + 'property' => 'height',
180 + 'device' => $device,
181 + ]),
182 + isset( $attributes['barBorder'] ) ? Border::get_css( $attributes['barBorder'], '', $device ) : [],
183 + );
184 + }
185 + public function get_progress_bar_hover_css( $attributes, $device = '' ) {
186 + return array_merge(
187 + isset( $attributes['barBorder'] ) ? Border::get_hover_css( $attributes['barBorder'], '', $device ) : []
188 + );
189 + }
190 +
191 + public function get_progress_bar_css( $attributes ) {
192 + $css = [];
193 + if ( ! empty( $attributes['direction'] ) && $attributes['direction'] === 'left' ) {
194 + $css['justify-content'] = 'right';
195 + } elseif ( ! empty( $attributes['direction'] ) && $attributes['direction'] === 'right' ) {
196 + $css['justify-content'] = 'left';
197 + }
198 + return array_merge(
199 + $css,
200 + [ 'background' => Color::get_css( isset( $attributes['barProgressColor'] ) ? $attributes['barProgressColor'] : '' ) ]
201 + );
202 + }
203 +
204 + public function get_progress_circle_css( $attributes ) {
205 + return [ 'stroke' => Color::get_css( isset( $attributes['circleProgressColor'] ) ? $attributes['circleProgressColor'] : '' ) ];
206 + }
207 +
208 + public function get_progress_circle_bg_css( $attributes ) {
209 + return array_merge(
210 + [ 'stroke' => Color::get_css( isset( $attributes['circleBackgroundColor'] ) ? $attributes['circleBackgroundColor'] : '' ) ],
211 + Range::get_css([
212 + 'attributeValue' => $attributes['circleStrokeSize'],
213 + 'attribute_object_key' => 'value',
214 + 'defaultValue' => 10,
215 + 'unitDefaultValue' => 'px',
216 + 'property' => 'stroke-width'
217 + ]),
218 + );
219 + }
220 +}