| @@ -1,8 +1,13 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | namespace ABlocks\Blocks\Counter; |
| 3 | 3 | |
| 4 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 5 | + exit; | |
| 6 | +} | |
| 7 | + | |
| 4 | 8 | use ABlocks\Classes\BlockBaseAbstract; |
| 9 | +use ABlocks\Classes\CssGeneratorV2; | |
| 5 | 10 | use ABlocks\Classes\CssGenerator; |
| 6 | 11 | use ABlocks\Controls\Alignment; |
| 7 | 12 | use ABlocks\Controls\Typography; |
| 8 | 13 | use ABlocks\Controls\Dimensions; |
| @@ -7,26 +12,128 @@ | ||
| 7 | 12 | use ABlocks\Controls\Typography; |
| 8 | 13 | use ABlocks\Controls\Dimensions; |
| 9 | 14 | use ABlocks\Controls\Icon; |
| 10 | 15 | use ABlocks\Controls\Range; |
| 16 | +use ABlocks\Controls\Color; | |
| 11 | 17 | |
| 12 | 18 | class Block extends BlockBaseAbstract { |
| 13 | 19 | protected $block_name = 'counter'; |
| 14 | 20 | |
| 15 | - public function build_css( $attributes ) { | |
| 21 | + public function build_css_v1( $attributes ) { | |
| 16 | 22 | $css_generator = new CssGenerator( $attributes, $this->block_name ); |
| 17 | 23 | // wrapper css |
| 18 | 24 | $css_generator->add_class_styles( |
| 19 | - '{{WRAPPER}}', | |
| 20 | - $this->get_wrapper_css( $attributes ), | |
| 21 | - $this->get_wrapper_css( $attributes, 'Tablet' ), | |
| 22 | - $this->get_wrapper_css( $attributes, 'Mobile' ), | |
| 25 | + '{{WRAPPER}}.ablocks-block--counter--number .ablocks-block-container', | |
| 26 | + $this->get_number_wrapper_css( $attributes ), | |
| 27 | + $this->get_number_wrapper_css( $attributes, 'Tablet' ), | |
| 28 | + $this->get_number_wrapper_css( $attributes, 'Mobile' ), | |
| 23 | 29 | ); |
| 30 | + // number text css | |
| 24 | 31 | $css_generator->add_class_styles( |
| 25 | - '{{WRAPPER}}.ablocks-block--counter--number .ablocks-block-container', | |
| 32 | + '{{WRAPPER}} .ablocks-counter__content', | |
| 33 | + $this->get_number_text_css( $attributes ), | |
| 34 | + $this->get_number_text_css( $attributes, 'Tablet' ), | |
| 35 | + $this->get_number_text_css( $attributes, 'Mobile' ), | |
| 36 | + ); | |
| 37 | + // heading text css | |
| 38 | + $css_generator->add_class_styles( | |
| 39 | + '{{WRAPPER}} .ablocks-counter__text', | |
| 40 | + $this->get_heading_text_css( $attributes ), | |
| 41 | + $this->get_heading_text_css( $attributes, 'Tablet' ), | |
| 42 | + $this->get_heading_text_css( $attributes, 'Mobile' ), | |
| 43 | + ); | |
| 44 | + // counter bar css | |
| 45 | + | |
| 46 | + // counter circle css | |
| 47 | + $css_generator->add_class_styles( | |
| 48 | + '{{WRAPPER}}.ablocks-block--counter--bar .ablocks-bar-counter__background', | |
| 49 | + $this->get_counter_bar_bg_css( $attributes ) | |
| 50 | + ); | |
| 51 | + | |
| 52 | + $css_generator->add_class_styles( | |
| 53 | + '{{WRAPPER}}.ablocks-block--counter--bar .ablocks-bar-counter__progress', | |
| 54 | + $this->get_counter_bar_progress_css( $attributes ), | |
| 55 | + $this->get_counter_bar_progress_css( $attributes, 'Tablet' ), | |
| 56 | + $this->get_counter_bar_progress_css( $attributes, 'Mobile' ), | |
| 57 | + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_counter_bar_progress_css( $attributes, $device ); } ) | |
| 58 | + ); | |
| 59 | + $css_generator->add_class_styles( | |
| 60 | + '{{WRAPPER}}.ablocks-block--counter--circle', | |
| 61 | + $this->get_counter_circle_css( $attributes ), | |
| 62 | + $this->get_counter_circle_css( $attributes, 'Tablet' ), | |
| 63 | + $this->get_counter_circle_css( $attributes, 'Mobile' ), | |
| 64 | + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_counter_circle_css( $attributes, $device ); } ) | |
| 65 | + ); | |
| 66 | + $css_generator->add_class_styles( | |
| 67 | + '{{WRAPPER}}.ablocks-block--counter--circle .ablocks-circle-counter__background', | |
| 68 | + $this->get_counter_circle_bg_css( $attributes ) | |
| 69 | + ); | |
| 70 | + | |
| 71 | + $css_generator->add_class_styles( | |
| 72 | + '{{WRAPPER}}.ablocks-block--counter--circle .ablocks-circle-counter__progress', | |
| 73 | + $this->get_counter_circle_progress_css( $attributes ) | |
| 74 | + ); | |
| 75 | + | |
| 76 | + $css_generator->add_class_styles( | |
| 77 | + '{{WRAPPER}} .ablocks-icon-wrap', | |
| 78 | + Icon::get_wrapper_css( $attributes ), | |
| 79 | + Icon::get_wrapper_css( $attributes, 'Tablet' ), | |
| 80 | + Icon::get_wrapper_css( $attributes, 'Mobile' ), | |
| 81 | + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return Icon::get_wrapper_css( $attributes, $device ); } ) | |
| 82 | + ); | |
| 83 | + $css_generator->add_class_styles( | |
| 84 | + '{{WRAPPER}} .ablocks-icon-wrap:hover', | |
| 85 | + Icon::get_wrapper_hover_css( $attributes ), | |
| 86 | + Icon::get_wrapper_hover_css( $attributes, 'Tablet' ), | |
| 87 | + Icon::get_wrapper_hover_css( $attributes, 'Mobile' ), | |
| 88 | + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return Icon::get_wrapper_hover_css( $attributes, $device ); } ) | |
| 89 | + ); | |
| 90 | + | |
| 91 | + $css_generator->add_class_styles( | |
| 92 | + '{{WRAPPER}} .ablocks-icon-wrap img.ablocks-image-icon', | |
| 93 | + Icon::get_element_image_css( $attributes ), | |
| 94 | + Icon::get_element_image_css( $attributes, 'Tablet' ), | |
| 95 | + Icon::get_element_image_css( $attributes, 'Mobile' ), | |
| 96 | + ); | |
| 97 | + $css_generator->add_class_styles( | |
| 98 | + '{{WRAPPER}} .ablocks-icon-wrap img.ablocks-image-icon:hover', | |
| 99 | + Icon::get_element_image_hover_css( $attributes ), | |
| 100 | + Icon::get_element_image_hover_css( $attributes, 'Tablet' ), | |
| 101 | + Icon::get_element_image_hover_css( $attributes, 'Mobile' ), | |
| 102 | + ); | |
| 103 | + $css_generator->add_class_styles( | |
| 104 | + '{{WRAPPER}} .ablocks-icon-wrap svg.ablocks-svg-icon', | |
| 105 | + Icon::get_element_css( $attributes ), | |
| 106 | + Icon::get_element_css( $attributes, 'Tablet' ), | |
| 107 | + Icon::get_element_css( $attributes, 'Mobile' ), | |
| 108 | + ); | |
| 109 | + $css_generator->add_class_styles( | |
| 110 | + '{{WRAPPER}} .ablocks-icon-wrap svg.ablocks-svg-icon:hover', | |
| 111 | + Icon::get_element_image_hover_css( $attributes ), | |
| 112 | + Icon::get_element_image_hover_css( $attributes, 'Tablet' ), | |
| 113 | + Icon::get_element_image_hover_css( $attributes, 'Mobile' ), | |
| 114 | + ); | |
| 115 | + | |
| 116 | + return $css_generator->generate_css(); | |
| 117 | + } | |
| 118 | + public function build_css_v2( $attributes ) { | |
| 119 | + $css_generator = new CssGeneratorV2( $attributes, $this->block_name ); | |
| 120 | + // wrapper css | |
| 121 | + $css_generator->add_class_styles( | |
| 122 | + '{{WRAPPER}}.ablocks-block--counter--bar:not(.ablocks-has-container), | |
| 123 | + {{WRAPPER}}.ablocks-block--counter--bar .ablocks-block-container', | |
| 124 | + $this->get_counter_bar_css( $attributes ), | |
| 125 | + $this->get_counter_bar_css( $attributes, 'Tablet' ), | |
| 126 | + $this->get_counter_bar_css( $attributes, 'Mobile' ), | |
| 127 | + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_counter_bar_css( $attributes, $device ); } ) | |
| 128 | + ); | |
| 129 | + $css_generator->add_class_styles( | |
| 130 | + '{{WRAPPER}}.ablocks-block--counter--number:not(.ablocks-has-container), | |
| 131 | + {{WRAPPER}}.ablocks-block--counter--number .ablocks-block-container', | |
| 26 | 132 | $this->get_number_wrapper_css( $attributes ), |
| 27 | 133 | $this->get_number_wrapper_css( $attributes, 'Tablet' ), |
| 28 | 134 | $this->get_number_wrapper_css( $attributes, 'Mobile' ), |
| 135 | + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_number_wrapper_css( $attributes, $device ); } ) | |
| 29 | 136 | ); |
| 30 | 137 | // number text css |
| 31 | 138 | $css_generator->add_class_styles( |
| 32 | 139 | '{{WRAPPER}} .ablocks-counter__content', |
| @@ -32,8 +139,9 @@ | ||
| 32 | 139 | '{{WRAPPER}} .ablocks-counter__content', |
| 33 | 140 | $this->get_number_text_css( $attributes ), |
| 34 | 141 | $this->get_number_text_css( $attributes, 'Tablet' ), |
| 35 | 142 | $this->get_number_text_css( $attributes, 'Mobile' ), |
| 143 | + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_number_text_css( $attributes, $device ); } ) | |
| 36 | 144 | ); |
| 37 | 145 | // heading text css |
| 38 | 146 | $css_generator->add_class_styles( |
| 39 | 147 | '{{WRAPPER}} .ablocks-counter__text', |
| @@ -39,8 +147,9 @@ | ||
| 39 | 147 | '{{WRAPPER}} .ablocks-counter__text', |
| 40 | 148 | $this->get_heading_text_css( $attributes ), |
| 41 | 149 | $this->get_heading_text_css( $attributes, 'Tablet' ), |
| 42 | 150 | $this->get_heading_text_css( $attributes, 'Mobile' ), |
| 151 | + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_heading_text_css( $attributes, $device ); } ) | |
| 43 | 152 | ); |
| 44 | 153 | // counter bar css |
| 45 | 154 | |
| 46 | 155 | // counter circle css |
| @@ -52,17 +161,29 @@ | ||
| 52 | 161 | $css_generator->add_class_styles( |
| 53 | 162 | '{{WRAPPER}}.ablocks-block--counter--bar .ablocks-bar-counter__progress', |
| 54 | 163 | $this->get_counter_bar_progress_css( $attributes ), |
| 55 | 164 | $this->get_counter_bar_progress_css( $attributes, 'Tablet' ), |
| 56 | - $this->get_counter_bar_progress_css( $attributes, 'Mobile' ) | |
| 165 | + $this->get_counter_bar_progress_css( $attributes, 'Mobile' ), | |
| 166 | + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_counter_bar_progress_css( $attributes, $device ); } ) | |
| 57 | 167 | ); |
| 168 | + | |
| 169 | + // double for transform rotate issue in frontend | |
| 58 | 170 | $css_generator->add_class_styles( |
| 59 | - '{{WRAPPER}}.ablocks-block--counter--circle', | |
| 171 | + '{{WRAPPER}}.ablocks-block--counter--circle:not(.ablocks-has-block-container)', | |
| 60 | 172 | $this->get_counter_circle_css( $attributes ), |
| 61 | 173 | $this->get_counter_circle_css( $attributes, 'Tablet' ), |
| 62 | - $this->get_counter_circle_css( $attributes, 'Mobile' ) | |
| 174 | + $this->get_counter_circle_css( $attributes, 'Mobile' ), | |
| 175 | + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_counter_circle_css( $attributes, $device ); } ) | |
| 63 | 176 | ); |
| 177 | + | |
| 64 | 178 | $css_generator->add_class_styles( |
| 179 | + '{{WRAPPER}} .ablocks-block-container', | |
| 180 | + $this->get_counter_circle_css( $attributes ), | |
| 181 | + $this->get_counter_circle_css( $attributes, 'Tablet' ), | |
| 182 | + $this->get_counter_circle_css( $attributes, 'Mobile' ), | |
| 183 | + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_counter_circle_css( $attributes, $device ); } ) | |
| 184 | + ); | |
| 185 | + $css_generator->add_class_styles( | |
| 65 | 186 | '{{WRAPPER}}.ablocks-block--counter--circle .ablocks-circle-counter__background', |
| 66 | 187 | $this->get_counter_circle_bg_css( $attributes ) |
| 67 | 188 | ); |
| 68 | 189 | |
| @@ -74,15 +195,24 @@ | ||
| 74 | 195 | $css_generator->add_class_styles( |
| 75 | 196 | '{{WRAPPER}} .ablocks-icon-wrap', |
| 76 | 197 | Icon::get_wrapper_css( $attributes ), |
| 77 | 198 | Icon::get_wrapper_css( $attributes, 'Tablet' ), |
| 78 | - Icon::get_wrapper_css( $attributes, 'Mobile' ) | |
| 199 | + Icon::get_wrapper_css( $attributes, 'Mobile' ), | |
| 200 | + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return Icon::get_wrapper_css( $attributes, $device ); } ) | |
| 79 | 201 | ); |
| 80 | 202 | $css_generator->add_class_styles( |
| 203 | + '{{WRAPPER}} .ablocks-icon-wrap:hover', | |
| 204 | + Icon::get_wrapper_hover_css( $attributes ), | |
| 205 | + Icon::get_wrapper_hover_css( $attributes, 'Tablet' ), | |
| 206 | + Icon::get_wrapper_hover_css( $attributes, 'Mobile' ), | |
| 207 | + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return Icon::get_wrapper_hover_css( $attributes, $device ); } ) | |
| 208 | + ); | |
| 209 | + $css_generator->add_class_styles( | |
| 81 | 210 | '{{WRAPPER}} .ablocks-icon-wrap img.ablocks-image-icon', |
| 82 | 211 | Icon::get_element_image_css( $attributes ), |
| 83 | 212 | Icon::get_element_image_css( $attributes, 'Tablet' ), |
| 84 | 213 | Icon::get_element_image_css( $attributes, 'Mobile' ), |
| 214 | + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return Icon::get_element_image_css( $attributes, $device ); } ) | |
| 85 | 215 | ); |
| 86 | 216 | $css_generator->add_class_styles( |
| 87 | 217 | '{{WRAPPER}} .ablocks-icon-wrap img.ablocks-image-icon:hover', |
| 88 | 218 | Icon::get_element_image_hover_css( $attributes ), |
| @@ -87,8 +217,9 @@ | ||
| 87 | 217 | '{{WRAPPER}} .ablocks-icon-wrap img.ablocks-image-icon:hover', |
| 88 | 218 | Icon::get_element_image_hover_css( $attributes ), |
| 89 | 219 | Icon::get_element_image_hover_css( $attributes, 'Tablet' ), |
| 90 | 220 | Icon::get_element_image_hover_css( $attributes, 'Mobile' ), |
| 221 | + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return Icon::get_element_image_hover_css( $attributes, $device ); } ) | |
| 91 | 222 | ); |
| 92 | 223 | $css_generator->add_class_styles( |
| 93 | 224 | '{{WRAPPER}} .ablocks-icon-wrap svg.ablocks-svg-icon', |
| 94 | 225 | Icon::get_element_css( $attributes ), |
| @@ -93,8 +224,9 @@ | ||
| 93 | 224 | '{{WRAPPER}} .ablocks-icon-wrap svg.ablocks-svg-icon', |
| 94 | 225 | Icon::get_element_css( $attributes ), |
| 95 | 226 | Icon::get_element_css( $attributes, 'Tablet' ), |
| 96 | 227 | Icon::get_element_css( $attributes, 'Mobile' ), |
| 228 | + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return Icon::get_element_css( $attributes, $device ); } ) | |
| 97 | 229 | ); |
| 98 | 230 | $css_generator->add_class_styles( |
| 99 | 231 | '{{WRAPPER}} .ablocks-icon-wrap svg.ablocks-svg-icon:hover', |
| 100 | 232 | Icon::get_element_image_hover_css( $attributes ), |
| @@ -99,33 +231,56 @@ | ||
| 99 | 231 | '{{WRAPPER}} .ablocks-icon-wrap svg.ablocks-svg-icon:hover', |
| 100 | 232 | Icon::get_element_image_hover_css( $attributes ), |
| 101 | 233 | Icon::get_element_image_hover_css( $attributes, 'Tablet' ), |
| 102 | 234 | Icon::get_element_image_hover_css( $attributes, 'Mobile' ), |
| 235 | + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return Icon::get_element_image_hover_css( $attributes, $device ); } ) | |
| 103 | 236 | ); |
| 104 | 237 | |
| 105 | 238 | return $css_generator->generate_css(); |
| 106 | 239 | } |
| 107 | 240 | |
| 108 | - public function get_wrapper_css( $attributes, $device = '' ) { | |
| 109 | - $alignment = ! empty( $attributes['alignment'] ) ? $attributes['alignment'] : ''; | |
| 110 | - return Alignment::get_css( $alignment, 'text-align', $device ); | |
| 241 | + public function build_css( $attributes ) { | |
| 242 | + if ( isset( $attributes['blockVersion'] ) && (int) $attributes['blockVersion'] === 2 ) { | |
| 243 | + return $this->build_css_v2( $attributes ); | |
| 244 | + } | |
| 245 | + return $this->build_css_v1( $attributes ); | |
| 111 | 246 | } |
| 247 | + | |
| 248 | + public function get_counter_bar_css( $attributes, $device = '' ) { | |
| 249 | + $css = []; | |
| 250 | + | |
| 251 | + $alignment = isset( $attributes['alignment'] ) ? $attributes['alignment'] : []; | |
| 252 | + $device_key = 'value' . $device; | |
| 253 | + | |
| 254 | + $alignment_value = isset( $alignment[ $device_key ] ) ? $alignment[ $device_key ] : ( $alignment['value'] ?? '' ); | |
| 255 | + | |
| 256 | + if ( $alignment_value ) { | |
| 257 | + $css['align-items'] = $alignment_value; | |
| 258 | + } | |
| 259 | + | |
| 260 | + return $css; | |
| 261 | + } | |
| 262 | + | |
| 112 | 263 | public function get_number_wrapper_css( $attributes, $device = '' ) { |
| 113 | - $counterNumberWrapperCSS = array( | |
| 114 | - 'display' => 'flex', | |
| 115 | - 'align-items' => 'center', | |
| 116 | - ); | |
| 117 | - if ( isset( $attributes['alignment'][ 'value' . $device ] ) ) { | |
| 118 | - $counterNumberWrapperCSS['justify-content'] = $attributes['alignment'][ 'value' . $device ]; | |
| 264 | + $counterNumberWrapperCSS = []; | |
| 265 | + $alignment = isset( $attributes['alignment'][ 'value' . $device ] ) | |
| 266 | + ? $attributes['alignment'][ 'value' . $device ] | |
| 267 | + : ''; | |
| 268 | + | |
| 269 | + if ( $alignment ) { | |
| 270 | + $counterNumberWrapperCSS['justify-content'] = $alignment; | |
| 271 | + | |
| 272 | + if ( $alignment === 'center' ) { | |
| 273 | + $counterNumberWrapperCSS['text-align'] = 'center'; | |
| 274 | + } elseif ( $alignment === 'flex-end' ) { | |
| 275 | + $counterNumberWrapperCSS['text-align'] = 'right'; | |
| 276 | + } | |
| 119 | 277 | } |
| 120 | 278 | return $counterNumberWrapperCSS; |
| 121 | 279 | } |
| 280 | + | |
| 122 | 281 | public function get_number_text_css( $attributes, $device = '' ) { |
| 123 | 282 | $css = []; |
| 124 | - $number_color = ! empty( $attributes['numberColor'] ) ? $attributes['numberColor'] : ''; | |
| 125 | - if ( $number_color ) { | |
| 126 | - $css['color'] = $attributes['numberColor']; | |
| 127 | - } | |
| 128 | 283 | if ( isset( $attributes['mediaPosition'] ) && $attributes['mediaPosition'] === 'leftOfNumber' || isset( $attributes['mediaPosition'] ) && $attributes['mediaPosition'] === 'rightOfNumber' || isset( $attributes['layout'] ) && $attributes['layout'] === 'bar' ) { |
| 129 | 284 | $css['display'] = 'inline-flex'; |
| 130 | 285 | $css['align-items'] = 'center'; |
| 131 | 286 | $css['justify-content'] = 'center'; |
| @@ -131,10 +286,12 @@ | ||
| 131 | 286 | $css['justify-content'] = 'center'; |
| 132 | 287 | } else { |
| 133 | 288 | $css['display'] = 'block'; |
| 134 | 289 | } |
| 290 | + $typographyGlobal = ( isset( $attributes['numberTypographyGlobal'] ) ? $attributes['numberTypographyGlobal'] : '' ); | |
| 135 | 291 | return array_merge( |
| 136 | - isset( $attributes['numberTypography'] ) ? Typography::get_css( $attributes['numberTypography'], '', $device ) : [], | |
| 292 | + [ 'color' => Color::get_css( isset( $attributes['numberColor'] ) ? $attributes['numberColor'] : '' ) ], | |
| 293 | + isset( $attributes['numberTypography'] ) ? Typography::get_css( $attributes['numberTypography'], '', $device, $typographyGlobal ) : [], | |
| 137 | 294 | isset( $attributes['numberMargin'] ) ? Dimensions::get_css( $attributes['numberMargin'], 'margin', '', $device ) : [], |
| 138 | 295 | $css |
| 139 | 296 | ); |
| 140 | 297 | } |
| @@ -139,36 +296,23 @@ | ||
| 139 | 296 | ); |
| 140 | 297 | } |
| 141 | 298 | |
| 142 | 299 | public function get_heading_text_css( $attributes, $device = '' ) { |
| 143 | - $css = []; | |
| 144 | - $heading_color = ! empty( $attributes['headingColor'] ) ? $attributes['headingColor'] : ''; | |
| 145 | - if ( $heading_color ) { | |
| 146 | - $css['color'] = $attributes['headingColor']; | |
| 147 | - } | |
| 300 | + $typographyGlobal = ( isset( $attributes['headingTypographyGlobal'] ) ? $attributes['headingTypographyGlobal'] : '' ); | |
| 148 | 301 | return array_merge( |
| 149 | - isset( $attributes['headingTypography'] ) ? Typography::get_css( $attributes['headingTypography'], '', $device ) : [], | |
| 302 | + [ 'color' => Color::get_css( isset( $attributes['headingColor'] ) ? $attributes['headingColor'] : '' ) ], | |
| 303 | + isset( $attributes['headingTypography'] ) ? Typography::get_css( $attributes['headingTypography'], '', $device, $typographyGlobal ) : [], | |
| 150 | 304 | isset( $attributes['headingMargin'] ) ? Dimensions::get_css( $attributes['headingMargin'], 'margin', $device ) : [], |
| 151 | - $css | |
| 152 | 305 | ); |
| 153 | 306 | } |
| 154 | 307 | |
| 155 | 308 | |
| 156 | 309 | public function get_counter_bar_bg_css( $attributes ) { |
| 157 | - $counter_bar_bg_css = []; | |
| 158 | - | |
| 159 | - if ( ! empty( $attributes['barBackgroundColor'] ) ) { | |
| 160 | - $counter_bar_bg_css['background'] = $attributes['barBackgroundColor']; | |
| 161 | - } | |
| 162 | - | |
| 163 | - return $counter_bar_bg_css; | |
| 310 | + return [ 'background' => Color::get_css( isset( $attributes['barBackgroundColor'] ) ? $attributes['barBackgroundColor'] : '' ) ]; | |
| 164 | 311 | } |
| 165 | 312 | |
| 166 | 313 | public function get_counter_bar_progress_css( $attributes, $device = '' ) { |
| 167 | 314 | $counter_bar_progress_css = []; |
| 168 | - if ( ! empty( $attributes['barProgressColor'] ) ) { | |
| 169 | - $counter_bar_progress_css['background'] = $attributes['barProgressColor']; | |
| 170 | - } | |
| 171 | 315 | if ( ! empty( $attributes['barHeadingPosition'] ) ) { |
| 172 | 316 | if ( $attributes['barHeadingPosition'] === 'inner' ) { |
| 173 | 317 | $counter_bar_progress_css['justify-content'] = 'space-between'; |
| 174 | 318 | } elseif ( |
| @@ -179,8 +323,9 @@ | ||
| 179 | 323 | } |
| 180 | 324 | } |
| 181 | 325 | |
| 182 | 326 | return array_merge( |
| 327 | + [ 'background' => Color::get_css( isset( $attributes['barProgressColor'] ) ? $attributes['barProgressColor'] : '' ) ], | |
| 183 | 328 | Range::get_css([ |
| 184 | 329 | 'attributeValue' => $attributes['barSize'], |
| 185 | 330 | 'attribute_object_key' => 'value', |
| 186 | 331 | 'isResponsive' => true, |
| @@ -194,36 +339,26 @@ | ||
| 194 | 339 | ); |
| 195 | 340 | } |
| 196 | 341 | |
| 197 | 342 | public function get_counter_circle_css( $attributes, $device = '' ) { |
| 198 | - $counterCircleCSS = array( | |
| 199 | - 'align-items' => 'center', | |
| 200 | - ); | |
| 343 | + $css = []; | |
| 344 | + | |
| 201 | 345 | if ( isset( $attributes['alignment'][ 'value' . $device ] ) ) { |
| 202 | - $alignmentValue = $attributes['alignment'][ 'value' . $device ]; | |
| 203 | - | |
| 204 | - if ( $alignmentValue === 'center' ) { | |
| 205 | - $counterCircleCSS['align-items'] = 'center'; | |
| 206 | - } elseif ( $alignmentValue === 'left' ) { | |
| 207 | - $counterCircleCSS['align-items'] = 'flex-start'; | |
| 208 | - } elseif ( $alignmentValue === 'right' ) { | |
| 209 | - $counterCircleCSS['align-items'] = 'flex-end'; | |
| 210 | - } | |
| 346 | + $css['justify-content'] = $attributes['alignment'][ 'value' . $device ]; | |
| 347 | + $css['align-items'] = $attributes['alignment'][ 'value' . $device ]; | |
| 211 | 348 | } |
| 212 | - return $counterCircleCSS; | |
| 349 | + return $css; | |
| 213 | 350 | } |
| 351 | + | |
| 352 | + | |
| 214 | 353 | public function get_counter_circle_bg_css( $attributes ) { |
| 215 | 354 | $counter_circle_bg_css = []; |
| 216 | - | |
| 217 | - if ( ! empty( $attributes['circleBackgroundColor'] ) ) { | |
| 218 | - $counter_circle_bg_css['stroke'] = $attributes['circleBackgroundColor']; | |
| 219 | - } | |
| 220 | - | |
| 221 | 355 | if ( ! empty( $attributes['circleStrokeSize'] ) ) { |
| 222 | 356 | $counter_circle_bg_css['stroke-width'] = $attributes['circleStrokeSize']; |
| 223 | 357 | } |
| 224 | 358 | |
| 225 | 359 | return array_merge( |
| 360 | + [ 'stroke' => Color::get_css( isset( $attributes['circleBackgroundColor'] ) ? $attributes['circleBackgroundColor'] : '' ) ], | |
| 226 | 361 | Range::get_css([ |
| 227 | 362 | 'attributeValue' => $attributes['circleStrokeSize'], |
| 228 | 363 | 'attribute_object_key' => 'value', |
| 229 | 364 | 'defaultValue' => 20, |
| @@ -233,15 +368,10 @@ | ||
| 233 | 368 | ); |
| 234 | 369 | } |
| 235 | 370 | |
| 236 | 371 | public function get_counter_circle_progress_css( $attributes ) { |
| 237 | - $counter_circle_progress_css = []; | |
| 238 | - | |
| 239 | - if ( ! empty( $attributes['circleProgressColor'] ) ) { | |
| 240 | - $counter_circle_progress_css['stroke'] = $attributes['circleProgressColor']; | |
| 241 | - } | |
| 242 | - | |
| 243 | 372 | return array_merge( |
| 373 | + [ 'stroke' => Color::get_css( isset( $attributes['circleProgressColor'] ) ? $attributes['circleProgressColor'] : '' ) ], | |
| 244 | 374 | Range::get_css([ |
| 245 | 375 | 'attributeValue' => $attributes['circleStrokeSize'], |
| 246 | 376 | 'attribute_object_key' => 'value', |
| 247 | 377 | 'defaultValue' => 20, |
| @@ -246,9 +376,8 @@ | ||
| 246 | 376 | 'attribute_object_key' => 'value', |
| 247 | 377 | 'defaultValue' => 20, |
| 248 | 378 | 'property' => 'stroke-width', |
| 249 | 379 | ]), |
| 250 | - $counter_circle_progress_css, | |
| 251 | 380 | ); |
| 252 | 381 | } |
| 253 | 382 | |
| 254 | 383 | } |