0
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-02-22 19:54:22 +01:00

Update source Sass to use Sass map module for all map functions, save for custom map-loop() which we may need to remove

This commit is contained in:
Mark Otto 2025-02-19 22:14:58 -08:00
parent 97fba7154c
commit 0c46e484eb
17 changed files with 64 additions and 46 deletions

View File

@ -1,3 +1,4 @@
@use "sass:map";
@use "config" as *;
@use "variables" as *;
@use "mixins/border-radius" as *;
@ -61,7 +62,7 @@
// scss-docs-start alert-modifiers
// Generate contextual modifier classes for colorizing the alert
@each $state in map-keys($theme-colors) {
@each $state in map.keys($theme-colors) {
.alert-#{$state} {
--#{$prefix}alert-color: var(--#{$prefix}#{$state}-text-emphasis);
--#{$prefix}alert-bg: var(--#{$prefix}#{$state}-bg-subtle);

View File

@ -1,3 +1,4 @@
@use "sass:map";
@use "config" as *;
@use "variables" as *;
@use "mixins/caret" as *;
@ -95,7 +96,7 @@
// We deliberately hardcode the `bs-` prefix because we check
// this custom property in JS to determine Popper's positioning
@each $breakpoint in map-keys($grid-breakpoints) {
@each $breakpoint in map.keys($grid-breakpoints) {
@include media-breakpoint-up($breakpoint) {
$infix: breakpoint-infix($breakpoint, $grid-breakpoints);

View File

@ -1,3 +1,4 @@
@use "sass:map";
@use "config" as *;
@use "colors" as *;
@use "variables" as *;
@ -126,7 +127,7 @@
//
// Change the layout of list group items from vertical (default) to horizontal.
@each $breakpoint in map-keys($grid-breakpoints) {
@each $breakpoint in map.keys($grid-breakpoints) {
@include media-breakpoint-up($breakpoint) {
$infix: breakpoint-infix($breakpoint, $grid-breakpoints);
@ -187,7 +188,7 @@
// Add modifier classes to change text and background color on individual items.
// Organizationally, this must come after the `:hover` states.
@each $state in map-keys($theme-colors) {
@each $state in map.keys($theme-colors) {
.list-group-item-#{$state} {
--#{$prefix}list-group-color: var(--#{$prefix}#{$state}-text-emphasis);
--#{$prefix}list-group-bg: var(--#{$prefix}#{$state}-bg-subtle);

View File

@ -1,3 +1,4 @@
@use "sass:map";
@use "config" as *;
@use "colors" as *;
@use "functions" as *;
@ -105,7 +106,7 @@ $utilities-colors: $theme-colors-rgb !default;
// scss-docs-end utilities-colors
// scss-docs-start utilities-text-colors
$utilities-text: map-merge(
$utilities-text: map.merge(
$utilities-colors,
(
"black": to-rgb($black),
@ -128,7 +129,7 @@ $utilities-text-emphasis-colors: (
// scss-docs-end utilities-text-colors
// scss-docs-start utilities-bg-colors
$utilities-bg: map-merge(
$utilities-bg: map.merge(
$utilities-colors,
(
"black": to-rgb($black),
@ -151,7 +152,7 @@ $utilities-bg-subtle: (
// scss-docs-end utilities-bg-colors
// scss-docs-start utilities-border-colors
$utilities-border: map-merge(
$utilities-border: map.merge(
$utilities-colors,
(
"black": to-rgb($black),

View File

@ -1,3 +1,4 @@
@use "sass:map";
@use "config" as *;
@use "variables" as *;
@use "mixins/border-radius" as *;
@ -215,7 +216,7 @@
}
// scss-docs-start modal-fullscreen-loop
@each $breakpoint in map-keys($grid-breakpoints) {
@each $breakpoint in map.keys($grid-breakpoints) {
$infix: breakpoint-infix($breakpoint, $grid-breakpoints);
$postfix: if($infix != "", $infix + "-down", "");

View File

@ -1,3 +1,4 @@
@use "sass:map";
@use "config" as *;
@use "variables" as *;
@use "mixins/border-radius" as *;
@ -201,7 +202,7 @@
// Generate series of `.navbar-expand-*` responsive classes for configuring
// where your navbar collapses.
.navbar-expand {
@each $breakpoint in map-keys($grid-breakpoints) {
@each $breakpoint in map.keys($grid-breakpoints) {
$next: breakpoint-next($breakpoint, $grid-breakpoints);
$infix: breakpoint-infix($next, $grid-breakpoints);

View File

@ -1,3 +1,4 @@
@use "sass:map";
@use "config" as *;
@use "variables" as *;
@use "mixins/box-shadow" as *;
@ -24,7 +25,7 @@
// scss-docs-end offcanvas-css-vars
}
@each $breakpoint in map-keys($grid-breakpoints) {
@each $breakpoint in map.keys($grid-breakpoints) {
$next: breakpoint-next($breakpoint, $grid-breakpoints);
$infix: breakpoint-infix($next, $grid-breakpoints);
@ -33,7 +34,7 @@
}
}
@each $breakpoint in map-keys($grid-breakpoints) {
@each $breakpoint in map.keys($grid-breakpoints) {
$next: breakpoint-next($breakpoint, $grid-breakpoints);
$infix: breakpoint-infix($next, $grid-breakpoints);

View File

@ -1,3 +1,4 @@
@use "sass:map";
@use "config" as *;
@use "colors" as *;
@use "variables" as *;
@ -190,7 +191,7 @@
// Generate series of `.table-responsive-*` classes for configuring the screen
// size of where your table will overflow.
@each $breakpoint in map-keys($grid-breakpoints) {
@each $breakpoint in map.keys($grid-breakpoints) {
$infix: breakpoint-infix($breakpoint, $grid-breakpoints);
@include media-breakpoint-down($breakpoint) {

View File

@ -1,3 +1,4 @@
@use "sass:map";
@use "config" as *;
@use "colors" as *;
@use "variables" as *;
@ -8,7 +9,7 @@
$utilities: () !default;
// stylelint-disable-next-line scss/dollar-variable-default
$utilities: map-merge(
$utilities: map.merge(
(
// scss-docs-start utils-vertical-align
"align": (
@ -366,43 +367,43 @@ $utilities: map-merge(
responsive: true,
property: margin,
class: m,
values: map-merge($spacers, (auto: auto))
values: map.merge($spacers, (auto: auto))
),
"margin-x": (
responsive: true,
property: margin-right margin-left,
class: mx,
values: map-merge($spacers, (auto: auto))
values: map.merge($spacers, (auto: auto))
),
"margin-y": (
responsive: true,
property: margin-top margin-bottom,
class: my,
values: map-merge($spacers, (auto: auto))
values: map.merge($spacers, (auto: auto))
),
"margin-top": (
responsive: true,
property: margin-top,
class: mt,
values: map-merge($spacers, (auto: auto))
values: map.merge($spacers, (auto: auto))
),
"margin-end": (
responsive: true,
property: margin-right,
class: me,
values: map-merge($spacers, (auto: auto))
values: map.merge($spacers, (auto: auto))
),
"margin-bottom": (
responsive: true,
property: margin-bottom,
class: mb,
values: map-merge($spacers, (auto: auto))
values: map.merge($spacers, (auto: auto))
),
"margin-start": (
responsive: true,
property: margin-left,
class: ms,
values: map-merge($spacers, (auto: auto))
values: map.merge($spacers, (auto: auto))
),
// Negative margin utilities
"negative-margin": (
@ -592,7 +593,7 @@ $utilities: map-merge(
local-vars: (
"text-opacity": 1
),
values: map-merge(
values: map.merge(
$utilities-text-colors,
(
"muted": var(--#{$prefix}secondary-color), // deprecated
@ -650,7 +651,7 @@ $utilities: map-merge(
local-vars: (
"link-underline-opacity": 1
),
values: map-merge(
values: map.merge(
$utilities-links-underline,
(
null: rgba(var(--#{$prefix}link-color-rgb), var(--#{$prefix}link-underline-opacity, 1)),
@ -678,7 +679,7 @@ $utilities: map-merge(
local-vars: (
"bg-opacity": 1
),
values: map-merge(
values: map.merge(
$utilities-bg-colors,
(
"transparent": transparent,

View File

@ -2,6 +2,7 @@
@use "../variables" as *;
@use "../mixins/border-radius" as *;
@use "../mixins/transition" as *;
.form-floating {
position: relative;

View File

@ -1,3 +1,4 @@
@use "sass:map";
@use "../config" as *;
@use "../variables" as *;
@use "../vendor/rfs" as *;
@ -121,7 +122,7 @@
}
$validation-messages: "";
@each $state in map-keys($form-validation-states) {
@each $state in map.keys($form-validation-states) {
$validation-messages: $validation-messages + ":not(." + unquote($state) + "-tooltip)" + ":not(." + unquote($state) + "-feedback)";
}

View File

@ -1,3 +1,4 @@
@use "sass:map";
@use "../config" as *;
@use "../variables" as *;
@use "../layout/breakpoints" as *;
@ -21,7 +22,7 @@
}
// Responsive sticky top and bottom
@each $breakpoint in map-keys($grid-breakpoints) {
@each $breakpoint in map.keys($grid-breakpoints) {
@include media-breakpoint-up($breakpoint) {
$infix: breakpoint-infix($breakpoint, $grid-breakpoints);

View File

@ -1,3 +1,4 @@
@use "sass:map";
@use "../config" as *;
@ -17,7 +18,7 @@
// md
// >> breakpoint-next(sm, $breakpoint-names: (xs sm md lg xl xxl))
// md
@function breakpoint-next($name, $breakpoints: $grid-breakpoints, $breakpoint-names: map-keys($breakpoints)) {
@function breakpoint-next($name, $breakpoints: $grid-breakpoints, $breakpoint-names: map.keys($breakpoints)) {
$n: index($breakpoint-names, $name);
@if not $n {
@error "breakpoint `#{$name}` not found in `#{$breakpoints}`";
@ -30,7 +31,7 @@
// >> breakpoint-min(sm, (xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px, xxl: 1400px))
// 576px
@function breakpoint-min($name, $breakpoints: $grid-breakpoints) {
$min: map-get($breakpoints, $name);
$min: map.get($breakpoints, $name);
@return if($min != 0, $min, null);
}
@ -44,7 +45,7 @@
// >> breakpoint-max(md, (xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px, xxl: 1400px))
// 767.98px
@function breakpoint-max($name, $breakpoints: $grid-breakpoints) {
$max: map-get($breakpoints, $name);
$max: map.get($breakpoints, $name);
@return if($max and $max > 0, $max - .02, null);
}

View File

@ -1,9 +1,10 @@
@use "sass:map";
@use "../config" as *;
// Utility generator
// Used to generate utilities & print utilities
@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 type-of($values) == "string" or type-of(nth($values, 1)) != "list" {
@ -11,7 +12,7 @@
}
@each $key, $value in $values {
$properties: map-get($utility, property);
$properties: map.get($utility, property);
// Multiple properties are possible, for example with vertical or horizontal margins or paddings
@if type-of($properties) == "string" {
@ -19,21 +20,21 @@
}
// Use custom class if present
$property-class: if(map-has-key($utility, class), map-get($utility, class), nth($properties, 1));
$property-class: if(map.has-key($utility, class), map.get($utility, class), nth($properties, 1));
$property-class: if($property-class == null, "", $property-class);
// Use custom CSS variable name if present, otherwise default to `class`
$css-variable-name: if(map-has-key($utility, css-variable-name), map-get($utility, css-variable-name), map-get($utility, class));
$css-variable-name: if(map.has-key($utility, css-variable-name), map.get($utility, css-variable-name), map.get($utility, class));
// State params to generate pseudo-classes
$state: if(map-has-key($utility, state), map-get($utility, state), ());
$state: if(map.has-key($utility, state), map.get($utility, state), ());
$infix: if($property-class == "" and str-slice($infix, 1, 1) == "-", str-slice($infix, 2), $infix);
// Don't prefix if value key is null (e.g. with shadow class)
$property-class-modifier: if($key, if($property-class == "" and $infix == "", "", "-") + $key, "");
@if map-get($utility, rfs) {
@if map.get($utility, rfs) {
// Inside the media query
@if $is-rfs-media-query {
$val: rfs-value($value);
@ -46,9 +47,9 @@
}
}
$is-css-var: map-get($utility, css-var);
$is-local-vars: map-get($utility, local-vars);
$is-rtl: map-get($utility, rtl);
$is-css-var: map.get($utility, css-var);
$is-local-vars: map.get($utility, local-vars);
$is-rtl: map.get($utility, rtl);
@if $value != null {
@if $is-rtl == false {

View File

@ -1,3 +1,4 @@
@use "sass:map";
@use "../config" as *;
@use "../variables" as *;
@use "../vendor/rfs" as *;
@ -6,7 +7,7 @@
@use "../utilities" as *;
// Loop over each breakpoint
@each $breakpoint in map-keys($grid-breakpoints) {
@each $breakpoint in map.keys($grid-breakpoints) {
// Generate media query if needed
@include media-breakpoint-up($breakpoint) {
@ -16,7 +17,7 @@
@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, responsive) or $infix == "") {
@if type-of($utility) == "map" and (map.get($utility, responsive) or $infix == "") {
@include generate-utility($utility, $infix);
}
}
@ -25,15 +26,15 @@
// RFS rescaling
@media (min-width: $rfs-mq-value) {
@each $breakpoint in map-keys($grid-breakpoints) {
@each $breakpoint in map.keys($grid-breakpoints) {
$infix: breakpoint-infix($breakpoint, $grid-breakpoints);
@if (map-get($grid-breakpoints, $breakpoint) < $rfs-breakpoint) {
@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) and (map-get($utility, responsive) or $infix == "") {
@if type-of($utility) == "map" and map.get($utility, rfs) and (map.get($utility, responsive) or $infix == "") {
@include generate-utility($utility, $infix, true);
}
}
@ -47,7 +48,7 @@
@each $key, $utility in $utilities {
// The utility can be disabled with `false`, thus check if the utility is a map first
// Then check if the utility needs print styles
@if type-of($utility) == "map" and map-get($utility, print) == true {
@if type-of($utility) == "map" and map.get($utility, print) == true {
@include generate-utility($utility, "-print");
}
}

View File

@ -1,3 +1,5 @@
@use "sass:map";
// stylelint-disable scss/dimension-no-non-numeric-values
// SCSS RFS mixin
@ -88,8 +90,8 @@ $rfs-base-value-unit: unit($rfs-base-value);
"em": 1em,
"%": 1%
);
@if ($dividend-unit != $divisor-unit and map-has-key($unit-map, $dividend-unit)) {
$result: $result * map-get($unit-map, $dividend-unit);
@if ($dividend-unit != $divisor-unit and map.has-key($unit-map, $dividend-unit)) {
$result: $result * map.get($unit-map, $dividend-unit);
}
@return $result;
}

View File

@ -1,3 +1,4 @@
@use "sass:map";
@use "../../../scss/config" as *;
@use "../../../scss/colors" as *;
@use "../../../scss/layout/breakpoints" as *;
@ -7,7 +8,7 @@
// Docs color palette classes
//
@each $color, $value in map-merge($colors, ("gray-500": $gray-500)) {
@each $color, $value in map.merge($colors, ("gray-500": $gray-500)) {
.swatch-#{$color} {
color: color-contrast($value);
background-color: #{$value};