handle.scss 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. @import "./themes.scss";
  2. //切换主题时 获取不同的主题色值
  3. @mixin themeify {
  4. @each $theme-name,
  5. $theme-map in $themes {
  6. //!global 把局部变量强升为全局变量
  7. $theme-map: $theme-map !global;
  8. //判断html的data-theme的属性值 #{}是sass的插值表达式
  9. //& sass嵌套里的父容器标识 @content是混合器插槽,像vue的slot
  10. [data-theme="#{$theme-name}"] & {
  11. @content;
  12. }
  13. }
  14. }
  15. //从主题色map中取出对应颜色
  16. @function themed($key) {
  17. @return map-get($theme-map, $key);
  18. }
  19. //获取背景颜色
  20. @mixin background_color($color) {
  21. @include themeify {
  22. background-color: themed($color) !important;
  23. }
  24. }
  25. //获取字体颜色
  26. @mixin font_color($color) {
  27. @include themeify {
  28. color: themed($color) !important;
  29. }
  30. }
  31. //获取icon颜色
  32. @mixin fill_color($fill) {
  33. @include themeify {
  34. fill: themed($fill) !important;
  35. }
  36. }
  37. //获取border
  38. @mixin border($border) {
  39. @include themeify {
  40. border: themed($border);
  41. }
  42. }
  43. //获取border_color
  44. @mixin border_color($color) {
  45. @include themeify {
  46. border-color: themed($color) !important;
  47. }
  48. }
  49. //获取box-shadow
  50. @mixin box_shadow($color) {
  51. @include themeify {
  52. box-shadow: themed($color);
  53. }
  54. }