Skip to content

Commit 33847ab

Browse files
committed
refactor: replace type-of() with meta.typeof() and unquote() with string.unquote()
1 parent 18621e3 commit 33847ab

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

scss/utilities/_api.scss

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
@use "sass:meta";
12
@use "../variables" as *;
23
@use "../utilities" as *;
34
@use "../mixins/breakpoints" as *;
@@ -15,7 +16,7 @@
1516
@each $key, $utility in $utilities {
1617
// The utility can be disabled with `false`, thus check if the utility is a map first
1718
// Only proceed if responsive media queries are enabled or if it's the base media query
18-
@if type-of($utility) == "map" and (map-get($utility, responsive) or $infix == "") {
19+
@if meta.type-of($utility) == "map" and (map-get($utility, responsive) or $infix == "") {
1920
@include generate-utility($utility, $infix);
2021
}
2122
}
@@ -32,7 +33,7 @@
3233
@each $key, $utility in $utilities {
3334
// The utility can be disabled with `false`, thus check if the utility is a map first
3435
// Only proceed if responsive media queries are enabled or if it's the base media query
35-
@if type-of($utility) == "map" and map-get($utility, rfs) and (map-get($utility, responsive) or $infix == "") {
36+
@if meta.type-of($utility) == "map" and map-get($utility, rfs) and (map-get($utility, responsive) or $infix == "") {
3637
@include generate-utility($utility, $infix, true);
3738
}
3839
}
@@ -46,7 +47,7 @@
4647
@each $key, $utility in $utilities {
4748
// The utility can be disabled with `false`, thus check if the utility is a map first
4849
// Then check if the utility needs print styles
49-
@if type-of($utility) == "map" and map-get($utility, print) == true {
50+
@if meta.type-of($utility) == "map" and map-get($utility, print) == true {
5051
@include generate-utility($utility, "-print");
5152
}
5253
}

scss/vendor/_rfs.scss

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// stylelint-disable scss/dimension-no-non-numeric-values
22
@use "sass:math";
3+
@use "sass:meta";
4+
@use "sass:string";
35

46
// SCSS RFS mixin
57
//
@@ -31,7 +33,7 @@ $rfs-two-dimensional: false !default;
3133
// Factor of decrease
3234
$rfs-factor: 10 !default;
3335

34-
@if type-of($rfs-factor) != number or $rfs-factor <= 1 {
36+
@if meta.type-of($rfs-factor) != number or $rfs-factor <= 1 {
3537
@error "`#{$rfs-factor}` is not a valid $rfs-factor, it must be greater than 1.";
3638
}
3739

@@ -191,7 +193,7 @@ $rfs-mq-property-height: if($rfs-mode == max-media-query, max-height, min-height
191193
// Helper function to get the formatted non-responsive value
192194
@function rfs-value($values) {
193195
// Convert to list
194-
$values: if(type-of($values) != list, ($values,), $values);
196+
$values: if(meta.type-of($values) != list, ($values,), $values);
195197

196198
$val: "";
197199

@@ -202,7 +204,7 @@ $rfs-mq-property-height: if($rfs-mode == max-media-query, max-height, min-height
202204
}
203205
@else {
204206
// Cache $value unit
205-
$unit: if(type-of($value) == "number", math.unit($value), false);
207+
$unit: if(meta.type-of($value) == "number", math.unit($value), false);
206208

207209
@if $unit == px {
208210
// Convert to rem if needed
@@ -219,13 +221,13 @@ $rfs-mq-property-height: if($rfs-mode == max-media-query, max-height, min-height
219221
}
220222

221223
// Remove first space
222-
@return unquote(str-slice($val, 2));
224+
@return string.unquote(str-slice($val, 2));
223225
}
224226

225227
// Helper function to get the responsive value calculated by RFS
226228
@function rfs-fluid-value($values) {
227229
// Convert to list
228-
$values: if(type-of($values) != list, ($values,), $values);
230+
$values: if(meta.type-of($values) != list, ($values,), $values);
229231

230232
$val: "";
231233

@@ -235,7 +237,7 @@ $rfs-mq-property-height: if($rfs-mode == max-media-query, max-height, min-height
235237
$val: $val + " 0";
236238
} @else {
237239
// Cache $value unit
238-
$unit: if(type-of($value) == "number", math.unit($value), false);
240+
$unit: if(meta.type-of($value) == "number", math.unit($value), false);
239241

240242
// If $value isn't a number (like inherit) or $value has a unit (not px or rem, like 1.5em) or $ is 0, just print the value
241243
@if not $unit or $unit != px and $unit != rem {
@@ -275,7 +277,7 @@ $rfs-mq-property-height: if($rfs-mode == max-media-query, max-height, min-height
275277
}
276278

277279
// Remove first space
278-
@return unquote(str-slice($val, 2));
280+
@return string.unquote(str-slice($val, 2));
279281
}
280282

281283
// RFS mixin

0 commit comments

Comments
 (0)