mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-31 09:05:47 +02:00
Helpers & utilities split (#28445)
This commit is contained in:
33
scss/mixins/_utilities.scss
Normal file
33
scss/mixins/_utilities.scss
Normal file
@@ -0,0 +1,33 @@
|
||||
// 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);
|
||||
}
|
||||
|
||||
@each $value in $values {
|
||||
$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
|
||||
$property-class: map-get($utility, class);
|
||||
$property-class: if($property-class, $property-class, nth($properties, 1));
|
||||
|
||||
// Don't prefix if value key is null (eg. with shadow class)
|
||||
$property-class-modifier: if(nth($value, 1), "-" + nth($value, 1), "");
|
||||
|
||||
.#{$property-class + $infix + $property-class-modifier} {
|
||||
@each $property in $properties {
|
||||
// stylelint-disable-next-line declaration-no-important
|
||||
#{$property}: #{nth($value, 2)} !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user