_dialog-theme.scss 3.6 KB

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