_themes.scss 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. $themes: (
  2. neutral: (
  3. baseColorDark: #000,
  4. baseColorLight: #fff,
  5. baseBorder: rgba(0, 0, 0, 0.125),
  6. secondaryColorDark: #555,
  7. secondaryColorLight: #fff,
  8. panelBackgroundColor: #fff,
  9. panelTextColor: #000,
  10. panelSecondaryBackgroundColor: rgba(255, 255, 255, 0.95),
  11. toolsBackground: #fff,
  12. toolsBackgroundDarker: #ccc,
  13. toolsColor: #000,
  14. toolsColorActive: #ffdd00,
  15. appEntryBoxBackground: #f5f5f5,
  16. appEntryBoxActiveTabBg: #e7e7e7,
  17. ),
  18. modern: (
  19. baseColorDark: #263238,
  20. baseColorLight: #ECEFF1,
  21. baseBorder: rgba(0, 0, 0, 0.125),
  22. secondaryColorDark: #607d8b,
  23. secondaryColorLight: #ECEFF1,
  24. panelBackgroundColor: #fff,
  25. panelTextColor: #000,
  26. panelSecondaryBackgroundColor: rgba(236, 239, 241, 0.95),
  27. toolsBackground: #ECEFF1,
  28. toolsColor: #263238,
  29. toolsBackgroundDarker: #b0bec5,
  30. toolsColorActive: #ffdd00,
  31. appEntryBoxBackground: #f1f4f5,
  32. appEntryBoxActiveTabBg: #eaecec,
  33. ),
  34. classic: (
  35. baseColorDark: rgb(54, 45, 40),
  36. baseColorLight: rgb(245, 234, 212),
  37. baseBorder: rgba(0, 0, 0, 0.125),
  38. secondaryColorDark: rgb(143, 119, 106),
  39. secondaryColorLight: rgb(245, 234, 212),
  40. panelBackgroundColor: #fff,
  41. panelTextColor: #000,
  42. panelSecondaryBackgroundColor: rgba(236, 239, 241, 0.95),
  43. toolsBackground: #f5ead4,
  44. toolsColor: rgb(54, 45, 40),
  45. toolsBackgroundDarker: #ccc4ba,
  46. toolsColorActive: #ffdd00,
  47. appEntryBoxBackground: #f9f7f5,
  48. appEntryBoxActiveTabBg: #f2ede9,
  49. ),
  50. );
  51. // Themify
  52. // This mixin will add a CSS rule for each theme for the CSS rules defined within it.
  53. // The `@each $theme, $map in $themes` tell Sass to loop over the `$themes` map that was defined above.
  54. // On each loop, it assigns these values to `$theme` and `$map` respectively.
  55. // - `$theme` - Theme name
  56. // - `$map` - Map of all theme variables
  57. // Then the `map-get()` function is used to get any theme variable from `$map` and output the correct property for each theme.
  58. // The `&` refer to parent selectors and placing it after `[data-theme="#{$theme}"]` tells Sass to output any parent selectors after the theme name.
  59. // To use this mixin, just be sure that the element for which you are defining the CSS rules is included in a `*[data-theme]="theme-name"` element
  60. // and embody every CSS rule that needs to be themified within the mixin:
  61. // ```
  62. // btn-primary {
  63. // @include themify($themes) {
  64. // color: themed('baseColorDark');
  65. // }
  66. // }
  67. // ```
  68. @mixin themify($themes: $themes) {
  69. @each $theme, $map in $themes {
  70. :host-context([data-theme="#{$theme}"]) &,
  71. [data-theme="#{$theme}"] & {
  72. $theme-map: () !global;
  73. @each $key, $submap in $map {
  74. $value: map-get(map-get($themes, $theme), '#{$key}');
  75. $theme-map: map-merge($theme-map, ($key: $value)) !global;
  76. }
  77. @content;
  78. $theme-map: null !global;
  79. }
  80. }
  81. }
  82. // ThemifySelf
  83. // This mixin will add a CSS rule for each theme for the CSS rules defined within it.
  84. // The `@each $theme, $map in $themes` tell Sass to loop over the `$themes` map that was defined above.
  85. // On each loop, it assigns these values to `$theme` and `$map` respectively.
  86. // - `$theme` - Theme name
  87. // - `$map` - Map of all theme variables
  88. // Then the `map-get()` function is used to get any theme variable from `$map` and output the correct property for each theme.
  89. // To use this mixin, just be sure that the element for which you are defining the CSS rules has the `[data-theme]="theme-name"` attribute
  90. // and embody every CSS rule that needs to be themified within the mixin:
  91. // ```
  92. // btn-primary {
  93. // @include themifySelf($themes) {
  94. // color: themed('baseColorDark');
  95. // }
  96. // }
  97. // ```
  98. @mixin themifySelf($themes: $themes) {
  99. @each $theme, $map in $themes {
  100. &[data-theme="#{$theme}"] {
  101. $theme-map: () !global;
  102. @each $key, $submap in $map {
  103. $value: map-get(map-get($themes, $theme), '#{$key}');
  104. $theme-map: map-merge($theme-map, ($key: $value)) !global;
  105. }
  106. @content;
  107. $theme-map: null !global;
  108. }
  109. }
  110. }
  111. @function themed($key) {
  112. @return map-get($theme-map, $key);
  113. }