| @@ -20,15 +20,17 @@ | ||
| 20 | 20 | $css_generator->add_class_styles( |
| 21 | 21 | '{{WRAPPER}}', |
| 22 | 22 | $this->get_wrapper_css( $attributes ), |
| 23 | 23 | $this->get_wrapper_css( $attributes, 'Tablet' ), |
| 24 | - $this->get_wrapper_css( $attributes, 'Mobile' ) | |
| 24 | + $this->get_wrapper_css( $attributes, 'Mobile' ), | |
| 25 | + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_wrapper_css( $attributes, $device ); } ) | |
| 25 | 26 | ); |
| 26 | 27 | $css_generator->add_class_styles( |
| 27 | 28 | '{{WRAPPER}}.ablocks-block--form-input', |
| 28 | 29 | $this->get_input_block_main_wrapper( $attributes ), |
| 29 | 30 | $this->get_input_block_main_wrapper( $attributes, 'Tablet' ), |
| 30 | - $this->get_input_block_main_wrapper( $attributes, 'Mobile' ) | |
| 31 | + $this->get_input_block_main_wrapper( $attributes, 'Mobile' ), | |
| 32 | + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_input_block_main_wrapper( $attributes, $device ); } ) | |
| 31 | 33 | ); |
| 32 | 34 | |
| 33 | 35 | // Generate button icon CSS start |
| 34 | 36 | $css_generator->add_class_styles( |
| @@ -34,15 +36,17 @@ | ||
| 34 | 36 | $css_generator->add_class_styles( |
| 35 | 37 | '{{WRAPPER}} .ablocks-icon-wrap', |
| 36 | 38 | $this->get_icon_wrapper_css( $attributes ), |
| 37 | 39 | $this->get_icon_wrapper_css( $attributes, 'Tablet' ), |
| 38 | - $this->get_icon_wrapper_css( $attributes, 'Mobile' ) | |
| 40 | + $this->get_icon_wrapper_css( $attributes, 'Mobile' ), | |
| 41 | + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_icon_wrapper_css( $attributes, $device ); } ) | |
| 39 | 42 | ); |
| 40 | 43 | $css_generator->add_class_styles( |
| 41 | 44 | '{{WRAPPER}} .ablocks-form-builder__input-show-icon', |
| 42 | 45 | $this->get_icon_space_css( $attributes ), |
| 43 | 46 | $this->get_icon_space_css( $attributes, 'Tablet' ), |
| 44 | - $this->get_icon_space_css( $attributes, 'Mobile' ) | |
| 47 | + $this->get_icon_space_css( $attributes, 'Mobile' ), | |
| 48 | + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_icon_space_css( $attributes, $device ); } ) | |
| 45 | 49 | ); |
| 46 | 50 | |
| 47 | 51 | $css_generator->add_class_styles( |
| 48 | 52 | '{{WRAPPER}} .ablocks-form-builder__input-toggle-password .ablocks-icon-wrap ', |
| @@ -78,18 +82,15 @@ | ||
| 78 | 82 | public function get_input_block_main_wrapper( $attributes, $device = '' ) { |
| 79 | 83 | $css = []; |
| 80 | 84 | $css['box-sizing'] = 'border-box'; |
| 81 | 85 | |
| 82 | - $valueKey = $device === 'Tablet' ? 'valueTablet' : ( $device === 'Mobile' ? 'valueMobile' : 'value' ); | |
| 83 | - $unitKey = $device === 'Tablet' ? 'valueUnitTablet' : ( $device === 'Mobile' ? 'valueUnitMobile' : 'valueUnit' ); | |
| 84 | - | |
| 85 | - $widthValue = isset( $attributes['inputWidth'][ $valueKey ] ) && $attributes['inputWidth'][ $valueKey ] !== '' | |
| 86 | - ? $attributes['inputWidth'][ $valueKey ] | |
| 87 | - : ( isset( $attributes['inputWidth']['value'] ) ? $attributes['inputWidth']['value'] : 100 ); | |
| 88 | - | |
| 89 | - $widthUnit = isset( $attributes['inputWidth'][ $unitKey ] ) && $attributes['inputWidth'][ $unitKey ] !== '' | |
| 90 | - ? $attributes['inputWidth'][ $unitKey ] | |
| 91 | - : '%'; | |
| 86 | + // The device's own width, else the nearest containing wider device's | |
| 87 | + // (custom breakpoints included), else Desktop's. | |
| 88 | + $input_width = isset( $attributes['inputWidth'] ) ? (array) $attributes['inputWidth'] : []; | |
| 89 | + $widthValue = \ABlocks\Helper::get_responsive_value( $input_width, 'value', $device ); | |
| 90 | + $widthValue = false === $widthValue ? 100 : $widthValue; | |
| 91 | + $widthUnit = \ABlocks\Helper::get_responsive_value( $input_width, 'valueUnit', $device ); | |
| 92 | + $widthUnit = false === $widthUnit ? '%' : $widthUnit; | |
| 92 | 93 | |
| 93 | 94 | if ( is_numeric( $widthValue ) ) { |
| 94 | 95 | $widthValue = max( 0, floatval( $widthValue ) - 1 ); |
| 95 | 96 | } |