This repository has been archived on 2024-07-11. You can view files and clone it, but cannot push or open issues or pull requests.
redemption/source/css/base/_variables.scss

43 lines
847 B
SCSS

// 自动 浅色、暗色 模式
// 默认跟随系统自动开启
$darkmode: true !default; // true | false | 'manual'
$manualmode-auto-selector: '[data-darkmode="auto"] &' !default;
$manualmode-dark-selector: '[data-darkmode="dark"] &' !default;
@mixin darkmode($darkmode: $darkmode, $dark-selector: $manualmode-dark-selector, $auto-selector: $manualmode-auto-selector) {
// darkmode = ture : 跟随系统
// darkmode = false : 不跟随系统
// darkmode = manual : 手动模式
@if $darkmode=='manual' {
#{$dark-selector} {
@content;
}
@media (prefers-color-scheme: dark) {
#{$auto-selector} {
@content;
}
}
}
@else if $darkmode {
@media (prefers-color-scheme: dark) {
@content;
}
}
}