Skip to content

Commit d8ccba7

Browse files
committed
feat: allow to generate CSS Variables without callbacks
1 parent 6a7f883 commit d8ccba7

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

scss/mixins/_utilities.scss

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
$properties: append((), $properties);
1717
}
1818

19+
// Use class prefix if present
20+
$property-class-prefix: if(map-has-key($utility, prefix), map-get($utility, prefix), null);
21+
$property-class-prefix: if($property-class-prefix == null, "", $property-class-prefix);
22+
1923
// Use custom class if present
2024
$property-class: if(map-has-key($utility, class), map-get($utility, class), nth($properties, 1));
2125
$property-class: if($property-class == null, "", $property-class);
@@ -29,8 +33,11 @@
2933
$property-class-modifier: if($key, if($property-class == "" and $infix == "", "", "-") + $key, "");
3034

3135
// Generate also CSS Variable
32-
$generate-vars: if(map-has-key($utility, vars), map-get($utility, vars), "false");
33-
$generate-rtl: if(map-has-key($utility, rtl), map-get($utility, rtl), "false");
36+
$generate-vars: if(map-has-key($utility, vars), map-get($utility, vars), false);
37+
$generate-only-vars: if(map-has-key($utility, only-vars), map-get($utility, only-vars), false);
38+
39+
// Generate RTL version
40+
$generate-rtl: if(map-has-key($utility, rtl), map-get($utility, rtl), false);
3441

3542
@if map-get($utility, rfs) {
3643
// Inside the media query
@@ -51,10 +58,15 @@
5158
@if $is-rtl == false {
5259
/* rtl:begin:remove */
5360
}
54-
.#{$property-class + $infix + $property-class-modifier} {
61+
.#{$property-class-prefix + $property-class + $infix + $property-class-modifier} {
5562
@each $property in $properties {
56-
@if $generate-vars == true {
57-
#{$property}: var(--#{$variable-prefix}#{$key}, $value) if($enable-important-utilities, !important, null);
63+
@if $generate-vars == true or $generate-only-vars == true {
64+
@if $generate-only-vars {
65+
#{$property}: var(--#{$variable-prefix}#{$key}) if($enable-important-utilities, !important, null);
66+
}
67+
@else {
68+
#{$property}: var(--#{$variable-prefix}#{$key}, $value) if($enable-important-utilities, !important, null);
69+
}
5870
}
5971
@else {
6072
@if $generate-rtl == true {

0 commit comments

Comments
 (0)