| 1 |
<?php |
| 2 |
|
| 3 |
namespace Elementor\Modules\AtomicWidgets\CssConverter\Expanders; |
| 4 |
|
| 5 |
use Elementor\Modules\AtomicWidgets\CssConverter\Shorthand_Expander_Base; |
| 6 |
|
| 7 |
if ( ! defined( 'ABSPATH' ) ) { |
| 8 |
exit; // Exit if accessed directly. |
| 9 |
} |
| 10 |
|
| 11 |
/** |
| 12 |
* Rewrites physical inset properties (top, right, bottom, left) to their logical equivalents |
| 13 |
* (inset-block-start, inset-inline-end, inset-block-end, inset-inline-start) so the standard |
| 14 |
* Size converters can handle them without needing separate converter registrations. |
| 15 |
* |
| 16 |
* Assumes LTR writing mode, which matches the Elementor canvas default. |
| 17 |
*/ |
| 18 |
class Physical_To_Logical_Expander extends Shorthand_Expander_Base { |
| 19 |
const PHYSICAL_TO_LOGICAL = [ |
| 20 |
'top' => 'inset-block-start', |
| 21 |
'right' => 'inset-inline-end', |
| 22 |
'bottom' => 'inset-block-end', |
| 23 |
'left' => 'inset-inline-start', |
| 24 |
]; |
| 25 |
|
| 26 |
protected function get_supported_properties(): array { |
| 27 |
return array_keys( self::PHYSICAL_TO_LOGICAL ); |
| 28 |
} |
| 29 |
|
| 30 |
protected function expand_null( array $rule ): array { |
| 31 |
return [ $this->null_rule( self::PHYSICAL_TO_LOGICAL[ $rule['property'] ] ) ]; |
| 32 |
} |
| 33 |
|
| 34 |
protected function do_expand( array $rule ): array { |
| 35 |
$logical = self::PHYSICAL_TO_LOGICAL[ $rule['property'] ]; |
| 36 |
|
| 37 |
return [ |
| 38 |
[ |
| 39 |
'property' => $logical, |
| 40 |
'value' => $rule['value'], |
| 41 |
'declaration' => $logical . ': ' . $rule['value'], |
| 42 |
], |
| 43 |
]; |
| 44 |
} |
| 45 |
} |
| 46 |
|