_handle.scss 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. @import "./_themes.scss";
  2. //遍历主题map
  3. @mixin themeify {
  4. @each $theme-name, $theme-map in $themes {
  5. //!global 把局部变量强升为全局变量
  6. $theme-map: $theme-map !global;
  7. //判断html的data-theme的属性值 #{}是sass的插值表达式
  8. //& sass嵌套里的父容器标识 @content是混合器插槽,像vue的slot
  9. [data-theme="#{$theme-name}"] & {
  10. @content;
  11. }
  12. }
  13. }
  14. //声明一个根据Key获取颜色的function
  15. @function themed($key) {
  16. @return map-get($theme-map, $key);
  17. }
  18. //背景图大小
  19. @mixin bs($color) {
  20. @include themeify {
  21. background-size: themed($color)!important;
  22. }
  23. }
  24. //渐变文字
  25. @mixin bgTextClip($color) {
  26. @include themeify {
  27. -webkit-background-clip: themed($color)!important;
  28. }
  29. }
  30. //获取背景颜色
  31. @mixin background($color) {
  32. @include themeify {
  33. background: themed($color)!important;
  34. }
  35. }
  36. //获取字体颜色
  37. @mixin font_color($color) {
  38. @include themeify {
  39. color: themed($color)!important;
  40. }
  41. }
  42. //获取边框颜色
  43. @mixin border_color($color) {
  44. @include themeify {
  45. border-color: themed($color)!important;
  46. }
  47. }