2019-05-23 05:56:03 -04:00
|
|
|
// Utility generator
|
|
|
|
// Used to generate utilities & print utilities
|
|
|
|
@mixin generate-utility($utility, $infix) {
|
|
|
|
$values: map-get($utility, values);
|
|
|
|
|
|
|
|
// If the values are a list or string, convert it into a map
|
|
|
|
@if type-of($values) == "string" or type-of(nth($values, 1)) != "list" {
|
|
|
|
$values: zip($values, $values);
|
|
|
|
}
|
|
|
|
|
2019-05-30 11:22:06 -04:00
|
|
|
@each $key, $value in $values {
|
2019-05-23 05:56:03 -04:00
|
|
|
$properties: map-get($utility, property);
|
|
|
|
|
|
|
|
// Multiple properties are possible, for example with vertical or horizontal margins or paddings
|
|
|
|
@if type-of($properties) == "string" {
|
|
|
|
$properties: append((), $properties);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Use custom class if present
|
2019-08-17 14:19:00 -04:00
|
|
|
$property-class: if(map-has-key($utility, class), map-get($utility, class), nth($properties, 1));
|
|
|
|
$property-class: if($property-class == null, "", $property-class);
|
|
|
|
|
|
|
|
$infix: if($property-class == "" and str-slice($infix, 1, 1) == "-", str-slice($infix, 2), $infix);
|
2019-05-23 05:56:03 -04:00
|
|
|
|
|
|
|
// Don't prefix if value key is null (eg. with shadow class)
|
2019-08-17 14:19:00 -04:00
|
|
|
$property-class-modifier: if($key, if($property-class == "" and $infix == "", "", "-") + $key, "");
|
2019-05-23 05:56:03 -04:00
|
|
|
|
|
|
|
.#{$property-class + $infix + $property-class-modifier} {
|
|
|
|
@each $property in $properties {
|
|
|
|
// stylelint-disable-next-line declaration-no-important
|
2020-02-10 09:05:07 -05:00
|
|
|
#{$property}: $value if($enable-important-utilities, !important, null);
|
2019-05-23 05:56:03 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|