_stepper-theme.scss 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. @use '../core/theming/theming';
  2. @use '../core/theming/inspection';
  3. @use '../core/theming/validation';
  4. @use '../core/typography/typography';
  5. @use '../core/style/sass-utils';
  6. @use '../core/tokens/token-utils';
  7. @use '../core/tokens/m2/mat/stepper' as tokens-mat-stepper;
  8. /// Outputs base theme styles (styles not dependent on the color, typography, or density settings)
  9. /// for mat-stepper.
  10. /// @param {Map} $theme The theme to generate base styles for.
  11. @mixin base($theme) {
  12. @if inspection.get-theme-version($theme) == 1 {
  13. @include _theme-from-tokens(inspection.get-theme-tokens($theme, base));
  14. } @else {
  15. }
  16. }
  17. /// Outputs color theme styles for mat-stepper.
  18. /// @param {Map} $theme The theme to generate color styles for.
  19. /// @param {ArgList} Additional optional arguments (only supported for M3 themes):
  20. /// $color-variant: The color variant to use for the stepper: primary, secondary,
  21. /// tertiary, or error (If not specified, primary color values will be used).
  22. @mixin color($theme, $options...) {
  23. @if inspection.get-theme-version($theme) == 1 {
  24. @include _theme-from-tokens(inspection.get-theme-tokens($theme, color), $options...);
  25. } @else {
  26. @include sass-utils.current-selector-or-root() {
  27. @include token-utils.create-token-values(
  28. tokens-mat-stepper.$prefix,
  29. tokens-mat-stepper.get-color-tokens($theme)
  30. );
  31. .mat-step-header.mat-accent {
  32. @include token-utils.create-token-values(
  33. tokens-mat-stepper.$prefix,
  34. tokens-mat-stepper.private-get-color-palette-color-tokens($theme, accent)
  35. );
  36. }
  37. .mat-step-header.mat-warn {
  38. @include token-utils.create-token-values(
  39. tokens-mat-stepper.$prefix,
  40. tokens-mat-stepper.private-get-color-palette-color-tokens($theme, warn)
  41. );
  42. }
  43. }
  44. }
  45. }
  46. /// Outputs typography theme styles for mat-stepper.
  47. /// @param {Map} $theme The theme to generate typography styles for.
  48. @mixin typography($theme) {
  49. @if inspection.get-theme-version($theme) == 1 {
  50. @include _theme-from-tokens(inspection.get-theme-tokens($theme, typography));
  51. } @else {
  52. @include sass-utils.current-selector-or-root() {
  53. @include token-utils.create-token-values(
  54. tokens-mat-stepper.$prefix,
  55. tokens-mat-stepper.get-typography-tokens($theme)
  56. );
  57. }
  58. }
  59. }
  60. /// Outputs density theme styles for mat-stepper.
  61. /// @param {Map} $theme The theme to generate density styles for.
  62. @mixin density($theme) {
  63. @if inspection.get-theme-version($theme) == 1 {
  64. @include _theme-from-tokens(inspection.get-theme-tokens($theme, density));
  65. } @else {
  66. @include sass-utils.current-selector-or-root() {
  67. @include token-utils.create-token-values(
  68. tokens-mat-stepper.$prefix,
  69. tokens-mat-stepper.get-density-tokens($theme)
  70. );
  71. }
  72. }
  73. }
  74. /// Defines the tokens that will be available in the `overrides` mixin and for docs extraction.
  75. @function _define-overrides() {
  76. @return (
  77. (
  78. namespace: tokens-mat-stepper.$prefix,
  79. tokens: tokens-mat-stepper.get-token-slots(),
  80. ),
  81. );
  82. }
  83. /// Outputs the CSS variable values for the given tokens.
  84. /// @param {Map} $tokens The token values to emit.
  85. @mixin overrides($tokens: ()) {
  86. @include token-utils.batch-create-token-values($tokens, _define-overrides()...);
  87. }
  88. /// Outputs all (base, color, typography, and density) theme styles for mat-stepper.
  89. /// @param {Map} $theme The theme to generate color styles for.
  90. /// @param {ArgList} Additional optional arguments (only supported for M3 themes):
  91. /// $color-variant: The color variant to use for the stepper: primary, secondary,
  92. /// tertiary, or error (If not specified, primary color values will be used).
  93. @mixin theme($theme, $options...) {
  94. @include theming.private-check-duplicate-theme-styles($theme, 'mat-stepper') {
  95. @if inspection.get-theme-version($theme) == 1 {
  96. @include _theme-from-tokens(inspection.get-theme-tokens($theme), $options...);
  97. } @else {
  98. @include base($theme);
  99. @if inspection.theme-has($theme, color) {
  100. @include color($theme);
  101. }
  102. @if inspection.theme-has($theme, density) {
  103. @include density($theme);
  104. }
  105. @if inspection.theme-has($theme, typography) {
  106. @include typography($theme);
  107. }
  108. }
  109. }
  110. }
  111. @mixin _theme-from-tokens($tokens, $options...) {
  112. @include validation.selector-defined(
  113. 'Calls to Angular Material theme mixins with an M3 theme must be wrapped in a selector'
  114. );
  115. @if ($tokens != ()) {
  116. $mat-stepper-tokens: token-utils.get-tokens-for(
  117. $tokens,
  118. tokens-mat-stepper.$prefix,
  119. $options...
  120. );
  121. @include token-utils.create-token-values(tokens-mat-stepper.$prefix, $mat-stepper-tokens);
  122. }
  123. }