| @@ -19,9 +19,10 @@ | ||
| 19 | 19 | $css_generator->add_class_styles( |
| 20 | 20 | '{{WRAPPER}}', |
| 21 | 21 | $this->get_wrapper_css( $attributes ), |
| 22 | 22 | $this->get_wrapper_css( $attributes, 'Tablet' ), |
| 23 | - $this->get_wrapper_css( $attributes, 'Mobile' ) | |
| 23 | + $this->get_wrapper_css( $attributes, 'Mobile' ), | |
| 24 | + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_wrapper_css( $attributes, $device ); } ) | |
| 24 | 25 | ); |
| 25 | 26 | $css_generator->add_class_styles( |
| 26 | 27 | '{{WRAPPER}}.ablocks-block--form-select', |
| 27 | 28 | $this->get_input_block_main_wrapper( $attributes ), |
| @@ -36,18 +37,15 @@ | ||
| 36 | 37 | public function get_input_block_main_wrapper( $attributes, $device = '' ) { |
| 37 | 38 | $css = []; |
| 38 | 39 | $css['box-sizing'] = 'border-box'; |
| 39 | 40 | |
| 40 | - $valueKey = $device === 'Tablet' ? 'valueTablet' : ( $device === 'Mobile' ? 'valueMobile' : 'value' ); | |
| 41 | - $unitKey = $device === 'Tablet' ? 'valueUnitTablet' : ( $device === 'Mobile' ? 'valueUnitMobile' : 'valueUnit' ); | |
| 42 | - | |
| 43 | - $widthValue = isset( $attributes['inputWidth'][ $valueKey ] ) && $attributes['inputWidth'][ $valueKey ] !== '' | |
| 44 | - ? $attributes['inputWidth'][ $valueKey ] | |
| 45 | - : ( isset( $attributes['inputWidth']['value'] ) ? $attributes['inputWidth']['value'] : 100 ); | |
| 46 | - | |
| 47 | - $widthUnit = isset( $attributes['inputWidth'][ $unitKey ] ) && $attributes['inputWidth'][ $unitKey ] !== '' | |
| 48 | - ? $attributes['inputWidth'][ $unitKey ] | |
| 49 | - : '%'; | |
| 41 | + // The device's own width, else the nearest containing wider device's | |
| 42 | + // (custom breakpoints included), else Desktop's. | |
| 43 | + $input_width = isset( $attributes['inputWidth'] ) ? (array) $attributes['inputWidth'] : []; | |
| 44 | + $widthValue = \ABlocks\Helper::get_responsive_value( $input_width, 'value', $device ); | |
| 45 | + $widthValue = false === $widthValue ? 100 : $widthValue; | |
| 46 | + $widthUnit = \ABlocks\Helper::get_responsive_value( $input_width, 'valueUnit', $device ); | |
| 47 | + $widthUnit = false === $widthUnit ? '%' : $widthUnit; | |
| 50 | 48 | |
| 51 | 49 | if ( is_numeric( $widthValue ) ) { |
| 52 | 50 | $widthValue = max( 0, floatval( $widthValue ) - 1 ); |
| 53 | 51 | } |