| 1 |
<?php |
| 2 |
|
| 3 |
namespace Elementor\Modules\Mcp\Abilities\Utils; |
| 4 |
|
| 5 |
if ( ! defined( 'ABSPATH' ) ) { |
| 6 |
exit; |
| 7 |
} |
| 8 |
|
| 9 |
/** |
| 10 |
* Every atomic element (not widget) renders with the `.e-con` class. These are the declarations |
| 11 |
* from assets/dev/scss/frontend/_container.scss that affect atomic elements, kept in sync by a |
| 12 |
* PHPUnit check. |
| 13 |
* |
| 14 |
* The kit's Container Padding (10px by default) is left out on purpose: `.e-con` applies it as |
| 15 |
* inline padding only, the base padding of most atomic elements overrides it, and the value is |
| 16 |
* user-editable per breakpoint so it can't be hardcoded here. |
| 17 |
*/ |
| 18 |
class Atomic_Container_Presentation { |
| 19 |
|
| 20 |
const WIDGET_EL_TYPE = 'widget'; |
| 21 |
|
| 22 |
const SHELL_STYLES = [ |
| 23 |
'position' => 'relative', |
| 24 |
'width' => '100%', |
| 25 |
'min-width' => '0', |
| 26 |
]; |
| 27 |
|
| 28 |
const SHELL_CSS = '.e-con{position:relative;width:100%;min-width:0;}'; |
| 29 |
|
| 30 |
const DOCUMENT_ROOT_SHELL_CSS = '.e-con{position:relative;width:100%;min-width:0;margin-inline-start:auto;margin-inline-end:auto;max-width:100%;}'; |
| 31 |
|
| 32 |
public static function applies_to( array $element_config ): bool { |
| 33 |
$is_atomic = ! empty( $element_config['atomic'] ); |
| 34 |
$is_element = self::WIDGET_EL_TYPE !== ( $element_config['elType'] ?? self::WIDGET_EL_TYPE ); |
| 35 |
|
| 36 |
return $is_atomic && $is_element; |
| 37 |
} |
| 38 |
|
| 39 |
public static function to_css_string( bool $is_document_root ): string { |
| 40 |
return $is_document_root ? self::DOCUMENT_ROOT_SHELL_CSS : self::SHELL_CSS; |
| 41 |
} |
| 42 |
} |
| 43 |
|