| 1 |
<?php |
| 2 |
|
| 3 |
namespace Elementor\Modules\AtomicWidgets\Styles; |
| 4 |
|
| 5 |
if ( ! defined( 'ABSPATH' ) ) { |
| 6 |
exit; // Exit if accessed directly. |
| 7 |
} |
| 8 |
|
| 9 |
class Size_Constants { |
| 10 |
const UNIT_PX = 'px'; |
| 11 |
const UNIT_PERCENT = '%'; |
| 12 |
const UNIT_EM = 'em'; |
| 13 |
const UNIT_REM = 'rem'; |
| 14 |
const UNIT_VW = 'vw'; |
| 15 |
const UNIT_VH = 'vh'; |
| 16 |
const UNIT_AUTO = 'auto'; |
| 17 |
const UNIT_CUSTOM = 'custom'; |
| 18 |
const UNIT_SECOND = 's'; |
| 19 |
const UNIT_MILLI_SECOND = 'ms'; |
| 20 |
const UNIT_ANGLE_DEG = 'deg'; |
| 21 |
|
| 22 |
const LENGTH_UNITS = [ |
| 23 |
self::UNIT_PX, |
| 24 |
self::UNIT_EM, |
| 25 |
self::UNIT_REM, |
| 26 |
self::UNIT_VW, |
| 27 |
self::UNIT_VH, |
| 28 |
]; |
| 29 |
|
| 30 |
const TIME_UNITS = [ self::UNIT_SECOND, self::UNIT_MILLI_SECOND ]; |
| 31 |
const EXTENDED_UNITS = [ self::UNIT_AUTO, self::UNIT_CUSTOM ]; |
| 32 |
const VIEWPORT_MIN_MAX_UNITS = [ 'vmin', 'vmax' ]; |
| 33 |
const ANGLE_UNITS = [ self::UNIT_ANGLE_DEG, 'rad', 'grad', 'turn' ]; |
| 34 |
|
| 35 |
public static function all_supported_units(): array { |
| 36 |
return array_merge( |
| 37 |
self::all(), |
| 38 |
self::ANGLE_UNITS, |
| 39 |
self::TIME_UNITS, |
| 40 |
self::EXTENDED_UNITS, |
| 41 |
self::VIEWPORT_MIN_MAX_UNITS, |
| 42 |
); |
| 43 |
} |
| 44 |
|
| 45 |
public static function all(): array { |
| 46 |
return [ |
| 47 |
...self::LENGTH_UNITS, |
| 48 |
self::UNIT_PERCENT, |
| 49 |
self::UNIT_AUTO, |
| 50 |
]; |
| 51 |
} |
| 52 |
|
| 53 |
private static function units_without_auto(): array { |
| 54 |
return [ ...self::LENGTH_UNITS, self::UNIT_PERCENT ]; |
| 55 |
} |
| 56 |
|
| 57 |
public static function layout() { |
| 58 |
return self::units_without_auto(); |
| 59 |
} |
| 60 |
|
| 61 |
public static function spacing(): array { |
| 62 |
return self::units_without_auto(); |
| 63 |
} |
| 64 |
|
| 65 |
public static function position(): array { |
| 66 |
return self::units_without_auto(); |
| 67 |
} |
| 68 |
|
| 69 |
public static function anchor_offset() { |
| 70 |
return self::LENGTH_UNITS; |
| 71 |
} |
| 72 |
|
| 73 |
public static function typography(): array { |
| 74 |
return self::units_without_auto(); |
| 75 |
} |
| 76 |
|
| 77 |
public static function stroke_width() { |
| 78 |
return [ |
| 79 |
self::UNIT_PX, |
| 80 |
self::UNIT_EM, |
| 81 |
self::UNIT_REM, |
| 82 |
]; |
| 83 |
} |
| 84 |
|
| 85 |
public static function transition() { |
| 86 |
return self::TIME_UNITS; |
| 87 |
} |
| 88 |
|
| 89 |
public static function border(): array { |
| 90 |
return self::units_without_auto(); |
| 91 |
} |
| 92 |
|
| 93 |
|
| 94 |
public static function opacity(): array { |
| 95 |
return [ self::UNIT_PERCENT ]; |
| 96 |
} |
| 97 |
|
| 98 |
public static function box_shadow(): array { |
| 99 |
return self::units_without_auto(); |
| 100 |
} |
| 101 |
|
| 102 |
public static function rotate(): array { |
| 103 |
return self::ANGLE_UNITS; |
| 104 |
} |
| 105 |
|
| 106 |
public static function transform(): array { |
| 107 |
return self::units_without_auto(); |
| 108 |
} |
| 109 |
|
| 110 |
public static function drop_shadow() { |
| 111 |
return self::LENGTH_UNITS; |
| 112 |
} |
| 113 |
|
| 114 |
public static function blur_filter() { |
| 115 |
return self::LENGTH_UNITS; |
| 116 |
} |
| 117 |
|
| 118 |
public static function intensity_filter() { |
| 119 |
return [ self::UNIT_PERCENT ]; |
| 120 |
} |
| 121 |
|
| 122 |
public static function color_tone_filter() { |
| 123 |
return [ self::UNIT_PERCENT ]; |
| 124 |
} |
| 125 |
|
| 126 |
public static function hue_rotate_filter() { |
| 127 |
return self::ANGLE_UNITS; |
| 128 |
} |
| 129 |
} |
| 130 |
|