_timepicker-theme.scss 4.4 KB

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