]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Add Sass variable for CSS variable prefix (#31684)
authorMark Otto <markd.otto@gmail.com>
Wed, 30 Sep 2020 05:32:58 +0000 (22:32 -0700)
committerGitHub <noreply@github.com>
Wed, 30 Sep 2020 05:32:58 +0000 (08:32 +0300)
* Add Sass variable for CSS variable prefix

* Update other --bs-* var instances

scss/_root.scss
scss/_tables.scss
scss/_utilities.scss
scss/_variables.scss
scss/forms/_form-check.scss
scss/forms/_form-file.scss
scss/mixins/_gradients.scss
scss/mixins/_grid.scss
scss/mixins/_table-variants.scss

index 44eff1700687044663912cee17c6ad564a801603..768d6343f8c4119ce87c195fcb8ebbd0a0af0598 100644 (file)
@@ -1,16 +1,16 @@
 :root {
   // Custom variable values only support SassScript inside `#{}`.
   @each $color, $value in $colors {
-    --bs-#{$color}: #{$value};
+    --#{$variable-prefix}#{$color}: #{$value};
   }
 
   @each $color, $value in $theme-colors {
-    --bs-#{$color}: #{$value};
+    --#{$variable-prefix}#{$color}: #{$value};
   }
 
   // Use `inspect` for lists so that quoted items keep the quotes.
   // See https://github.com/sass/sass/issues/2383#issuecomment-336349172
-  --bs-font-sans-serif: #{inspect($font-family-sans-serif)};
-  --bs-font-monospace: #{inspect($font-family-monospace)};
-  --bs-gradient: #{$gradient};
+  --#{$variable-prefix}font-sans-serif: #{inspect($font-family-sans-serif)};
+  --#{$variable-prefix}font-monospace: #{inspect($font-family-monospace)};
+  --#{$variable-prefix}gradient: #{$gradient};
 }
index 47ffde1663015fb81aef8063d66a98272b665445..1b2db3008b9124c08fc63798f61493e4b4052601 100644 (file)
@@ -3,14 +3,14 @@
 //
 
 .table {
-  --bs-table-bg: #{$table-bg};
-  --bs-table-accent-bg: transparent;
-  --bs-table-striped-color: #{$table-striped-color};
-  --bs-table-striped-bg: #{$table-striped-bg};
-  --bs-table-active-color: #{$table-active-color};
-  --bs-table-active-bg: #{$table-active-bg};
-  --bs-table-hover-color: #{$table-hover-color};
-  --bs-table-hover-bg: #{$table-hover-bg};
+  --#{$variable-prefix}table-bg: #{$table-bg};
+  --#{$variable-prefix}table-accent-bg: transparent;
+  --#{$variable-prefix}table-striped-color: #{$table-striped-color};
+  --#{$variable-prefix}table-striped-bg: #{$table-striped-bg};
+  --#{$variable-prefix}table-active-color: #{$table-active-color};
+  --#{$variable-prefix}table-active-bg: #{$table-active-bg};
+  --#{$variable-prefix}table-hover-color: #{$table-hover-color};
+  --#{$variable-prefix}table-hover-bg: #{$table-hover-bg};
 
   width: 100%;
   margin-bottom: $spacer;
@@ -25,8 +25,8 @@
   // stylelint-disable-next-line selector-max-universal
   > :not(caption) > * > * {
     padding: $table-cell-padding-y $table-cell-padding-x;
-    background-color: var(--bs-table-bg);
-    background-image: linear-gradient(var(--bs-table-accent-bg), var(--bs-table-accent-bg));
+    background-color: var(--#{$variable-prefix}table-bg);
+    background-image: linear-gradient(var(--#{$variable-prefix}table-accent-bg), var(--#{$variable-prefix}table-accent-bg));
     border-bottom-width: $table-border-width;
   }
 
@@ -99,8 +99,8 @@
 
 .table-striped {
   > tbody > tr:nth-of-type(#{$table-striped-order}) {
-    --bs-table-accent-bg: var(--bs-table-striped-bg);
-    color: var(--bs-table-striped-color);
+    --#{$variable-prefix}table-accent-bg: var(--#{$variable-prefix}table-striped-bg);
+    color: var(--#{$variable-prefix}table-striped-color);
   }
 }
 
 // The `.table-active` class can be added to highlight rows or cells
 
 .table-active {
-  --bs-table-accent-bg: var(--bs-table-active-bg);
-  color: var(--bs-table-active-color);
+  --#{$variable-prefix}table-accent-bg: var(--#{$variable-prefix}table-active-bg);
+  color: var(--#{$variable-prefix}table-active-color);
 }
 
 // Hover effect
 
 .table-hover {
   > tbody > tr:hover {
-    --bs-table-accent-bg: var(--bs-table-hover-bg);
-    color: var(--bs-table-hover-color);
+    --#{$variable-prefix}table-accent-bg: var(--#{$variable-prefix}table-hover-bg);
+    color: var(--#{$variable-prefix}table-hover-color);
   }
 }
 
index e9a9b1e33b157daa644e1702fc32342f8687add9..565c466c2fa2dede90a516b897aa0ebb54467b51 100644 (file)
@@ -448,7 +448,7 @@ $utilities: map-merge(
     "gradient": (
       property: background-image,
       class: bg,
-      values: (gradient: var(--bs-gradient))
+      values: (gradient: var(--#{$variable-prefix}gradient))
     ),
     "white-space": (
       property: white-space,
@@ -475,7 +475,7 @@ $utilities: map-merge(
     "font-family": (
       property: font-family,
       class: font,
-      values: (monospace: var(--bs-font-monospace))
+      values: (monospace: var(--#{$variable-prefix}font-monospace))
     ),
     "user-select": (
       property: user-select,
index 707302adf208e6923df07d8637f7e97b37d00267..3941bab0fbcbc6a10409e2b2fba63d652a05d079 100644 (file)
@@ -222,6 +222,10 @@ $enable-negative-margins:     false !default;
 $enable-deprecation-messages: true !default;
 $enable-important-utilities:  true !default;
 
+// Prefix for :root CSS variables
+
+$variable-prefix:             bs- !default;
+
 // Gradient
 //
 // The gradient which is added to components if `$enable-gradients` is `true`
@@ -395,8 +399,8 @@ $aspect-ratios: (
 $font-family-sans-serif:      system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji" !default;
 $font-family-monospace:       SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace !default;
 // stylelint-enable value-keyword-case
-$font-family-base:            var(--bs-font-sans-serif) !default;
-$font-family-code:            var(--bs-font-monospace) !default;
+$font-family-base:            var(--#{$variable-prefix}font-sans-serif) !default;
+$font-family-code:            var(--#{$variable-prefix}font-monospace) !default;
 
 // $font-size-root effects the value of `rem`, which is used for as well font sizes, paddings and margins
 // $font-size-base effects the font size of the body text
index 16a27246ac5a987153c9af53714ecdccce04749b..77af825f5f14569f6d103ae889d502600f76c112 100644 (file)
@@ -53,7 +53,7 @@
 
     &[type="checkbox"] {
       @if $enable-gradients {
-        background-image: escape-svg($form-check-input-checked-bg-image), var(--bs-gradient);
+        background-image: escape-svg($form-check-input-checked-bg-image), var(--#{$variable-prefix}gradient);
       } @else {
         background-image: escape-svg($form-check-input-checked-bg-image);
       }
@@ -61,7 +61,7 @@
 
     &[type="radio"] {
       @if $enable-gradients {
-        background-image: escape-svg($form-check-radio-checked-bg-image), var(--bs-gradient);
+        background-image: escape-svg($form-check-radio-checked-bg-image), var(--#{$variable-prefix}gradient);
       } @else {
         background-image: escape-svg($form-check-radio-checked-bg-image);
       }
@@ -73,7 +73,7 @@
     border-color: $form-check-input-indeterminate-border-color;
 
     @if $enable-gradients {
-      background-image: escape-svg($form-check-input-indeterminate-bg-image), var(--bs-gradient);
+      background-image: escape-svg($form-check-input-indeterminate-bg-image), var(--#{$variable-prefix}gradient);
     } @else {
       background-image: escape-svg($form-check-input-indeterminate-bg-image);
     }
       background-position: $form-switch-checked-bg-position;
 
       @if $enable-gradients {
-        background-image: escape-svg($form-switch-checked-bg-image), var(--bs-gradient);
+        background-image: escape-svg($form-switch-checked-bg-image), var(--#{$variable-prefix}gradient);
       } @else {
         background-image: escape-svg($form-switch-checked-bg-image);
       }
index 5bc4afc69534e122c88a04dd77929add29150c49..228d9adf39ed4fb308f62d19ce84943a25fee70c 100644 (file)
@@ -1,5 +1,5 @@
 .form-file {
-  --bs-form-file-height: #{$form-file-height};
+  --#{$variable-prefix}form-file-height: #{$form-file-height};
   position: relative;
 }
 
@@ -7,7 +7,7 @@
   position: relative;
   z-index: 2;
   width: 100%;
-  height: var(--bs-form-file-height);
+  height: var(--#{$variable-prefix}form-file-height);
   margin: 0;
   opacity: 0;
 
@@ -32,7 +32,7 @@
   left: 0;
   z-index: 1;
   display: flex;
-  height: var(--bs-form-file-height);
+  height: var(--#{$variable-prefix}form-file-height);
   border-color: $form-file-border-color;
   @include border-radius($form-file-border-radius);
   @include box-shadow($form-file-box-shadow);
@@ -71,7 +71,7 @@
 }
 
 .form-file-sm {
-  --bs-form-file-height: #{$form-file-height-sm};
+  --#{$variable-prefix}form-file-height: #{$form-file-height-sm};
   @include font-size($form-file-font-size-sm);
 
   .form-file-text,
@@ -81,7 +81,7 @@
 }
 
 .form-file-lg {
-  --bs-form-file-height: #{$form-file-height-lg};
+  --#{$variable-prefix}form-file-height: #{$form-file-height-lg};
   @include font-size($form-file-font-size-lg);
 
   .form-file-text,
index 8b87c0f15e2b99860380bbb4a003fa8812805ec3..ec38ca1417ff72e3a39ce8597f6be2c238ad5edf 100644 (file)
@@ -4,7 +4,7 @@
   background-color: $color;
 
   @if $enable-gradients {
-    background-image: var(--bs-gradient);
+    background-image: var(--#{$variable-prefix}gradient);
   }
 }
 
index a229199dd32fff0b68f02b89bee77d94b50ba778..92bb88ad49447c913b872e4ae95a161592f84b26 100644 (file)
@@ -3,13 +3,13 @@
 // Generate semantic grid columns with these mixins.
 
 @mixin make-row($gutter: $grid-gutter-width) {
-  --bs-gutter-x: #{$gutter};
-  --bs-gutter-y: 0;
+  --#{$variable-prefix}gutter-x: #{$gutter};
+  --#{$variable-prefix}gutter-y: 0;
   display: flex;
   flex-wrap: wrap;
-  margin-top: calc(var(--bs-gutter-y) * -1); // stylelint-disable-line function-disallowed-list
-  margin-right: calc(var(--bs-gutter-x) / -2); // stylelint-disable-line function-disallowed-list
-  margin-left: calc(var(--bs-gutter-x) / -2); // stylelint-disable-line function-disallowed-list
+  margin-top: calc(var(--#{$variable-prefix}gutter-y) * -1); // stylelint-disable-line function-disallowed-list
+  margin-right: calc(var(--#{$variable-prefix}gutter-x) / -2); // stylelint-disable-line function-disallowed-list
+  margin-left: calc(var(--#{$variable-prefix}gutter-x) / -2); // stylelint-disable-line function-disallowed-list
 }
 
 @mixin make-col-ready($gutter: $grid-gutter-width) {
@@ -21,9 +21,9 @@
   flex-shrink: 0;
   width: 100%;
   max-width: 100%; // Prevent `.col-auto`, `.col` (& responsive variants) from breaking out the grid
-  padding-right: calc(var(--bs-gutter-x) / 2); // stylelint-disable-line function-disallowed-list
-  padding-left: calc(var(--bs-gutter-x) / 2); // stylelint-disable-line function-disallowed-list
-  margin-top: var(--bs-gutter-y);
+  padding-right: calc(var(--#{$variable-prefix}gutter-x) / 2); // stylelint-disable-line function-disallowed-list
+  padding-left: calc(var(--#{$variable-prefix}gutter-x) / 2); // stylelint-disable-line function-disallowed-list
+  margin-top: var(--#{$variable-prefix}gutter-y);
 }
 
 @mixin make-col($size, $columns: $grid-columns) {
       @each $key, $value in $gutters {
         .g#{$infix}-#{$key},
         .gx#{$infix}-#{$key} {
-          --bs-gutter-x: #{$value};
+          --#{$variable-prefix}gutter-x: #{$value};
         }
 
         .g#{$infix}-#{$key},
         .gy#{$infix}-#{$key} {
-          --bs-gutter-y: #{$value};
+          --#{$variable-prefix}gutter-y: #{$value};
         }
       }
     }
index 89f482c3537be11a04447f72668b5ffcf4539f1b..9fd0fb02a42c4ea47054c40a9ab1312138780bc9 100644 (file)
@@ -6,13 +6,13 @@
     $striped-bg: mix($color, $background, percentage($table-striped-bg-factor));
     $active-bg: mix($color, $background, percentage($table-active-bg-factor));
 
-    --bs-table-bg: #{$background};
-    --bs-table-striped-bg: #{$striped-bg};
-    --bs-table-striped-color: #{color-contrast($striped-bg)};
-    --bs-table-active-bg: #{$active-bg};
-    --bs-table-active-color: #{color-contrast($active-bg)};
-    --bs-table-hover-bg: #{$hover-bg};
-    --bs-table-hover-color: #{color-contrast($hover-bg)};
+    --#{$variable-prefix}table-bg: #{$background};
+    --#{$variable-prefix}table-striped-bg: #{$striped-bg};
+    --#{$variable-prefix}table-striped-color: #{color-contrast($striped-bg)};
+    --#{$variable-prefix}table-active-bg: #{$active-bg};
+    --#{$variable-prefix}table-active-color: #{color-contrast($active-bg)};
+    --#{$variable-prefix}table-hover-bg: #{$hover-bg};
+    --#{$variable-prefix}table-hover-color: #{color-contrast($hover-bg)};
 
     color: $color;
     border-color: mix($color, $background, percentage($table-border-factor));