@mlut/core 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -0
- package/_index.scss +1 -0
- package/_tools.scss +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/jit/JitEngine.d.ts +19 -0
- package/dist/jit/JitEngine.js +124 -0
- package/dist/jit/index.d.ts +1 -0
- package/dist/jit/index.js +1 -0
- package/dist/sass/addons/demo-theme.scss +112 -0
- package/dist/sass/css/_base-setup.scss +3 -0
- package/dist/sass/css/_index.scss +2 -0
- package/dist/sass/css/helpers/_index.scss +3 -0
- package/dist/sass/css/helpers/btn.scss +28 -0
- package/dist/sass/css/helpers/gs-debug.scss +28 -0
- package/dist/sass/css/helpers/ratio-box.scss +47 -0
- package/dist/sass/css/helpers/row.scss +98 -0
- package/dist/sass/css/helpers/wrapper.scss +21 -0
- package/dist/sass/css/styles/_index.scss +2 -0
- package/dist/sass/css/styles/generic.scss +296 -0
- package/dist/sass/css/styles/variables.scss +32 -0
- package/dist/sass/css/utils/_bg-bd.scss +27 -0
- package/dist/sass/css/utils/_grid.scss +37 -0
- package/dist/sass/css/utils/_index.scss +2 -0
- package/dist/sass/css/utils/_load.scss +9 -0
- package/dist/sass/css/utils/_transition.scss +16 -0
- package/dist/sass/css/utils/box-alignment.scss +29 -0
- package/dist/sass/css/utils/box-model.scss +48 -0
- package/dist/sass/css/utils/grid-system.scss +17 -0
- package/dist/sass/css/utils/init.scss +107 -0
- package/dist/sass/css/utils/other.scss +35 -0
- package/dist/sass/css/utils/text.scss +33 -0
- package/dist/sass/css/utils/visual.scss +32 -0
- package/dist/sass/index.scss +4 -0
- package/dist/sass/tools/_index.scss +4 -0
- package/dist/sass/tools/functions/_index.import.scss +3 -0
- package/dist/sass/tools/functions/_index.scss +9 -0
- package/dist/sass/tools/functions/base/_error.scss +9 -0
- package/dist/sass/tools/functions/base/_getters.scss +124 -0
- package/dist/sass/tools/functions/base/_index.scss +11 -0
- package/dist/sass/tools/functions/base/_list.scss +56 -0
- package/dist/sass/tools/functions/base/_math.scss +149 -0
- package/dist/sass/tools/functions/base/_string.scss +300 -0
- package/dist/sass/tools/functions/common/_custom-units.scss +231 -0
- package/dist/sass/tools/functions/common/_forward-tools.scss +2 -0
- package/dist/sass/tools/functions/common/_helpers.scss +57 -0
- package/dist/sass/tools/functions/common/_index.scss +9 -0
- package/dist/sass/tools/functions/common/_utils.scss +211 -0
- package/dist/sass/tools/functions/high/_at-rules.scss +296 -0
- package/dist/sass/tools/functions/high/_forward-tools.scss +3 -0
- package/dist/sass/tools/functions/high/_index.scss +8 -0
- package/dist/sass/tools/functions/high/utils/_index.scss +288 -0
- package/dist/sass/tools/functions/high/utils/_parse-util.scss +107 -0
- package/dist/sass/tools/functions/high/utils/_range-generators.scss +355 -0
- package/dist/sass/tools/functions/high/utils/_util-apply-selector.scss +134 -0
- package/dist/sass/tools/functions/high/utils/_value-converters.scss +294 -0
- package/dist/sass/tools/functions/high/utils/_value-transformers.scss +65 -0
- package/dist/sass/tools/mixins/_index.import.scss +2 -0
- package/dist/sass/tools/mixins/_index.scss +8 -0
- package/dist/sass/tools/mixins/base/_forward-tools.scss +2 -0
- package/dist/sass/tools/mixins/base/_index.scss +93 -0
- package/dist/sass/tools/mixins/base/_mk-ar.scss +96 -0
- package/dist/sass/tools/mixins/base/_mk-state.scss +175 -0
- package/dist/sass/tools/mixins/high/_forward-tools.scss +3 -0
- package/dist/sass/tools/mixins/high/_index.scss +1 -0
- package/dist/sass/tools/mixins/high/utils/_index.scss +188 -0
- package/dist/sass/tools/mixins/high/utils/_mk-util.scss +366 -0
- package/dist/sass/tools/settings/_index.import.scss +3 -0
- package/dist/sass/tools/settings/_index.scss +3 -0
- package/dist/sass/tools/settings/base/_general.scss +175 -0
- package/dist/sass/tools/settings/base/_index.scss +2 -0
- package/dist/sass/tools/settings/base/_utils.scss +578 -0
- package/dist/sass/tools/settings/common/_at-rules.scss +213 -0
- package/dist/sass/tools/settings/common/_index.scss +2 -0
- package/dist/sass/tools/settings/common/_utils.scss +1926 -0
- package/dist/sass/tools/settings/high/_forward-tools.scss +2 -0
- package/dist/sass/tools/settings/high/_grid.scss +55 -0
- package/dist/sass/tools/settings/high/_index.scss +2 -0
- package/dist/sass/tools/settings/high/_utils.scss +104 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/logger.d.ts +7 -0
- package/dist/utils/logger.js +13 -0
- package/package.json +48 -0
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
@use 'sass:meta';
|
|
2
|
+
@use 'sass:map';
|
|
3
|
+
@use 'sass:math';
|
|
4
|
+
@use 'sass:string';
|
|
5
|
+
@use 'sass:list';
|
|
6
|
+
|
|
7
|
+
@use '../../settings/base/general' as ml;
|
|
8
|
+
@use 'error' as *;
|
|
9
|
+
|
|
10
|
+
// String
|
|
11
|
+
//
|
|
12
|
+
// Functions to manipulate strings.
|
|
13
|
+
//
|
|
14
|
+
// Styleguide: sass-tools.functions.string
|
|
15
|
+
|
|
16
|
+
// str2n
|
|
17
|
+
//
|
|
18
|
+
// Convert string to number. Returns null if conversion is not possible.
|
|
19
|
+
// ```scss
|
|
20
|
+
//@debug ml.str2n('1.5'); // 1.5
|
|
21
|
+
//@debug ml.str2n('1x5'); // 1
|
|
22
|
+
//@debug ml.str2n('xx'); // null
|
|
23
|
+
//@debug ml.str2n('1x5', 1); // 1x5
|
|
24
|
+
// ```
|
|
25
|
+
//
|
|
26
|
+
// $str - string to be converted
|
|
27
|
+
// $skip-unknown = false - bool flag. If it on and the string contains an unknown sequence of characters after the number, then the it is returned as is
|
|
28
|
+
//
|
|
29
|
+
// Styleguide: sass-tools.functions.string.str2n
|
|
30
|
+
|
|
31
|
+
@function str2n($str, $skip-unknown: false) {
|
|
32
|
+
$value-type: meta.type-of($str);
|
|
33
|
+
|
|
34
|
+
@if $value-type == 'number' {
|
|
35
|
+
@return $str;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@if $value-type != 'string' {
|
|
39
|
+
@return null;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
$negative: string.slice($str, 1, 1) == '-';
|
|
43
|
+
$result: 0;
|
|
44
|
+
$decimal: false;
|
|
45
|
+
|
|
46
|
+
@for $i from if($negative, 2, 1) through string.length($str) {
|
|
47
|
+
$char: string.slice($str, $i, $i);
|
|
48
|
+
$digit: list.index(ml.$dec-digits, $char);
|
|
49
|
+
|
|
50
|
+
@if $digit and not $decimal {
|
|
51
|
+
$result: $result * 10 + ($digit - 1);
|
|
52
|
+
} @else if $digit and $decimal {
|
|
53
|
+
$result: $result + math.div($digit - 1, $decimal);
|
|
54
|
+
$decimal: $decimal * 10;
|
|
55
|
+
} @else if $char == '.' and not $decimal {
|
|
56
|
+
$decimal: 10;
|
|
57
|
+
} @else if ($i == 1 and not $negative) or ($i == 2 and $negative) {
|
|
58
|
+
@return null;
|
|
59
|
+
} @else {
|
|
60
|
+
$unit: map.get(ml.$units-all, string.to-lower-case(string.slice($str, $i)));
|
|
61
|
+
|
|
62
|
+
@if not $unit {
|
|
63
|
+
@if $skip-unknown {
|
|
64
|
+
@return $str;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
$unit: 1;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
@return if($negative, -$result, $result) * $unit;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
@return if($negative, -$result, $result);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// str-digit-index
|
|
78
|
+
//
|
|
79
|
+
// Returns the first index of digit in $str, or `null` if digits not found
|
|
80
|
+
// ```scss
|
|
81
|
+
//@debug ml.str-digit-index('Mb55'); // 3
|
|
82
|
+
//@debug ml.str-digit-index('Mt-a'); // null
|
|
83
|
+
// ```
|
|
84
|
+
//
|
|
85
|
+
// $str - string for search
|
|
86
|
+
//
|
|
87
|
+
// Styleguide: sass-tools.functions.string.str_digit_index
|
|
88
|
+
|
|
89
|
+
@function str-digit-index($str) {
|
|
90
|
+
@if meta.type-of($str) != 'string' {
|
|
91
|
+
@return error('Wrong type of argument $str: `#{meta.type-of($str)}`. Expected `string`');
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
@for $i from 1 through string.length($str) {
|
|
95
|
+
@if list.index(ml.$dec-digits, string.slice($str, $i, $i)) {
|
|
96
|
+
@return $i;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
@return null;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// str-ucfirst
|
|
104
|
+
//
|
|
105
|
+
// Converts the first letter of string to uppercase
|
|
106
|
+
// ```scss
|
|
107
|
+
//@debug ml.str-ucfirst('fxg1'); // 'Fxg1'
|
|
108
|
+
// ```
|
|
109
|
+
//
|
|
110
|
+
// $str - string for converting
|
|
111
|
+
//
|
|
112
|
+
// Styleguide: sass-tools.functions.string.str_ucfirst
|
|
113
|
+
|
|
114
|
+
@function str-ucfirst($str) {
|
|
115
|
+
@if meta.type-of($str) != 'string' {
|
|
116
|
+
@return error('Wrong type of argument $str: `#{meta.type-of($str)}`. Expected `string`');
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
@return string.to-upper-case(string.slice($str, 1, 1)) + string.slice($str, 2);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// str-escape
|
|
123
|
+
//
|
|
124
|
+
// Escape special characters in value for using it in CSS selector.
|
|
125
|
+
// ```scss
|
|
126
|
+
//@debug ml.str-escape(':^:&:h'); // '\\:\\^\\:\\&\\:h'
|
|
127
|
+
//@debug ml.str-escape(1.5); // '1\\.5'
|
|
128
|
+
// ```
|
|
129
|
+
//
|
|
130
|
+
// $value - value for escaping
|
|
131
|
+
//
|
|
132
|
+
// Styleguide: sass-tools.functions.string.str_escape
|
|
133
|
+
|
|
134
|
+
@function str-escape($value) {
|
|
135
|
+
$str: $value + '';
|
|
136
|
+
$escaped: '';
|
|
137
|
+
|
|
138
|
+
@for $i from 1 through string.length($str) {
|
|
139
|
+
$char: string.slice($str, $i, $i);
|
|
140
|
+
|
|
141
|
+
@if list.index(ml.$spec-chars, $char) {
|
|
142
|
+
$char: '\\' + $char;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
$escaped: $escaped + $char;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
@return $escaped;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Private functions only for internal usage. I hope that in the future they will be built into Sass. And when it will happens I don't want that their removing broke backward compatibility.
|
|
152
|
+
|
|
153
|
+
@function str-split($str, $separator: '', $repeats: ml.$number-max) {
|
|
154
|
+
$result: ();
|
|
155
|
+
$sep-length: string.length($separator);
|
|
156
|
+
$str-length: string.length($str);
|
|
157
|
+
|
|
158
|
+
@if $sep-length == 0 {
|
|
159
|
+
@if $repeats < 1 {
|
|
160
|
+
@return $str;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
@for $i from 1 through math.min($str-length, $repeats) {
|
|
164
|
+
$result: list.append($result, string.slice($str, $i, $i));
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
@return if(
|
|
168
|
+
$repeats < $str-length,
|
|
169
|
+
list.append($result, string.slice($str, $repeats + 1)),
|
|
170
|
+
$result
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
$sep-pos: string.index($str, $separator);
|
|
175
|
+
$i: 0;
|
|
176
|
+
|
|
177
|
+
@while $sep-pos != null and $i < $repeats {
|
|
178
|
+
$result: list.append($result, string.slice($str, 1, $sep-pos - 1));
|
|
179
|
+
$str: string.slice($str, $sep-pos + $sep-length);
|
|
180
|
+
$sep-pos: string.index($str, $separator);
|
|
181
|
+
$i: $i + 1;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
@return list.append($result, $str);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
//Trim so simple because common usage will trim one or zero spaces in one side.
|
|
188
|
+
|
|
189
|
+
@function str-trim($str) {
|
|
190
|
+
@while 1 {
|
|
191
|
+
@if string.slice($str, 1, 1) == ' ' {
|
|
192
|
+
$str: string.slice($str, 2);
|
|
193
|
+
} @else if string.slice($str, -1) == ' ' {
|
|
194
|
+
$str: string.slice($str, 1, -2);
|
|
195
|
+
} @else {
|
|
196
|
+
@return $str;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
@function str-replace($str, $old, $new: '') {
|
|
202
|
+
$old-pos: string.index($str, $old);
|
|
203
|
+
|
|
204
|
+
@if $old-pos {
|
|
205
|
+
@return string.slice($str, 1, $old-pos - 1) + $new + string.slice($str, $old-pos + string.length($old));
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
@return $str;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
@function str-replace-all($str, $old, $new: '') {
|
|
212
|
+
$old-pos: string.index($str, $old);
|
|
213
|
+
$old-length: string.length($old);
|
|
214
|
+
$result: '';
|
|
215
|
+
|
|
216
|
+
@while $old-pos {
|
|
217
|
+
$result: $result + string.slice($str, 1, $old-pos - 1) + $new;
|
|
218
|
+
$str: string.slice($str, $old-pos + $old-length);
|
|
219
|
+
$old-pos: string.index($str, $old);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
@return $result + $str;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
@function str-starts($str, $substr) {
|
|
226
|
+
@if meta.type-of($str) != 'string' or meta.type-of($substr) != 'string' {
|
|
227
|
+
@return false;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
@return string.slice($str, 1, string.length($substr)) == $substr;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
@function str-contains-item($item, $i, $str) {
|
|
234
|
+
@return string.index($str, $item);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
@function str-hex2color($str) {
|
|
238
|
+
$value-type: meta.type-of($str);
|
|
239
|
+
|
|
240
|
+
@if $value-type == 'color' {
|
|
241
|
+
@return $str;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
@if $value-type != 'string' or string.slice($str, 1, 1) != '#' {
|
|
245
|
+
@return null;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
$str-length: string.length($str);
|
|
249
|
+
|
|
250
|
+
@if $str-length != 4 and $str-length != 7 {
|
|
251
|
+
@return error('Invalid color format: `#{$str}`. Allowed 3 or 6 hexadecimal digits');
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
$r: '';
|
|
255
|
+
$g: '';
|
|
256
|
+
$b: '';
|
|
257
|
+
$str: string.to-lower-case($str);
|
|
258
|
+
|
|
259
|
+
$max-length: if(
|
|
260
|
+
$str-length == 4, 1, 2
|
|
261
|
+
);
|
|
262
|
+
|
|
263
|
+
@for $i from 2 through $str-length {
|
|
264
|
+
$digit: string.slice($str, $i, $i);
|
|
265
|
+
|
|
266
|
+
@if not list.index(ml.$hex-digits, $digit) {
|
|
267
|
+
@return error('Invalid character: `#{$digit}`. Allowed only hexadecimal digits');
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
@if string.length($r) < $max-length {
|
|
271
|
+
$r: $r + $digit;
|
|
272
|
+
} @else if string.length($g) < $max-length {
|
|
273
|
+
$g: $g + $digit;
|
|
274
|
+
} @else {
|
|
275
|
+
$b: $b + $digit;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
@if $str-length == 4 {
|
|
280
|
+
$r: $r + $r;
|
|
281
|
+
$g: $g + $g;
|
|
282
|
+
$b: $b + $b;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
@return rgb(-hex2dec($r), -hex2dec($g), -hex2dec($b));
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
@function -hex2dec($n) {
|
|
289
|
+
$str-number: string.to-lower-case($n);
|
|
290
|
+
$result: 0;
|
|
291
|
+
$base: list.length(ml.$hex-digits);
|
|
292
|
+
$length: string.length($str-number);
|
|
293
|
+
|
|
294
|
+
@for $i from 1 through $length {
|
|
295
|
+
$digit: list.index(ml.$hex-digits, string.slice($str-number, $i, $i)) - 1;
|
|
296
|
+
$result: $result + $digit * math.pow($base, $length - $i);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
@return $result;
|
|
300
|
+
}
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
@use 'sass:meta';
|
|
2
|
+
@use 'sass:map';
|
|
3
|
+
@use 'sass:math';
|
|
4
|
+
@use 'sass:string';
|
|
5
|
+
@use 'sass:list';
|
|
6
|
+
|
|
7
|
+
@use 'forward-tools' as ml;
|
|
8
|
+
|
|
9
|
+
// Custom units
|
|
10
|
+
//
|
|
11
|
+
// Functions for working with custom units.
|
|
12
|
+
//
|
|
13
|
+
// Styleguide: sass-tools.functions.custom_units
|
|
14
|
+
|
|
15
|
+
// su
|
|
16
|
+
//
|
|
17
|
+
// Converts space units to CSS value.
|
|
18
|
+
// ```scss
|
|
19
|
+
//@debug ml.su(3u); // 0.75rem
|
|
20
|
+
//@debug ml.su(4); // 1rem
|
|
21
|
+
// ```
|
|
22
|
+
//
|
|
23
|
+
// $n - unitless number or number with `u` unit
|
|
24
|
+
// $data = () - service argument for provide any data
|
|
25
|
+
//
|
|
26
|
+
// Styleguide: sass-tools.functions.custom_units.su
|
|
27
|
+
|
|
28
|
+
@function su($n, $data: ()) {
|
|
29
|
+
@if meta.type-of($n) != 'number' {
|
|
30
|
+
@return ml.error(
|
|
31
|
+
'Wrong type of argument $n: `#{meta.type-of($n)}`. Expected `number`'
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@if math.unit($n) == 'u' {
|
|
36
|
+
$n: math.div($n, 1u);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@return ml.$su * $n;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// gg
|
|
43
|
+
//
|
|
44
|
+
// Converts grid gutter to CSS value.
|
|
45
|
+
// ```scss
|
|
46
|
+
//@debug ml.gg(5); // calc(var(--ml-gg) * 5)
|
|
47
|
+
//@debug ml.gg(1gg); // var(--ml-gg)
|
|
48
|
+
// ```
|
|
49
|
+
//
|
|
50
|
+
// $n - unitless number or number with `gg` unit
|
|
51
|
+
// $data = () - service argument for provide any data
|
|
52
|
+
//
|
|
53
|
+
// Styleguide: sass-tools.functions.custom_units.gg
|
|
54
|
+
|
|
55
|
+
@function gg($n, $data: ()) {
|
|
56
|
+
@if meta.type-of($n) != 'number' {
|
|
57
|
+
@return ml.error(
|
|
58
|
+
'Wrong type of argument $n: `#{meta.type-of($n)}`. Expected `number`'
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
@if math.unit($n) == 'gg' {
|
|
63
|
+
$n: math.div($n, 1gg);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
@return string.unquote(
|
|
67
|
+
'calc(var(#{map.get(ml.$general-cfg, "css-vars", "gg")}) * #{$n})'
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
ml.$general-cfg: map.set(
|
|
72
|
+
ml.$general-cfg, 'custom-unit-values', 'gg', meta.get-function('gg', false)
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
$-gtr-fallback-rem: ml.px2rem(ml.$gs-default-gtr);
|
|
76
|
+
|
|
77
|
+
// TODO: remove unused code
|
|
78
|
+
@function gg-fallback($util, $util-value, $css-value, $important) {
|
|
79
|
+
$value-part-init: 'calc(var(#{ml.css-var("gg")}';
|
|
80
|
+
|
|
81
|
+
@if not string.index(meta.inspect($css-value), $value-part-init) {
|
|
82
|
+
@return null;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
$def-unit: map.get(ml.$utils-db, 'utils', 'registry', $util, 'default-unit');
|
|
86
|
+
|
|
87
|
+
$value-part: $value-part-init + '#{$def-unit and "-" + $def-unit}) * ';
|
|
88
|
+
$fallback-list: ();
|
|
89
|
+
$multi-sep: list.separator($css-value);
|
|
90
|
+
|
|
91
|
+
$value-parts: (
|
|
92
|
+
(
|
|
93
|
+
$value-part,
|
|
94
|
+
string.length($value-part),
|
|
95
|
+
if(
|
|
96
|
+
$def-unit == 'rem',
|
|
97
|
+
$-gtr-fallback-rem,
|
|
98
|
+
ml.$gs-default-gtr
|
|
99
|
+
)
|
|
100
|
+
),
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
@if map.get(ml.$utils-db, 'utils', 'registry', $util, 'directions') {
|
|
104
|
+
$value-part: $value-part-init + '-rem) * ';
|
|
105
|
+
$value-parts: list.append(
|
|
106
|
+
$value-parts,
|
|
107
|
+
(
|
|
108
|
+
$value-part,
|
|
109
|
+
string.length($value-part),
|
|
110
|
+
$-gtr-fallback-rem,
|
|
111
|
+
)
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
@each $list in $css-value {
|
|
116
|
+
$converted-list: ();
|
|
117
|
+
|
|
118
|
+
@each $item in $list {
|
|
119
|
+
@if meta.type-of($item) == 'string' {
|
|
120
|
+
@each $part, $length, $fallback in $value-parts {
|
|
121
|
+
@if ml.str-starts($item, $part) {
|
|
122
|
+
$converted-list: list.append(
|
|
123
|
+
$converted-list,
|
|
124
|
+
ml.str2n(string.slice($item, $length + 1)) * $fallback
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
} @else {
|
|
129
|
+
$converted-list: list.append($converted-list, $item);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
$fallback-list: list.append($fallback-list, $converted-list, $multi-sep);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
@return $fallback-list $important;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
@if ml.$css-vars-fallback {
|
|
140
|
+
$-utils-registry: ();
|
|
141
|
+
|
|
142
|
+
@each $item in map.get(ml.$utils-cfg, 'gg-fallback-list') {
|
|
143
|
+
$props-map: ();
|
|
144
|
+
$props-list: ml.util-prop($item);
|
|
145
|
+
|
|
146
|
+
@each $item in $props-list {
|
|
147
|
+
$props-map: map.set(
|
|
148
|
+
$props-map, $item, meta.get-function('gg-fallback', false)
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
$-utils-registry: map.set(
|
|
153
|
+
$-utils-registry,
|
|
154
|
+
$item,
|
|
155
|
+
(
|
|
156
|
+
'preset-properties': $props-map,
|
|
157
|
+
'properties': $props-list
|
|
158
|
+
)
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
ml.$utils-db: map.deep-merge(
|
|
163
|
+
ml.$utils-db,
|
|
164
|
+
(
|
|
165
|
+
'utils': ('registry': $-utils-registry)
|
|
166
|
+
)
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
@function gc($n, $data: ()) {
|
|
171
|
+
@if math.unit($n) == 'gc' {
|
|
172
|
+
$n: math.div($n, 1gc);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
@return var(
|
|
176
|
+
#{ml.$cv-pref + if(map.get($data, 'util') == 'Ml', 'gsof', 'gscf')},
|
|
177
|
+
#{math.div($n, ml.$gs-columns) * 100%}
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
@function -gc-prop($util, $value, $css-value, $important) {
|
|
182
|
+
$n: ml.str2n($value);
|
|
183
|
+
|
|
184
|
+
@return if(
|
|
185
|
+
meta.type-of($n) == 'number' and math.unit($n) == 'gc',
|
|
186
|
+
math.div($n, 1gc),
|
|
187
|
+
null
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
@function -gc-fallback($util, $value, $css-value, $important) {
|
|
192
|
+
$n: ml.str2n($value);
|
|
193
|
+
|
|
194
|
+
@if meta.type-of($n) == 'number' and math.unit($n) == 'gc' {
|
|
195
|
+
$cols: math.div($n, 1gc);
|
|
196
|
+
|
|
197
|
+
@return calc(
|
|
198
|
+
(math.div($cols, ml.$gs-columns) * 100%) -
|
|
199
|
+
ml.$gs-default-gtr * if($util == 'Ml', -1, 2)
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
@return null;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
@if ml.$legacy-grid-system {
|
|
207
|
+
ml.$general-cfg: map.set(
|
|
208
|
+
ml.$general-cfg, 'custom-unit-values', 'gc', meta.get-function('gc', false)
|
|
209
|
+
);
|
|
210
|
+
|
|
211
|
+
ml.$utils-db: map.deep-merge(
|
|
212
|
+
ml.$utils-db,
|
|
213
|
+
('utils': (
|
|
214
|
+
'registry': (
|
|
215
|
+
'W': (
|
|
216
|
+
'preset-properties': (
|
|
217
|
+
ml.$cv-pref + 'gsc': meta.get-function('-gc-prop'),
|
|
218
|
+
// space in key is needed to add the second fallback
|
|
219
|
+
' width': meta.get-function('-gc-fallback'),
|
|
220
|
+
)
|
|
221
|
+
),
|
|
222
|
+
'Ml': (
|
|
223
|
+
'preset-properties': (
|
|
224
|
+
ml.$cv-pref + 'gso': meta.get-function('-gc-prop'),
|
|
225
|
+
' margin-left': meta.get-function('-gc-fallback'),
|
|
226
|
+
)
|
|
227
|
+
)
|
|
228
|
+
)
|
|
229
|
+
))
|
|
230
|
+
);
|
|
231
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
@use 'sass:meta';
|
|
2
|
+
@use 'sass:map';
|
|
3
|
+
@use 'sass:math';
|
|
4
|
+
@use 'sass:string';
|
|
5
|
+
@use 'sass:list';
|
|
6
|
+
|
|
7
|
+
@use '../base' as ml;
|
|
8
|
+
|
|
9
|
+
// Helpers
|
|
10
|
+
//
|
|
11
|
+
// Basically, here are functions for internal needs. Perhaps the documentation will appear later.
|
|
12
|
+
//
|
|
13
|
+
/// Styleguide: sass-tools.functions.common.helpers
|
|
14
|
+
|
|
15
|
+
@function css-class($name, $only-name: false) {
|
|
16
|
+
$name: $name + '';
|
|
17
|
+
|
|
18
|
+
@if $only-name {
|
|
19
|
+
@return if(string.slice($name, 1, 1) == '.', string.slice($name, 2), $name);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@return if(string.slice($name, 1, 1) == '.', $name, '.' + $name);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@function replace-keyword($list, $keyword, $replacement) {
|
|
26
|
+
@each $item in $list {
|
|
27
|
+
$keyword-pos: string.index($item, $keyword);
|
|
28
|
+
|
|
29
|
+
@if $keyword-pos {
|
|
30
|
+
$list: ml.remove-nth($list, list.index($list, $item));
|
|
31
|
+
|
|
32
|
+
@each $rep-item in $replacement {
|
|
33
|
+
$item-with-kw: ml.str-replace($item, $keyword, $rep-item);
|
|
34
|
+
|
|
35
|
+
@if $item-with-kw != '' {
|
|
36
|
+
$list: list.append($list, $item-with-kw);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@return $list;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@function is-css-var($value, $in-color: false) {
|
|
46
|
+
@return (
|
|
47
|
+
ml.str-starts($value, 'var(') or
|
|
48
|
+
(
|
|
49
|
+
$in-color and (
|
|
50
|
+
ml.str-starts($value, 'rgba(var(') or
|
|
51
|
+
ml.str-starts($value, 'rgb(var(') or
|
|
52
|
+
ml.str-starts($value, 'hsla(var(') or
|
|
53
|
+
ml.str-starts($value, 'hsl(var(')
|
|
54
|
+
)
|
|
55
|
+
)
|
|
56
|
+
);
|
|
57
|
+
}
|