Height.js
2 years ago
MaxHeight.js
2 years ago
MaxWidth.js
2 years ago
MinHeight.js
2 years ago
MinWidth.js
2 years ago
SizingCSS.js
3 years ago
Width.js
2 years ago
SizingCSS.js
38 lines
| 1 | import addToCSS from '../../../../../utils/add-to-css'; |
| 2 | import sizingValue from '../../../../../utils/sizingValue'; |
| 3 | |
| 4 | export default function SizingCSS( css, selector, attributes, device = '' ) { |
| 5 | const { |
| 6 | sizing, |
| 7 | } = attributes; |
| 8 | |
| 9 | const styles = { |
| 10 | width: sizingValue( 'width' + device, sizing ), |
| 11 | height: sizingValue( 'height' + device, sizing ), |
| 12 | 'min-width': sizingValue( 'minWidth' + device, sizing ), |
| 13 | 'min-height': sizingValue( 'minHeight' + device, sizing ), |
| 14 | 'max-width': sizingValue( 'maxWidth' + device, sizing ), |
| 15 | 'max-height': sizingValue( 'maxHeight' + device, sizing ), |
| 16 | }; |
| 17 | |
| 18 | if ( attributes.useInnerContainer ) { |
| 19 | delete styles[ 'max-width' ]; |
| 20 | } else if ( attributes.useGlobalMaxWidth && ! device ) { |
| 21 | styles[ 'max-width' ] = generateBlocksInfo.globalContainerWidth; |
| 22 | } |
| 23 | |
| 24 | if ( attributes.isGrid ) { |
| 25 | delete styles.width; |
| 26 | delete styles[ 'min-width' ]; |
| 27 | delete styles[ 'max-width' ]; |
| 28 | } |
| 29 | |
| 30 | if ( ! styles[ 'max-width' ] ) { |
| 31 | styles[ 'max-width' ] = 'unset'; |
| 32 | } |
| 33 | |
| 34 | return ( |
| 35 | addToCSS( css, selector, styles ) |
| 36 | ); |
| 37 | } |
| 38 |