| 1 |
import { arrayToClassName, pxToRem } from 'elementor-app/utils/utils.js'; |
| 2 |
|
| 3 |
import './box.scss'; |
| 4 |
|
| 5 |
export default function Box( props ) { |
| 6 |
const baseClassName = 'eps-box', |
| 7 |
classes = [ baseClassName, props.className ], |
| 8 |
style = {}; |
| 9 |
|
| 10 |
if ( Object.prototype.hasOwnProperty.call( props, 'padding' ) ) { |
| 11 |
style[ '--eps-box-padding' ] = pxToRem( props.padding ); |
| 12 |
|
| 13 |
classes.push( baseClassName + '--padding' ); |
| 14 |
} |
| 15 |
|
| 16 |
return ( |
| 17 |
<div style={ style } className={ arrayToClassName( classes ) }> |
| 18 |
{ props.children } |
| 19 |
</div> |
| 20 |
); |
| 21 |
} |
| 22 |
|
| 23 |
Box.propTypes = { |
| 24 |
className: PropTypes.string, |
| 25 |
padding: PropTypes.string, |
| 26 |
children: PropTypes.oneOfType( [ |
| 27 |
PropTypes.string, |
| 28 |
PropTypes.object, |
| 29 |
PropTypes.arrayOf( PropTypes.object ), |
| 30 |
] ).isRequired, |
| 31 |
}; |
| 32 |
|
| 33 |
Box.defaultProps = { |
| 34 |
className: '', |
| 35 |
}; |
| 36 |
|