PluginProbe
Elementor Website Builder – more than just a page builder / 4.0.0
Elementor Website Builder – more than just a page builder v4.0.0
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 4.0.7 All 451 releases
elementor / modules / atomic-widgets / styles / size-constants.php

size-constants.php in Elementor Website Builder – more than just a page builder 4.0.0, at modules/atomic-widgets/styles/size-constants.php

254 lines 5.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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_CH = 'ch';
17 const UNIT_VMIN = 'vmin';
18 const UNIT_VMAX = 'vmax';
19 const UNIT_SECOND = 's';
20 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
28 const DEFAULT_UNIT = self::UNIT_PX;
29
30 private const LENGTH_UNITS = [
31 self::UNIT_PX,
32 self::UNIT_EM,
33 self::UNIT_REM,
34 self::UNIT_VW,
35 self::UNIT_VH,
36 self::UNIT_CH,
37 ];
38
39 private const TIME_UNITS = [
40 self::UNIT_MILLI_SECOND,
41 self::UNIT_SECOND,
42 ];
43
44 private const ANGLE_UNITS = [
45 self::UNIT_DEG,
46 self::UNIT_RAD,
47 self::UNIT_GRAD,
48 self::UNIT_TURN,
49 ];
50
51 private const EXTENDED_UNITS = [
52 self::UNIT_AUTO,
53 self::UNIT_CUSTOM,
54 ];
55
56 private const VIEWPORT_MIN_MAX_UNITS = [
57 self::UNIT_VMIN,
58 self::UNIT_VMAX,
59 ];
60
61 private const NUMERIC_UNITS = [
62 ...self::LENGTH_UNITS,
63 self::UNIT_PERCENT,
64 self::UNIT_CUSTOM,
65 ];
66
67 private static function presets(): array {
68 return [
69 'layout' => self::NUMERIC_UNITS,
70 'spacing' => self::NUMERIC_UNITS,
71 'position' => self::NUMERIC_UNITS,
72 'typography' => self::NUMERIC_UNITS,
73 'border' => self::NUMERIC_UNITS,
74 'box_shadow' => self::NUMERIC_UNITS,
75 'transform' => self::NUMERIC_UNITS,
76
77 'spacing_margin' => self::standard_units(),
78
79 'anchor_offset' => [
80 ...self::LENGTH_UNITS,
81 self::UNIT_CUSTOM,
82 ],
83
84 'stroke_width' => [
85 self::UNIT_PX,
86 self::UNIT_EM,
87 self::UNIT_REM,
88 self::UNIT_CUSTOM,
89 ],
90
91 'transition' => [
92 ...self::TIME_UNITS,
93 self::UNIT_CUSTOM,
94 ],
95
96 'opacity' => [
97 self::UNIT_PERCENT,
98 self::UNIT_CUSTOM,
99 ],
100
101 'rotate' => [
102 ...self::ANGLE_UNITS,
103 self::UNIT_CUSTOM,
104 ],
105
106 'drop_shadow' => [
107 ...self::LENGTH_UNITS,
108 self::UNIT_CUSTOM,
109 ],
110
111 'blur_filter' => [
112 ...self::LENGTH_UNITS,
113 self::UNIT_CUSTOM,
114 ],
115
116 'intensity_filter' => [
117 self::UNIT_PERCENT,
118 self::UNIT_CUSTOM,
119 ],
120
121 'color_tone_filter' => [
122 self::UNIT_PERCENT,
123 self::UNIT_CUSTOM,
124 ],
125
126 'hue_rotate_filter' => [
127 ...self::ANGLE_UNITS,
128 self::UNIT_CUSTOM,
129 ],
130 ];
131 }
132
133 public static function standard_units(): array {
134 return [
135 ...self::LENGTH_UNITS,
136 self::UNIT_PERCENT,
137 self::UNIT_AUTO,
138 self::UNIT_CUSTOM,
139 ];
140 }
141
142 public static function all_supported_units(): array {
143 return [
144 ...self::LENGTH_UNITS,
145 ...self::TIME_UNITS,
146 ...self::ANGLE_UNITS,
147 ...self::EXTENDED_UNITS,
148 ...self::VIEWPORT_MIN_MAX_UNITS,
149 self::UNIT_PERCENT,
150 ];
151 }
152
153 public static function grouped_units(): array {
154 return [
155 'length' => self::LENGTH_UNITS,
156 'angle' => self::ANGLE_UNITS,
157 'time' => self::TIME_UNITS,
158 'extended_units' => self::EXTENDED_UNITS,
159 ];
160 }
161
162 private static function by_group( string $group ): array {
163 $groups = self::grouped_units();
164
165 return $groups[ $group ] ?? [];
166 }
167
168 public static function get_preset( string $name ): array {
169 $presets = self::presets();
170
171 return $presets[ $name ] ?? [];
172 }
173
174 public static function length(): array {
175 return self::by_group( 'length' );
176 }
177
178 public static function time(): array {
179 return self::by_group( 'time' );
180 }
181
182 public static function layout(): array {
183 return self::get_preset( 'layout' );
184 }
185
186 public static function spacing_margin(): array {
187 return self::get_preset( 'spacing_margin' );
188 }
189
190 public static function spacing(): array {
191 return self::get_preset( 'spacing' );
192 }
193
194 public static function position(): array {
195 return self::get_preset( 'position' );
196 }
197
198 public static function anchor_offset(): array {
199 return self::get_preset( 'anchor_offset' );
200 }
201
202 public static function typography(): array {
203 return self::get_preset( 'typography' );
204 }
205
206 public static function stroke_width(): array {
207 return self::get_preset( 'stroke_width' );
208 }
209
210 public static function transition(): array {
211 return self::get_preset( 'transition' );
212 }
213
214 public static function border(): array {
215 return self::get_preset( 'border' );
216 }
217
218 public static function opacity(): array {
219 return self::get_preset( 'opacity' );
220 }
221
222 public static function box_shadow(): array {
223 return self::get_preset( 'box_shadow' );
224 }
225
226 public static function rotate(): array {
227 return self::get_preset( 'rotate' );
228 }
229
230 public static function transform(): array {
231 return self::get_preset( 'transform' );
232 }
233
234 public static function drop_shadow(): array {
235 return self::get_preset( 'drop_shadow' );
236 }
237
238 public static function blur_filter(): array {
239 return self::get_preset( 'blur_filter' );
240 }
241
242 public static function intensity_filter(): array {
243 return self::get_preset( 'intensity_filter' );
244 }
245
246 public static function color_tone_filter(): array {
247 return self::get_preset( 'color_tone_filter' );
248 }
249
250 public static function hue_rotate_filter(): array {
251 return self::get_preset( 'hue_rotate_filter' );
252 }
253 }
254