_snack-bar-theme.scss 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. @use 'sass:map';
  2. @use '../core/theming/theming';
  3. @use '../core/theming/inspection';
  4. @use '../core/theming/validation';
  5. @use '../core/style/sass-utils';
  6. @use '../core/typography/typography';
  7. @use '../core/tokens/token-utils';
  8. @use '../core/tokens/m2/mdc/snack-bar' as tokens-mdc-snack-bar;
  9. @use '../core/tokens/m2/mat/snack-bar' as tokens-mat-snack-bar;
  10. @mixin base($theme) {
  11. @if inspection.get-theme-version($theme) == 1 {
  12. @include _theme-from-tokens(inspection.get-theme-tokens($theme, base));
  13. } @else {
  14. // Add default values for tokens not related to color, typography, or density.
  15. @include sass-utils.current-selector-or-root() {
  16. @include token-utils.create-token-values(
  17. tokens-mdc-snack-bar.$prefix,
  18. tokens-mdc-snack-bar.get-unthemable-tokens()
  19. );
  20. }
  21. }
  22. }
  23. @mixin color($theme) {
  24. @if inspection.get-theme-version($theme) == 1 {
  25. @include _theme-from-tokens(inspection.get-theme-tokens($theme, color));
  26. } @else {
  27. @include sass-utils.current-selector-or-root() {
  28. @include token-utils.create-token-values(
  29. tokens-mdc-snack-bar.$prefix,
  30. tokens-mdc-snack-bar.get-color-tokens($theme)
  31. );
  32. @include token-utils.create-token-values(
  33. tokens-mat-snack-bar.$prefix,
  34. tokens-mat-snack-bar.get-color-tokens($theme)
  35. );
  36. }
  37. }
  38. }
  39. @mixin typography($theme) {
  40. @if inspection.get-theme-version($theme) == 1 {
  41. @include _theme-from-tokens(inspection.get-theme-tokens($theme, typography));
  42. } @else {
  43. @include sass-utils.current-selector-or-root() {
  44. @include token-utils.create-token-values(
  45. tokens-mdc-snack-bar.$prefix,
  46. tokens-mdc-snack-bar.get-typography-tokens($theme)
  47. );
  48. }
  49. }
  50. }
  51. @mixin density($theme) {
  52. }
  53. /// Defines the tokens that will be available in the `overrides` mixin and for docs extraction.
  54. @function _define-overrides() {
  55. @return (
  56. (
  57. namespace: tokens-mdc-snack-bar.$prefix,
  58. tokens: tokens-mdc-snack-bar.get-token-slots(),
  59. ),
  60. (
  61. namespace: tokens-mat-snack-bar.$prefix,
  62. tokens: tokens-mat-snack-bar.get-token-slots(),
  63. ),
  64. );
  65. }
  66. /// Outputs the CSS variable values for the given tokens.
  67. /// @param {Map} $tokens The token values to emit.
  68. @mixin overrides($tokens: ()) {
  69. @include token-utils.batch-create-token-values($tokens, _define-overrides()...);
  70. }
  71. @mixin theme($theme) {
  72. @include theming.private-check-duplicate-theme-styles($theme, 'mat-snack-bar') {
  73. @if inspection.get-theme-version($theme) == 1 {
  74. @include _theme-from-tokens(inspection.get-theme-tokens($theme));
  75. } @else {
  76. @include base($theme);
  77. @if inspection.theme-has($theme, color) {
  78. @include color($theme);
  79. }
  80. @if inspection.theme-has($theme, density) {
  81. @include density($theme);
  82. }
  83. @if inspection.theme-has($theme, typography) {
  84. @include typography($theme);
  85. }
  86. }
  87. }
  88. }
  89. @mixin _theme-from-tokens($tokens) {
  90. @include validation.selector-defined(
  91. 'Calls to Angular Material theme mixins with an M3 theme must be wrapped in a selector'
  92. );
  93. @if ($tokens != ()) {
  94. @include token-utils.create-token-values(
  95. tokens-mdc-snack-bar.$prefix,
  96. map.get($tokens, tokens-mdc-snack-bar.$prefix)
  97. );
  98. @include token-utils.create-token-values(
  99. tokens-mat-snack-bar.$prefix,
  100. map.get($tokens, tokens-mat-snack-bar.$prefix)
  101. );
  102. }
  103. }