theme-change.scss
799 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
$themes: (
theme-white: (
black: #000,
text: #314659,
border: #e8e8e8,
border-light: rgba(#e8e8e8, 0.2),
background: #fff,
),
theme-black: (
black: #fff,
text: #D8D9DA,
border: #343434,
border-light: rgba(#343434, 0.2),
background: #161719,
),
);
@mixin themify($themes: $themes) {
@each $theme-name, $map in $themes {
// & 表示父级元素
// !global 表示覆盖原来的
.#{$theme-name} & {
$theme-map: () !global;
// 循环合并键值对
@each $key, $value in $map {
$theme-map: map-merge($theme-map, ($key: $value)) !global;
}
// 表示包含 下面函数 themed()
@content;
$theme-map: null !global;
}
}
}
@function themed($key) {
@return map-get($theme-map, $key);
}