_progress-spinner-theme.scss 4.2 KB

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