SASS实现PC黑暗模式

994 阅读1分钟

前言

使用场景:黑暗模式、换肤

为什么选择sass:

  • 对开发人员友好
  • 可扩展

使用

步骤一:制作主题

编写样式

$common: (
// 普通模式样式
),
$dark: (
// 黑暗模式样式            
)

步骤二:编写mixin

申明函数

@mixin themeMake($component) {
    .theme-normal .#{$component} {
        @content($normal);
    }

    .theme-dark .#{$component} {
        @content($dark);
    }
}

@mixin、@include:www.runoob.com/sass/sass-m…

步骤三:样式表中使用

使用函数

@include themeMake(yourStyle) using ($theme) {
    color: map-deep-get($theme, "common", "note-font");
}