PluginProbe
Elementor Website Builder – more than just a page builder / 3.32.0-dev2
Elementor Website Builder – more than just a page builder v3.32.0-dev2
4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 All 452 releases
← All changes | modules/atomic-widgets/styles/size-constants.php +49 -227 4.2.13.32.0-dev2 View file →
@@ -12,296 +12,118 @@
12 12 const UNIT_EM = 'em';
13 13 const UNIT_REM = 'rem';
14 14 const UNIT_VW = 'vw';
15 15 const UNIT_VH = 'vh';
16 - const UNIT_CH = 'ch';
17 - const UNIT_VMIN = 'vmin';
18 - const UNIT_VMAX = 'vmax';
16 + const UNIT_AUTO = 'auto';
17 + const UNIT_CUSTOM = 'custom';
19 18 const UNIT_SECOND = 's';
20 19 const UNIT_MILLI_SECOND = 'ms';
21 - const UNIT_DEG = 'deg';
22 - const UNIT_RAD = 'rad';
23 - const UNIT_GRAD = 'grad';
24 - const UNIT_TURN = 'turn';
25 - const UNIT_AUTO = 'auto';
26 - const UNIT_CUSTOM = 'custom';
27 - const UNIT_FR = 'fr';
20 + const UNIT_ANGLE_DEG = 'deg';
28 21
29 - const DEFAULT_UNIT = self::UNIT_PX;
30 -
31 - private const ORDER = [
22 + const LENGTH_UNITS = [
32 23 self::UNIT_PX,
33 - self::UNIT_PERCENT,
34 24 self::UNIT_EM,
35 25 self::UNIT_REM,
36 26 self::UNIT_VW,
37 27 self::UNIT_VH,
38 - self::UNIT_CH,
39 - self::UNIT_VMIN,
40 - self::UNIT_VMAX,
41 - self::UNIT_FR,
42 - self::UNIT_DEG,
43 - self::UNIT_RAD,
44 - self::UNIT_GRAD,
45 - self::UNIT_TURN,
46 - self::UNIT_SECOND,
47 - self::UNIT_MILLI_SECOND,
48 - self::UNIT_AUTO,
49 - self::UNIT_CUSTOM,
50 28 ];
51 29
52 - private const LENGTH_UNITS = [
53 - self::UNIT_PX,
54 - self::UNIT_EM,
55 - self::UNIT_REM,
56 - self::UNIT_VW,
57 - self::UNIT_VH,
58 - self::UNIT_CH,
59 - ];
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' ];
60 34
61 - private const TIME_UNITS = [
62 - self::UNIT_MILLI_SECOND,
63 - self::UNIT_SECOND,
64 - ];
65 -
66 - private const ANGLE_UNITS = [
67 - self::UNIT_DEG,
68 - self::UNIT_RAD,
69 - self::UNIT_GRAD,
70 - self::UNIT_TURN,
71 - ];
72 -
73 - private const EXTENDED_UNITS = [
74 - self::UNIT_AUTO,
75 - self::UNIT_CUSTOM,
76 - ];
77 -
78 - private const VIEWPORT_MIN_MAX_UNITS = [
79 - self::UNIT_VMIN,
80 - self::UNIT_VMAX,
81 - ];
82 -
83 - private const NUMERIC_UNITS = [
84 - ...self::LENGTH_UNITS,
85 - self::UNIT_PERCENT,
86 - self::UNIT_CUSTOM,
87 - ];
88 -
89 - private static function presets(): array {
90 - return [
91 - 'layout' => self::sort_by_preferred_order( self::NUMERIC_UNITS ),
92 - 'spacing' => self::sort_by_preferred_order( self::NUMERIC_UNITS ),
93 - 'position' => self::NUMERIC_UNITS,
94 - 'typography' => self::NUMERIC_UNITS,
95 - 'border' => self::NUMERIC_UNITS,
96 - 'box_shadow' => self::NUMERIC_UNITS,
97 - 'transform' => self::NUMERIC_UNITS,
98 -
99 - 'spacing_margin' => self::standard_units(),
100 -
101 - 'anchor_offset' => [
102 - ...self::LENGTH_UNITS,
103 - self::UNIT_CUSTOM,
104 - ],
105 -
106 - 'stroke_width' => [
107 - self::UNIT_PX,
108 - self::UNIT_EM,
109 - self::UNIT_REM,
110 - self::UNIT_CUSTOM,
111 - ],
112 -
113 - 'transition' => [
114 - ...self::TIME_UNITS,
115 - self::UNIT_CUSTOM,
116 - ],
117 -
118 - 'opacity' => [
119 - self::UNIT_PERCENT,
120 - self::UNIT_CUSTOM,
121 - ],
122 -
123 - 'rotate' => [
124 - ...self::ANGLE_UNITS,
125 - self::UNIT_CUSTOM,
126 - ],
127 -
128 - 'drop_shadow' => [
129 - ...self::LENGTH_UNITS,
130 - self::UNIT_CUSTOM,
131 - ],
132 -
133 - 'blur_filter' => [
134 - ...self::LENGTH_UNITS,
135 - self::UNIT_CUSTOM,
136 - ],
137 -
138 - 'intensity_filter' => [
139 - self::UNIT_PERCENT,
140 - self::UNIT_CUSTOM,
141 - ],
142 -
143 - 'color_tone_filter' => [
144 - self::UNIT_PERCENT,
145 - self::UNIT_CUSTOM,
146 - ],
147 -
148 - 'hue_rotate_filter' => [
149 - ...self::ANGLE_UNITS,
150 - self::UNIT_CUSTOM,
151 - ],
152 - ];
153 - }
154 -
155 - private static function sort_by_preferred_order( array $units ): array {
156 - $index = array_flip( self::ORDER );
157 -
158 - usort( $units, fn( $a, $b ) =>
159 - ( $index[ $a ] ?? PHP_INT_MAX ) <=> ( $index[ $b ] ?? PHP_INT_MAX )
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,
160 42 );
161 -
162 - return $units;
163 43 }
164 44
165 - public static function standard_units(): array {
166 - return self::sort_by_preferred_order( [
167 - ...self::LENGTH_UNITS,
168 - self::UNIT_PERCENT,
169 - self::UNIT_AUTO,
170 - self::UNIT_CUSTOM,
171 - ] );
172 - }
173 -
174 - public static function all_supported_units(): array {
45 + public static function all(): array {
175 46 return [
176 47 ...self::LENGTH_UNITS,
177 - ...self::TIME_UNITS,
178 - ...self::ANGLE_UNITS,
179 - ...self::EXTENDED_UNITS,
180 - ...self::VIEWPORT_MIN_MAX_UNITS,
181 48 self::UNIT_PERCENT,
182 - self::UNIT_FR,
183 - ];
184 - }
185 -
186 - public static function grid_track(): array {
187 - return [
188 - self::UNIT_FR,
189 - self::UNIT_CUSTOM,
190 - ];
191 - }
192 -
193 - public static function grid_auto_track(): array {
194 - return self::sort_by_preferred_order( [
195 - self::UNIT_PX,
196 - self::UNIT_PERCENT,
197 - self::UNIT_FR,
198 49 self::UNIT_AUTO,
199 - self::UNIT_CUSTOM,
200 - ] );
201 - }
202 -
203 - public static function grouped_units(): array {
204 - return [
205 - 'length' => self::LENGTH_UNITS,
206 - 'angle' => self::ANGLE_UNITS,
207 - 'time' => self::TIME_UNITS,
208 - 'extended_units' => self::EXTENDED_UNITS,
209 50 ];
210 51 }
211 52
212 - private static function by_group( string $group ): array {
213 - $groups = self::grouped_units();
214 -
215 - return $groups[ $group ] ?? [];
53 + private static function units_without_auto(): array {
54 + return [ ...self::LENGTH_UNITS, self::UNIT_PERCENT ];
216 55 }
217 56
218 - public static function get_preset( string $name ): array {
219 - $presets = self::presets();
220 -
221 - return $presets[ $name ] ?? [];
57 + public static function layout() {
58 + return self::units_without_auto();
222 59 }
223 60
224 - public static function length(): array {
225 - return self::by_group( 'length' );
226 - }
227 -
228 - public static function time(): array {
229 - return self::by_group( 'time' );
230 - }
231 -
232 - public static function angle(): array {
233 - return self::by_group( 'angle' );
234 - }
235 -
236 - public static function layout(): array {
237 - return self::get_preset( 'layout' );
238 - }
239 -
240 - public static function spacing_margin(): array {
241 - return self::get_preset( 'spacing_margin' );
242 - }
243 -
244 61 public static function spacing(): array {
245 - return self::get_preset( 'spacing' );
62 + return self::units_without_auto();
246 63 }
247 64
248 65 public static function position(): array {
249 - return self::get_preset( 'position' );
66 + return self::units_without_auto();
250 67 }
251 68
252 - public static function anchor_offset(): array {
253 - return self::get_preset( 'anchor_offset' );
69 + public static function anchor_offset() {
70 + return self::LENGTH_UNITS;
254 71 }
255 72
256 73 public static function typography(): array {
257 - return self::get_preset( 'typography' );
74 + return self::units_without_auto();
258 75 }
259 76
260 - public static function stroke_width(): array {
261 - return self::get_preset( 'stroke_width' );
77 + public static function stroke_width() {
78 + return [
79 + self::UNIT_PX,
80 + self::UNIT_EM,
81 + self::UNIT_REM,
82 + ];
262 83 }
263 84
264 - public static function transition(): array {
265 - return self::get_preset( 'transition' );
85 + public static function transition() {
86 + return self::TIME_UNITS;
266 87 }
267 88
268 89 public static function border(): array {
269 - return self::get_preset( 'border' );
90 + return self::units_without_auto();
270 91 }
271 92
93 +
272 94 public static function opacity(): array {
273 - return self::get_preset( 'opacity' );
95 + return [ self::UNIT_PERCENT ];
274 96 }
275 97
276 98 public static function box_shadow(): array {
277 - return self::get_preset( 'box_shadow' );
99 + return self::units_without_auto();
278 100 }
279 101
280 102 public static function rotate(): array {
281 - return self::get_preset( 'rotate' );
103 + return self::ANGLE_UNITS;
282 104 }
283 105
284 106 public static function transform(): array {
285 - return self::get_preset( 'transform' );
107 + return self::units_without_auto();
286 108 }
287 109
288 - public static function drop_shadow(): array {
289 - return self::get_preset( 'drop_shadow' );
110 + public static function drop_shadow() {
111 + return self::LENGTH_UNITS;
290 112 }
291 113
292 - public static function blur_filter(): array {
293 - return self::get_preset( 'blur_filter' );
114 + public static function blur_filter() {
115 + return self::LENGTH_UNITS;
294 116 }
295 117
296 - public static function intensity_filter(): array {
297 - return self::get_preset( 'intensity_filter' );
118 + public static function intensity_filter() {
119 + return [ self::UNIT_PERCENT ];
298 120 }
299 121
300 - public static function color_tone_filter(): array {
301 - return self::get_preset( 'color_tone_filter' );
122 + public static function color_tone_filter() {
123 + return [ self::UNIT_PERCENT ];
302 124 }
303 125
304 - public static function hue_rotate_filter(): array {
305 - return self::get_preset( 'hue_rotate_filter' );
126 + public static function hue_rotate_filter() {
127 + return self::ANGLE_UNITS;
306 128 }
307 129 }