| @@ -1,8 +1,12 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace ABlocks\Blocks\FormBuilder; |
| 4 | 4 | |
| 5 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 6 | + exit; | |
| 7 | +} | |
| 8 | + | |
| 5 | 9 | use ABlocks\Classes\BlockBaseAbstract; |
| 6 | 10 | use ABlocks\Classes\CssGenerator; |
| 7 | 11 | use ABlocks\Controls\Alignment; |
| 8 | 12 | use ABlocks\Controls\Typography; |
| @@ -8,9 +12,10 @@ | ||
| 8 | 12 | use ABlocks\Controls\Typography; |
| 9 | 13 | use ABlocks\Controls\Dimensions; |
| 10 | 14 | use ABlocks\Controls\Border; |
| 11 | 15 | use ABlocks\Controls\Range; |
| 12 | - | |
| 16 | +use ABlocks\Classes\CssGeneratorV2; | |
| 17 | +use ABlocks\Controls\Color; | |
| 13 | 18 | class Block extends BlockBaseAbstract { |
| 14 | 19 | |
| 15 | 20 | protected $block_name = 'form-builder'; |
| 16 | 21 | |
| @@ -30,12 +35,19 @@ | ||
| 30 | 35 | } |
| 31 | 36 | return $content; |
| 32 | 37 | } |
| 33 | 38 | |
| 34 | - public function build_css( $attributes ) { | |
| 39 | + public function build_css_v1( $attributes ) { | |
| 35 | 40 | $css_generator = new CssGenerator( $attributes, $this->block_name ); |
| 36 | 41 | |
| 37 | 42 | $css_generator->add_class_styles( |
| 43 | + '{{WRAPPER}} .ablocks-form-builder', | |
| 44 | + $this->get_row_column_displayCss( $attributes ), | |
| 45 | + $this->get_row_column_displayCss( $attributes, 'Tablet' ), | |
| 46 | + $this->get_row_column_displayCss( $attributes, 'Mobile' ), | |
| 47 | + ); | |
| 48 | + | |
| 49 | + $css_generator->add_class_styles( | |
| 38 | 50 | '{{WRAPPER}} .ablocks-form-builder__field', |
| 39 | 51 | $this->get_field_css( $attributes ), |
| 40 | 52 | $this->get_field_css( $attributes, 'Tablet' ), |
| 41 | 53 | $this->get_field_css( $attributes, 'Mobile' ), |
| @@ -54,9 +66,12 @@ | ||
| 54 | 66 | $this->get_helper_text_css( $attributes, 'Mobile' ), |
| 55 | 67 | ); |
| 56 | 68 | |
| 57 | 69 | $css_generator->add_class_styles( |
| 58 | - '{{WRAPPER}} .ablocks-form-builder__input', | |
| 70 | + '{{WRAPPER}} input.ablocks-form-builder__input , | |
| 71 | + {{WRAPPER}} input.ablocks-form-builder__select , | |
| 72 | + {{WRAPPER}} input.ablocks-form-builder-timepicker-input , | |
| 73 | + {{WRAPPER}} input.ablocks-form-builder-datepicker-input', | |
| 59 | 74 | $this->get_input_css( $attributes ), |
| 60 | 75 | $this->get_input_css( $attributes, 'Tablet' ), |
| 61 | 76 | $this->get_input_css( $attributes, 'Mobile' ), |
| 62 | 77 | ); |
| @@ -137,9 +152,148 @@ | ||
| 137 | 152 | $this->get_success_error_common_styles_css( $attributes, 'Mobile' ), |
| 138 | 153 | ); |
| 139 | 154 | return $css_generator->generate_css(); |
| 140 | 155 | } |
| 156 | + public function build_css_v2( $attributes ) { | |
| 157 | + $css_generator = new CssGeneratorV2( $attributes, $this->block_name ); | |
| 141 | 158 | |
| 159 | + $css_generator->add_class_styles( | |
| 160 | + '{{WRAPPER}} .ablocks-form-builder', | |
| 161 | + $this->get_row_column_displayCss( $attributes ), | |
| 162 | + $this->get_row_column_displayCss( $attributes, 'Tablet' ), | |
| 163 | + $this->get_row_column_displayCss( $attributes, 'Mobile' ), | |
| 164 | + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_row_column_displayCss( $attributes, $device ); } ) | |
| 165 | + ); | |
| 166 | + | |
| 167 | + $css_generator->add_class_styles( | |
| 168 | + '{{WRAPPER}} .ablocks-form-builder__field', | |
| 169 | + $this->get_field_css( $attributes ), | |
| 170 | + $this->get_field_css( $attributes, 'Tablet' ), | |
| 171 | + $this->get_field_css( $attributes, 'Mobile' ), | |
| 172 | + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_field_css( $attributes, $device ); } ) | |
| 173 | + ); | |
| 174 | + | |
| 175 | + $css_generator->add_class_styles( | |
| 176 | + '{{WRAPPER}} .ablocks-form-builder__label', | |
| 177 | + $this->get_label_css( $attributes ), | |
| 178 | + $this->get_label_css( $attributes, 'Tablet' ), | |
| 179 | + $this->get_label_css( $attributes, 'Mobile' ), | |
| 180 | + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_label_css( $attributes, $device ); } ) | |
| 181 | + ); | |
| 182 | + $css_generator->add_class_styles( | |
| 183 | + '{{WRAPPER}} .ablocks-form-builder__helper-text', | |
| 184 | + $this->get_helper_text_css( $attributes ), | |
| 185 | + $this->get_helper_text_css( $attributes, 'Tablet' ), | |
| 186 | + $this->get_helper_text_css( $attributes, 'Mobile' ), | |
| 187 | + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_helper_text_css( $attributes, $device ); } ) | |
| 188 | + ); | |
| 189 | + | |
| 190 | + $css_generator->add_class_styles( | |
| 191 | + '{{WRAPPER}} .ablocks-form-builder__input , | |
| 192 | + {{WRAPPER}} .ablocks-form-builder__select , | |
| 193 | + {{WRAPPER}} .ablocks-form-builder-timepicker-input , | |
| 194 | + {{WRAPPER}} .ablocks-form-builder-datepicker-input', | |
| 195 | + $this->get_input_css( $attributes ), | |
| 196 | + $this->get_input_css( $attributes, 'Tablet' ), | |
| 197 | + $this->get_input_css( $attributes, 'Mobile' ), | |
| 198 | + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_input_css( $attributes, $device ); } ) | |
| 199 | + ); | |
| 200 | + $css_generator->add_class_styles( | |
| 201 | + '{{WRAPPER}} .ablocks-form-builder__input:hover', | |
| 202 | + $this->get_input_hover_css( $attributes ), | |
| 203 | + $this->get_input_hover_css( $attributes, 'Tablet' ), | |
| 204 | + $this->get_input_hover_css( $attributes, 'Mobile' ), | |
| 205 | + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_input_hover_css( $attributes, $device ); } ) | |
| 206 | + ); | |
| 207 | + $css_generator->add_class_styles( | |
| 208 | + '{{WRAPPER}} .ablocks-form-builder__input:focus', | |
| 209 | + $this->get_input_focus_css( $attributes ), | |
| 210 | + $this->get_input_focus_css( $attributes, 'Tablet' ), | |
| 211 | + $this->get_input_focus_css( $attributes, 'Mobile' ), | |
| 212 | + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_input_focus_css( $attributes, $device ); } ) | |
| 213 | + ); | |
| 214 | + | |
| 215 | + $css_generator->add_class_styles( | |
| 216 | + '{{WRAPPER}} .ablocks-form-builder__input::placeholder', | |
| 217 | + $this->get_input_placeholder_css( $attributes ), | |
| 218 | + $this->get_input_placeholder_css( $attributes, 'Tablet' ), | |
| 219 | + $this->get_input_placeholder_css( $attributes, 'Mobile' ), | |
| 220 | + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_input_placeholder_css( $attributes, $device ); } ) | |
| 221 | + ); | |
| 222 | + $css_generator->add_class_styles( | |
| 223 | + '{{WRAPPER}} .ablocks-form-builder__input-icon,{{WRAPPER}} .ablocks-form-builder__input-toggle-password', | |
| 224 | + $this->get_input_position_css( $attributes ), | |
| 225 | + $this->get_input_position_css( $attributes, 'Tablet' ), | |
| 226 | + $this->get_input_position_css( $attributes, 'Mobile' ), | |
| 227 | + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_input_position_css( $attributes, $device ); } ) | |
| 228 | + ); | |
| 229 | + | |
| 230 | + $css_generator->add_class_styles( | |
| 231 | + '{{WRAPPER}} .ablocks-form-builder__submit-button', | |
| 232 | + $this->get_alignment_button_css( $attributes ), | |
| 233 | + $this->get_alignment_button_css( $attributes, 'Tablet' ), | |
| 234 | + $this->get_alignment_button_css( $attributes, 'Mobile' ), | |
| 235 | + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_alignment_button_css( $attributes, $device ); } ) | |
| 236 | + ); | |
| 237 | + | |
| 238 | + $css_generator->add_class_styles( | |
| 239 | + '{{WRAPPER}} .ablocks-form-builder__submit-button', | |
| 240 | + $this->get_submit_button_css( $attributes ), | |
| 241 | + $this->get_submit_button_css( $attributes, 'Tablet' ), | |
| 242 | + $this->get_submit_button_css( $attributes, 'Mobile' ), | |
| 243 | + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_submit_button_css( $attributes, $device ); } ) | |
| 244 | + ); | |
| 245 | + | |
| 246 | + $css_generator->add_class_styles( | |
| 247 | + '{{WRAPPER}} .ablocks-form-builder__submit-button:hover', | |
| 248 | + $this->get_submit_button_hover_css( $attributes ), | |
| 249 | + $this->get_submit_button_hover_css( $attributes, 'Tablet' ), | |
| 250 | + $this->get_submit_button_hover_css( $attributes, 'Mobile' ), | |
| 251 | + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_submit_button_hover_css( $attributes, $device ); } ) | |
| 252 | + ); | |
| 253 | + $css_generator->add_class_styles( | |
| 254 | + '{{WRAPPER}} .ablocks-block--form-builder__navigator', | |
| 255 | + $this->get_navigator_css( $attributes ), | |
| 256 | + $this->get_navigator_css( $attributes, 'Tablet' ), | |
| 257 | + $this->get_navigator_css( $attributes, 'Mobile' ), | |
| 258 | + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_navigator_css( $attributes, $device ); } ) | |
| 259 | + ); | |
| 260 | + $css_generator->add_class_styles( | |
| 261 | + '{{WRAPPER}} .ablocks-block--form-builder__navigator-redirect-page', | |
| 262 | + $this->get_navigator_spacing_css( $attributes ), | |
| 263 | + $this->get_navigator_spacing_css( $attributes, 'Tablet' ), | |
| 264 | + $this->get_navigator_spacing_css( $attributes, 'Mobile' ), | |
| 265 | + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_navigator_spacing_css( $attributes, $device ); } ) | |
| 266 | + ); | |
| 267 | + $css_generator->add_class_styles( | |
| 268 | + '{{WRAPPER}} .ablocks-block--form-builder__success', | |
| 269 | + $this->get_succsss_styles_css( $attributes ), | |
| 270 | + $this->get_succsss_styles_css( $attributes, 'Tablet' ), | |
| 271 | + $this->get_succsss_styles_css( $attributes, 'Mobile' ), | |
| 272 | + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_succsss_styles_css( $attributes, $device ); } ) | |
| 273 | + ); | |
| 274 | + $css_generator->add_class_styles( | |
| 275 | + '{{WRAPPER}} .ablocks-block--form-builder__error', | |
| 276 | + $this->get_error_styles_css( $attributes ), | |
| 277 | + $this->get_error_styles_css( $attributes, 'Tablet' ), | |
| 278 | + $this->get_error_styles_css( $attributes, 'Mobile' ), | |
| 279 | + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_error_styles_css( $attributes, $device ); } ) | |
| 280 | + ); | |
| 281 | + $css_generator->add_class_styles( | |
| 282 | + '{{WRAPPER}} .ablocks-block--form-builder__feedback-message', | |
| 283 | + $this->get_success_error_common_styles_css( $attributes ), | |
| 284 | + $this->get_success_error_common_styles_css( $attributes, 'Tablet' ), | |
| 285 | + $this->get_success_error_common_styles_css( $attributes, 'Mobile' ), | |
| 286 | + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_success_error_common_styles_css( $attributes, $device ); } ) | |
| 287 | + ); | |
| 288 | + return $css_generator->generate_css(); | |
| 289 | + } | |
| 290 | + public function build_css( $attributes ) { | |
| 291 | + if ( isset( $attributes['blockVersion'] ) && (int) $attributes['blockVersion'] === 2 ) { | |
| 292 | + return $this->build_css_v2( $attributes ); | |
| 293 | + } | |
| 294 | + return $this->build_css_v1( $attributes ); | |
| 295 | + } | |
| 142 | 296 | public function get_field_css( $attributes, $device = '' ) { |
| 143 | 297 | $field_css = array_merge( |
| 144 | 298 | Range::get_css([ |
| 145 | 299 | 'attributeValue' => $attributes['rowsSpacing'], |
| @@ -163,10 +317,12 @@ | ||
| 163 | 317 | return $field_css; |
| 164 | 318 | } |
| 165 | 319 | |
| 166 | 320 | public function get_label_css( $attributes, $device = '' ) { |
| 321 | + $typographyValueGlobal = ! empty( $attributes['labelTypographyGlobal'] ) ? $attributes['labelTypographyGlobal'] : array(); | |
| 167 | 322 | $label_css = array_merge( |
| 168 | - Typography::get_css( $attributes['labelTypography'], '', $device ), | |
| 323 | + [ 'color' => Color::get_css( isset( $attributes['labelColor'] ) ? $attributes['labelColor'] : '' ) ], | |
| 324 | + Typography::get_css( $attributes['labelTypography'], '', $device, $typographyValueGlobal ), | |
| 169 | 325 | Alignment::get_css( $attributes['labelAlignment'], 'text-align', $device ), |
| 170 | 326 | Range::get_css([ |
| 171 | 327 | 'attributeValue' => $attributes['labelSpacing'], |
| 172 | 328 | 'attributeObjectKey' => 'value', |
| @@ -179,13 +335,8 @@ | ||
| 179 | 335 | ); |
| 180 | 336 | if ( ! empty( $label_css['margin-bottom'] ) ) { |
| 181 | 337 | $label_css['margin-bottom'] = $label_css['margin-bottom'] . ' !important'; |
| 182 | 338 | } |
| 183 | - | |
| 184 | - if ( ! empty( $attributes['labelColor'] ) ) { | |
| 185 | - $label_css['color'] = $attributes['labelColor']; | |
| 186 | - } | |
| 187 | - | |
| 188 | 339 | if ( ! $attributes['showLabels'] ) { |
| 189 | 340 | $label_css['display'] = 'none'; |
| 190 | 341 | } |
| 191 | 342 | |
| @@ -191,10 +342,12 @@ | ||
| 191 | 342 | |
| 192 | 343 | return $label_css; |
| 193 | 344 | } |
| 194 | 345 | public function get_helper_text_css( $attributes, $device = '' ) { |
| 346 | + $typographyValueGlobal = ! empty( $attributes['helperTextTypographyGlobal'] ) ? $attributes['helperTextTypographyGlobal'] : array(); | |
| 195 | 347 | $helper_text_css = array_merge( |
| 196 | - Typography::get_css( $attributes['helperTextTypography'], '', $device ), | |
| 348 | + [ 'color' => Color::get_css( isset( $attributes['helperTextColor'] ) ? $attributes['helperTextColor'] : '' ) ], | |
| 349 | + Typography::get_css( $attributes['helperTextTypography'], '', $device, $typographyValueGlobal ), | |
| 197 | 350 | Alignment::get_css( $attributes['labelAlignment'], 'text-align', $device ), |
| 198 | 351 | Range::get_css([ |
| 199 | 352 | 'attributeValue' => $attributes['helperTextSpacing'], |
| 200 | 353 | 'attributeObjectKey' => 'value', |
| @@ -213,45 +366,32 @@ | ||
| 213 | 366 | if ( ! empty( $attributes['helperTextSpacing'][ 'value' . $device ] ) ) { |
| 214 | 367 | $helper_text_css['margin-top'] = $attributes['helperTextSpacing'][ 'value' . $device ] . 'px'; |
| 215 | 368 | $helper_text_css['margin-bottom'] = $attributes['helperTextSpacing'][ 'value' . $device ] . 'px'; |
| 216 | 369 | } |
| 217 | - if ( ! empty( $attributes['helperTextColor'] ) ) { | |
| 218 | - $helper_text_css['color'] = $attributes['helperTextColor']; | |
| 219 | - } | |
| 220 | 370 | |
| 221 | 371 | return $helper_text_css; |
| 222 | 372 | } |
| 223 | 373 | |
| 224 | 374 | public function get_input_css( $attributes, $device = '' ) { |
| 225 | - // Initialize the $css array before using it | |
| 226 | 375 | $css = array(); |
| 227 | - | |
| 228 | - // Check if the inputBorder's borderStyle is 'default' and apply default border styles | |
| 229 | 376 | if ( isset( $attributes['inputBorder']['borderStyle'] ) && $attributes['inputBorder']['borderStyle'] === 'default' ) { |
| 230 | 377 | $css['border'] = '1px solid #A7AAAD'; |
| 231 | 378 | $css['border-radius'] = '5px'; |
| 232 | 379 | } |
| 233 | - | |
| 234 | - // Merge the base CSS with typography, border, and padding CSS | |
| 380 | + $typographyValueGlobal = ! empty( $attributes['inputTypographyGlobal'] ) ? $attributes['inputTypographyGlobal'] : array(); | |
| 235 | 381 | $input_css = array_merge( |
| 236 | - $css, // Include the default border styles if set | |
| 382 | + [ 'background' => Color::get_css( isset( $attributes['inputBgColor'] ) ? $attributes['inputBgColor'] : '' ) ], | |
| 383 | + $css, | |
| 237 | 384 | Alignment::get_css( $attributes['inputAlignment'], 'text-align', $device ), |
| 238 | - Typography::get_css( $attributes['inputTypography'], '', $device ), | |
| 385 | + Typography::get_css( $attributes['inputTypography'], '', $device, $typographyValueGlobal ), | |
| 239 | 386 | Border::get_css( $attributes['inputBorder'], '', $device ), |
| 240 | - Dimensions::get_css( $attributes['inputPadding'], 'padding', $device ) | |
| 387 | + $this->add_important_to_css( Dimensions::get_css( $attributes['inputPadding'], 'padding', $device ) ) | |
| 241 | 388 | ); |
| 242 | 389 | |
| 243 | - // Add input text color if it's set in the attributes | |
| 244 | 390 | if ( ! empty( $attributes['inputColor'] ) ) { |
| 245 | - $input_css['color'] = $attributes['inputColor'] . '!important'; | |
| 391 | + $input_css['color'] = Color::get_css( | |
| 392 | + isset( $attributes['inputColor'] ) ? $attributes['inputColor'] : '') . '!important'; | |
| 246 | 393 | } |
| 247 | - | |
| 248 | - // Add background color if it's set in the attributes | |
| 249 | - if ( ! empty( $attributes['inputBgColor'] ) ) { | |
| 250 | - $input_css['background-color'] = $attributes['inputBgColor']; | |
| 251 | - } | |
| 252 | - | |
| 253 | - // Ensure box-sizing is set to 'border-box' | |
| 254 | 394 | $input_css['box-sizing'] = 'border-box'; |
| 255 | 395 | |
| 256 | 396 | return $input_css; |
| 257 | 397 | } |
| @@ -257,15 +397,12 @@ | ||
| 257 | 397 | } |
| 258 | 398 | |
| 259 | 399 | public function get_input_hover_css( $attributes, $device = '' ) { |
| 260 | 400 | $css = array(); |
| 261 | - | |
| 262 | - // Check if the inputBorder's borderStyle is 'default' and apply default border styles | |
| 263 | 401 | if ( isset( $attributes['inputBorder']['borderStyle'] ) && $attributes['inputBorder']['borderStyle'] === 'default' ) { |
| 264 | 402 | $css['border'] = '1px solid #A7AAAD'; |
| 265 | 403 | $css['border-radius'] = '5px'; |
| 266 | 404 | } |
| 267 | - // Get the border hover CSS based on inputBorder attribute | |
| 268 | 405 | $input_focus_css = array_merge( |
| 269 | 406 | $css, |
| 270 | 407 | Border::get_hover_css( $attributes['inputBorder'], '', $device ) |
| 271 | 408 | ); |
| @@ -273,15 +410,12 @@ | ||
| 273 | 410 | return $input_focus_css; |
| 274 | 411 | } |
| 275 | 412 | public function get_input_focus_css( $attributes, $device = '' ) { |
| 276 | 413 | $css = array(); |
| 277 | - | |
| 278 | - // Check if the inputBorder's borderStyle is 'default' and apply default border styles | |
| 279 | 414 | if ( isset( $attributes['inputBorder']['borderStyle'] ) && $attributes['inputBorder']['borderStyle'] === 'default' ) { |
| 280 | 415 | $css['border'] = '1px solid #A7AAAD'; |
| 281 | 416 | $css['border-radius'] = '5px'; |
| 282 | 417 | } |
| 283 | - // Get the border hover CSS based on inputBorder attribute | |
| 284 | 418 | $input_focus_css = array_merge( |
| 285 | 419 | $css, |
| 286 | 420 | Border::get_hover_css( $attributes['inputBorder'], '', $device ) |
| 287 | 421 | ); |
| @@ -288,29 +422,26 @@ | ||
| 288 | 422 | |
| 289 | 423 | return $input_focus_css; |
| 290 | 424 | } |
| 291 | 425 | public function get_input_placeholder_css( $attributes, $device = '' ) { |
| 292 | - // Initialize placeholder CSS array | |
| 426 | + $typographyValueGlobal = ! empty( $attributes['inputTypographyGlobal'] ) ? $attributes['inputTypographyGlobal'] : array(); | |
| 293 | 427 | $placeholder_css = array_merge( |
| 294 | - // Apply typography for the placeholder (font size, font family, etc.) | |
| 295 | - Typography::get_css( $attributes['inputTypography'], '', $device ), | |
| 296 | - // Apply alignment if specified | |
| 428 | + Typography::get_css( $attributes['inputTypography'], '', $device, $typographyValueGlobal ), | |
| 297 | 429 | Alignment::get_css( $attributes['inputAlignment'], 'text-align', $device ) |
| 298 | 430 | ); |
| 299 | - // Check if placeholder color is defined, and apply it | |
| 300 | 431 | if ( ! empty( $attributes['inputPlaceholderColor'] ) ) { |
| 301 | - $placeholder_css['color'] = $attributes['inputPlaceholderColor'] . '!important'; // Add !important to override conflicting styles | |
| 432 | + $placeholder_css['color'] = Color::get_css( | |
| 433 | + isset( $attributes['inputPlaceholderColor'] ) ? $attributes['inputPlaceholderColor'] : '') . '!important'; | |
| 302 | 434 | } |
| 303 | 435 | return $placeholder_css; |
| 304 | 436 | |
| 305 | 437 | } |
| 306 | 438 | public function get_input_position_css( $attributes, $device = '' ) { |
| 307 | - // Access the inputIconPosition attribute from the attributes array | |
| 308 | 439 | $css = array_merge( |
| 309 | 440 | Range::get_css([ |
| 310 | 441 | 'attributeValue' => $attributes['inputIconPosition'], |
| 311 | 442 | 'isResponsive' => false, |
| 312 | - 'defaultValue' => 60, | |
| 443 | + 'defaultValue' => 75, | |
| 313 | 444 | 'unitDefaultValue' => '%', |
| 314 | 445 | 'property' => 'top', |
| 315 | 446 | 'device' => $device, |
| 316 | 447 | ]), |
| @@ -327,47 +458,33 @@ | ||
| 327 | 458 | } |
| 328 | 459 | |
| 329 | 460 | |
| 330 | 461 | public function get_submit_button_css( $attributes, $device = '' ) { |
| 462 | + $typographyValueGlobal = ! empty( $attributes['buttonTypographyGlobal'] ) ? $attributes['buttonTypographyGlobal'] : array(); | |
| 331 | 463 | $button_css = array_merge( |
| 464 | + [ 'color' => Color::get_css( isset( $attributes['buttonColor'] ) ? $attributes['buttonColor'] : '' ) ], | |
| 465 | + [ 'background' => Color::get_css( isset( $attributes['buttonBgColor'] ) ? $attributes['buttonBgColor'] : '' ) ], | |
| 332 | 466 | Border::get_css( $attributes['buttonBorder'], '', $device ), |
| 333 | - Typography::get_css( $attributes['buttonTypography'], '', $device ), | |
| 467 | + Typography::get_css( $attributes['buttonTypography'], '', $device, $typographyValueGlobal ), | |
| 334 | 468 | Dimensions::get_css( $attributes['buttonPadding'], 'padding', $device ), |
| 335 | 469 | ); |
| 336 | - if ( ! empty( $attributes['buttonColor'] ) ) { | |
| 337 | - $button_css['color'] = $attributes['buttonColor']; | |
| 338 | - } | |
| 339 | - | |
| 340 | - if ( ! empty( $attributes['buttonBgColor'] ) ) { | |
| 341 | - $button_css['background-color'] = $attributes['buttonBgColor']; | |
| 342 | - } | |
| 343 | - | |
| 344 | 470 | return $button_css; |
| 345 | 471 | } |
| 346 | 472 | |
| 347 | 473 | public function get_submit_button_hover_css( $attributes, $device = '' ) { |
| 348 | - $button_hover_css = Border::get_hover_css( $attributes['buttonBorder'], '', $device ); | |
| 349 | - | |
| 350 | - if ( ! empty( $attributes['buttonHColor'] ) ) { | |
| 351 | - $button_hover_css['color'] = $attributes['buttonHColor']; | |
| 352 | - } | |
| 353 | - | |
| 354 | - if ( ! empty( $attributes['buttonBgHColor'] ) ) { | |
| 355 | - $button_hover_css['background-color'] = $attributes['buttonBgHColor']; | |
| 356 | - } | |
| 357 | - | |
| 358 | - return $button_hover_css; | |
| 474 | + return array_merge( | |
| 475 | + [ 'color' => Color::get_css( isset( $attributes['buttonHColor'] ) ? $attributes['buttonHColor'] : '' ) ], | |
| 476 | + [ 'background' => Color::get_css( isset( $attributes['buttonBgHColor'] ) ? $attributes['buttonBgHColor'] : '' ) ], | |
| 477 | + Border::get_hover_css( $attributes['buttonBorder'], '', $device ) | |
| 478 | + ); | |
| 359 | 479 | } |
| 360 | 480 | public function get_navigator_css( $attributes, $device = '' ) { |
| 361 | - $css = []; | |
| 362 | - if ( ! empty( $attributes['navigatorColor'] ) ) { | |
| 363 | - $css['color'] = $attributes['navigatorColor']; | |
| 364 | - } | |
| 481 | + $typographyValueGlobal = ! empty( $attributes['navigatorTypographyGlobal'] ) ? $attributes['navigatorTypographyGlobal'] : array(); | |
| 365 | 482 | return array_merge( |
| 366 | - Typography::get_css( $attributes['navigatorTypography'], '', $device ), | |
| 483 | + [ 'color' => Color::get_css( isset( $attributes['navigatorColor'] ) ? $attributes['navigatorColor'] : '' ) ], | |
| 484 | + Typography::get_css( $attributes['navigatorTypography'], '', $device, $typographyValueGlobal ), | |
| 367 | 485 | Dimensions::get_css( $attributes['navigatorPadding'], 'padding', $device ), |
| 368 | 486 | Alignment::get_css( $attributes['navigatorAlignment'], 'text-align', $device ), |
| 369 | - $css | |
| 370 | 487 | ); |
| 371 | 488 | } |
| 372 | 489 | public function get_navigator_spacing_css( $attributes, $device = '' ) { |
| 373 | 490 | // Access the inputIconPosition attribute from the attributes array |
| @@ -384,34 +501,50 @@ | ||
| 384 | 501 | return $css; |
| 385 | 502 | |
| 386 | 503 | } |
| 387 | 504 | public function get_succsss_styles_css( $attributes, $device = '' ) { |
| 388 | - $css = []; | |
| 389 | - if ( ! empty( $attributes['successBackground'] ) ) { | |
| 390 | - $css['background'] = $attributes['successBackground']; | |
| 391 | - } | |
| 392 | - if ( ! empty( $attributes['successColor'] ) ) { | |
| 393 | - $css['color'] = $attributes['successColor']; | |
| 394 | - } | |
| 395 | - return $css; | |
| 505 | + return array_merge( | |
| 506 | + [ 'color' => Color::get_css( isset( $attributes['successColor'] ) ? $attributes['successColor'] : '' ) ], | |
| 507 | + [ 'background' => Color::get_css( isset( $attributes['successBackground'] ) ? $attributes['successBackground'] : '' ) ] | |
| 508 | + ); | |
| 396 | 509 | } |
| 397 | 510 | public function get_error_styles_css( $attributes, $device = '' ) { |
| 398 | - $css = []; | |
| 399 | - if ( ! empty( $attributes['errorBackground'] ) ) { | |
| 400 | - $css['background'] = $attributes['errorBackground']; | |
| 401 | - } | |
| 402 | - if ( ! empty( $attributes['errorColor'] ) ) { | |
| 403 | - $css['color'] = $attributes['errorColor']; | |
| 404 | - } | |
| 405 | - return $css; | |
| 511 | + return array_merge( | |
| 512 | + [ 'color' => Color::get_css( isset( $attributes['errorColor'] ) ? $attributes['errorColor'] : '' ) ], | |
| 513 | + [ 'background' => Color::get_css( isset( $attributes['errorBackground'] ) ? $attributes['errorBackground'] : '' ) ], | |
| 514 | + ); | |
| 406 | 515 | } |
| 407 | 516 | public function get_success_error_common_styles_css( $attributes, $device = '' ) { |
| 408 | - $css = []; | |
| 517 | + $typographyValueGlobal = ! empty( $attributes['successErrorTypographyGlobal'] ) ? $attributes['successErrorTypographyGlobal'] : array(); | |
| 409 | 518 | return array_merge( |
| 410 | - Typography::get_css( $attributes['successErrorTypography'], '', $device ), | |
| 519 | + Typography::get_css( $attributes['successErrorTypography'], '', $device, $typographyValueGlobal ), | |
| 411 | 520 | Alignment::get_css( $attributes['successErrorAlignment'], 'text-align', $device ), |
| 412 | 521 | Dimensions::get_css( $attributes['successErrorPadding'], 'padding', $device ), |
| 413 | - $css, | |
| 414 | 522 | ); |
| 415 | 523 | } |
| 524 | + | |
| 525 | + public function get_row_column_displayCss( $attributes, $device = '' ) { | |
| 526 | + $css = []; | |
| 527 | + | |
| 528 | + if ( isset( $attributes['dir'][ 'value' . $device ] ) ) { | |
| 529 | + $dir_value = $attributes['dir'][ 'value' . $device ]; | |
| 530 | + $css['flex-direction'] = $dir_value; | |
| 531 | + | |
| 532 | + if ( in_array( $dir_value, [ 'row', 'row-reverse' ], true ) ) { | |
| 533 | + $css['align-items'] = 'center'; | |
| 534 | + } elseif ( in_array( $dir_value, [ 'column', 'column-reverse' ], true ) ) { | |
| 535 | + $css['flex-wrap'] = 'wrap'; | |
| 536 | + } | |
| 537 | + } | |
| 538 | + | |
| 539 | + return $css; | |
| 540 | + } | |
| 541 | + | |
| 542 | + private function add_important_to_css( $css_array ) { | |
| 543 | + foreach ( $css_array as $key => $value ) { | |
| 544 | + $css_array[$key] = $value . ' !important'; | |
| 545 | + } | |
| 546 | + return $css_array; | |
| 547 | + } | |
| 548 | + | |
| 416 | 549 | |
| 417 | 550 | } |