Force color-mode to prepend selectors instead of append

This commit is contained in:
Chris Qiang 2023-09-16 20:10:38 +07:00
parent 9e5e22ad6a
commit 6a05144d04
No known key found for this signature in database
GPG Key ID: DA360F9EF7543FCC
2 changed files with 26 additions and 1 deletions

View File

@ -13,7 +13,8 @@
} }
} }
} @else { } @else {
[data-bs-theme="#{$mode}"] { $parent-selector: &;
@at-root [data-bs-theme="#{$mode}"] #{$parent-selector} {
@content; @content;
} }
} }

View File

@ -30,6 +30,30 @@
} }
} }
} }
@include assert() {
@include output() {
.parent {
@include color-mode(dark) {
.element {
color: var(--bs-primary-text-emphasis);
background-color: var(--bs-primary-bg-subtle);
}
}
@include color-mode(dark, true) {
--custom-color: #{mix($indigo, $blue, 50%)};
}
}
}
@include expect() {
[data-bs-theme=dark] .parent .element {
color: var(--bs-primary-text-emphasis);
background-color: var(--bs-primary-bg-subtle);
}
[data-bs-theme=dark] .parent {
--custom-color: #3a3ff8;
}
}
}
} }
} }