_progress-bar-theme.scss 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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/linear-progress' as tokens-mdc-linear-progress;
  7. /// Outputs base theme styles (styles not dependent on the color, typography, or density settings)
  8. /// for the mat-progress-bar.
  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. // 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-linear-progress.$prefix,
  18. tokens-mdc-linear-progress.get-unthemable-tokens()
  19. );
  20. }
  21. }
  22. }
  23. @mixin _palette-styles($theme, $palette-name) {
  24. @include token-utils.create-token-values(
  25. tokens-mdc-linear-progress.$prefix,
  26. tokens-mdc-linear-progress.get-color-tokens($theme, $palette-name)
  27. );
  28. }
  29. /// Outputs color theme styles for the mat-progress-bar.
  30. /// @param {Map} $theme The theme to generate color styles for.
  31. /// @param {ArgList} Additional optional arguments (only supported for M3 themes):
  32. /// $color-variant: The color variant to use for the progress bar: primary, secondary, tertiary,
  33. /// or error (If not specified, default primary color will be used).
  34. @mixin color($theme, $options...) {
  35. @if inspection.get-theme-version($theme) == 1 {
  36. @include _theme-from-tokens(inspection.get-theme-tokens($theme, color), $options...);
  37. } @else {
  38. .mat-mdc-progress-bar {
  39. @include _palette-styles($theme, primary);
  40. &.mat-accent {
  41. @include _palette-styles($theme, accent);
  42. }
  43. &.mat-warn {
  44. @include _palette-styles($theme, warn);
  45. }
  46. }
  47. }
  48. }
  49. /// Outputs typography theme styles for the mat-progress-bar.
  50. /// @param {Map} $theme The theme to generate typography styles for.
  51. @mixin typography($theme) {
  52. }
  53. /// Outputs density theme styles for the mat-progress-bar.
  54. /// @param {Map} $theme The theme to generate density styles for.
  55. @mixin density($theme) {
  56. }
  57. /// Defines the tokens that will be available in the `overrides` mixin and for docs extraction.
  58. @function _define-overrides() {
  59. @return (
  60. (
  61. namespace: tokens-mdc-linear-progress.$prefix,
  62. tokens: tokens-mdc-linear-progress.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. /// Outputs all (base, color, typography, and density) theme styles for the mat-progress-bar.
  72. /// @param {Map} $theme The theme to generate styles for.
  73. /// @param {ArgList} Additional optional arguments (only supported for M3 themes):
  74. /// $color-variant: The color variant to use for the progress bar: primary, secondary, tertiary,
  75. /// or error (If not specified, default primary color will be used).
  76. @mixin theme($theme, $options...) {
  77. @include theming.private-check-duplicate-theme-styles($theme, 'mat-progress-bar') {
  78. @if inspection.get-theme-version($theme) == 1 {
  79. @include _theme-from-tokens(inspection.get-theme-tokens($theme), $options...);
  80. } @else {
  81. @include base($theme);
  82. @if inspection.theme-has($theme, color) {
  83. @include color($theme);
  84. }
  85. @if inspection.theme-has($theme, density) {
  86. @include density($theme);
  87. }
  88. @if inspection.theme-has($theme, typography) {
  89. @include typography($theme);
  90. }
  91. }
  92. }
  93. }
  94. @mixin _theme-from-tokens($tokens, $options...) {
  95. @include validation.selector-defined(
  96. 'Calls to Angular Material theme mixins with an M3 theme must be wrapped in a selector'
  97. );
  98. $tokens: token-utils.get-tokens-for($tokens, tokens-mdc-linear-progress.$prefix, $options...);
  99. @include token-utils.create-token-values(tokens-mdc-linear-progress.$prefix, $tokens);
  100. }