Skip to content

Commit

Permalink
Fix Sass compilation when $color-mode-type is set to media-query (#…
Browse files Browse the repository at this point in the history
…37687)

* Fix Sass compilation when `$color-mode-type` is set to `media-query`

* Update mixin names, fix docs color modes for using media queries by using mixin

Co-authored-by: Mark Otto <markdotto@gmail.com>
  • Loading branch information
julien-deramond and mdo committed Dec 21, 2022
1 parent f6687e9 commit 41f62c5
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 14 deletions.
6 changes: 3 additions & 3 deletions scss/_carousel.scss
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@

// Dark mode carousel

%carousel-dark {
@mixin carousel-dark() {
.carousel-control-prev-icon,
.carousel-control-next-icon {
filter: $carousel-dark-control-icon-filter;
Expand All @@ -226,13 +226,13 @@
}

.carousel-dark {
@extend %carousel-dark;
@include carousel-dark();
}

@if $enable-dark-mode {
@include color-mode(dark) {
.carousel {
@extend %carousel-dark;
@include carousel-dark();
}
}
}
6 changes: 3 additions & 3 deletions scss/_close.scss
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,18 @@
}
}

%btn-close-white {
@mixin btn-close-white() {
filter: var(--#{$prefix}btn-close-white-filter);
}

.btn-close-white {
@extend %btn-close-white;
@include btn-close-white();
}

@if $enable-dark-mode {
@include color-mode(dark) {
.btn-close {
@extend %btn-close-white;
@include btn-close-white();
}
}
}
2 changes: 1 addition & 1 deletion scss/_root.scss
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
}

@if $enable-dark-mode {
@include color-mode(dark) {
@include color-mode(dark, true) {
// scss-docs-start root-dark-mode-vars
--#{$prefix}body-color: #{$body-color-dark};
--#{$prefix}body-color-rgb: #{to-rgb($body-color-dark)};
Expand Down
2 changes: 1 addition & 1 deletion scss/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ $enable-deprecation-messages: true !default;
$enable-important-utilities: true !default;

$enable-dark-mode: true !default;
$color-mode-type: data !default;
$color-mode-type: data !default; // `data` or `media-query`

// Prefix for :root CSS variables

Expand Down
16 changes: 12 additions & 4 deletions scss/mixins/_color-mode.scss
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
// scss-docs-start color-mode-mixin
@mixin color-mode($mode: light, $type: $color-mode-type) {
@if $type == "media-query" {
@media (prefers-color-scheme: $mode) {
@content;
@mixin color-mode($mode: light, $root: false) {
@if $color-mode-type == "media-query" {
@if $root == true {
@media (prefers-color-scheme: $mode) {
:root {
@content;
}
}
} @else {
@media (prefers-color-scheme: $mode) {
@content;
}
}
} @else {
[data-bs-theme="#{$mode}"] {
Expand Down
2 changes: 1 addition & 1 deletion site/assets/scss/_syntax.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
--base0F: #333;
}

[data-bs-theme="dark"] {
@include color-mode(dark, true) {
--base00: #282c34;
--base01: #353b45;
--base02: #3e4451;
Expand Down
2 changes: 1 addition & 1 deletion site/assets/scss/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ $bd-callout-variants: info, warning, danger !default;
--bd-sidebar-link-bg: rgba(var(--bd-violet-rgb), .1);
}

[data-bs-theme="dark"] {
@include color-mode(dark, true) {
--bd-violet: #{mix($bd-violet, $white, 75%)};
--bd-violet-bg: #{$bd-violet};
--bd-sidebar-link-bg: rgba(#{to-rgb(mix($bd-violet, $black, 75%))}, .5);
Expand Down

0 comments on commit 41f62c5

Please sign in to comment.