mirror of
https://github.com/twbs/bootstrap.git
synced 2025-01-18 10:52:19 +01:00
Add RFS to utility API (#30050)
This commit is contained in:
parent
22062ed9d7
commit
1d8a3a9597
2
scss/bootstrap-grid.scss
vendored
2
scss/bootstrap-grid.scss
vendored
@ -23,6 +23,8 @@ html {
|
|||||||
@import "mixins/grid";
|
@import "mixins/grid";
|
||||||
@import "mixins/utilities";
|
@import "mixins/utilities";
|
||||||
|
|
||||||
|
@import "vendor/rfs";
|
||||||
|
|
||||||
@import "containers";
|
@import "containers";
|
||||||
@import "grid";
|
@import "grid";
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// Utility generator
|
// Utility generator
|
||||||
// Used to generate utilities & print utilities
|
// Used to generate utilities & print utilities
|
||||||
@mixin generate-utility($utility, $infix) {
|
@mixin generate-utility($utility, $infix, $is-rfs-media-query: false) {
|
||||||
$values: map-get($utility, values);
|
$values: map-get($utility, values);
|
||||||
|
|
||||||
// If the values are a list or string, convert it into a map
|
// If the values are a list or string, convert it into a map
|
||||||
@ -25,10 +25,24 @@
|
|||||||
// Don't prefix if value key is null (eg. with shadow class)
|
// Don't prefix if value key is null (eg. with shadow class)
|
||||||
$property-class-modifier: if($key, if($property-class == "" and $infix == "", "", "-") + $key, "");
|
$property-class-modifier: if($key, if($property-class == "" and $infix == "", "", "-") + $key, "");
|
||||||
|
|
||||||
.#{$property-class + $infix + $property-class-modifier} {
|
@if map-get($utility, rfs) {
|
||||||
@each $property in $properties {
|
// Inside the media query
|
||||||
// stylelint-disable-next-line declaration-no-important
|
@if $is-rfs-media-query {
|
||||||
#{$property}: $value if($enable-important-utilities, !important, null);
|
$val: rfs-value($value);
|
||||||
|
|
||||||
|
// Do not render anything if fluid and non fluid values are the same
|
||||||
|
$value: if($val == rfs-fluid-value($value), null, $val);
|
||||||
|
}
|
||||||
|
@else {
|
||||||
|
$value: rfs-fluid-value($value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@if $value != null {
|
||||||
|
.#{$property-class + $infix + $property-class-modifier} {
|
||||||
|
@each $property in $properties {
|
||||||
|
#{$property}: $value if($enable-important-utilities, !important, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,24 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RFS rescaling
|
||||||
|
@media (min-width: $rfs-mq-value) {
|
||||||
|
@each $breakpoint in map-keys($grid-breakpoints) {
|
||||||
|
$infix: breakpoint-infix($breakpoint, $grid-breakpoints);
|
||||||
|
|
||||||
|
@if (map-get($grid-breakpoints, $breakpoint) < $rfs-breakpoint) {
|
||||||
|
// Loop over each utility property
|
||||||
|
@each $key, $utility in $utilities {
|
||||||
|
// The utility can be disabled with `false`, thus check if the utility is a map first
|
||||||
|
// Only proceed if responsive media queries are enabled or if it's the base media query
|
||||||
|
@if type-of($utility) == "map" and map-get($utility, rfs) {
|
||||||
|
@include generate-utility($utility, $infix, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Print utilities
|
// Print utilities
|
||||||
@media print {
|
@media print {
|
||||||
|
@ -13,6 +13,7 @@ The `$utilities` map contains all utilities and is later merged with your custom
|
|||||||
|
|
||||||
- `property`: Name of the property, this can be a string or an array of strings (needed for eg. horizontal paddings or margins).
|
- `property`: Name of the property, this can be a string or an array of strings (needed for eg. horizontal paddings or margins).
|
||||||
- `responsive` _(optional)_: Boolean indicating if responsive classes need to be generated. `false` by default.
|
- `responsive` _(optional)_: Boolean indicating if responsive classes need to be generated. `false` by default.
|
||||||
|
- `rfs` _(optional)_: Variable to enable fluid rescaling. Have a look at the [RFS]({{< docsref "/getting-started/rfs" >}}) page to find out how this works. `false` by default.
|
||||||
- `class` _(optional)_: Variable to change the class name if you don't want it to be the same as the property. In case you don't provide the `class` key and `property` key is an array of strings, the class name will be the first element of the `property` array.
|
- `class` _(optional)_: Variable to change the class name if you don't want it to be the same as the property. In case you don't provide the `class` key and `property` key is an array of strings, the class name will be the first element of the `property` array.
|
||||||
- `values`: This can be a list of values or a map if you don't want the class name to be the same as the value. If null is used as map key, it isn't rendered.
|
- `values`: This can be a list of values or a map if you don't want the class name to be the same as the value. If null is used as map key, it isn't rendered.
|
||||||
- `print` _(optional)_: Boolean indicating if print classes need to be generated. `false` by default.
|
- `print` _(optional)_: Boolean indicating if print classes need to be generated. `false` by default.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user