_paginator-theme.scss 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. @use 'sass:map';
  2. @use 'sass:meta';
  3. @use '../core/tokens/m2/mat/paginator' as tokens-mat-paginator;
  4. @use '../core/style/sass-utils';
  5. @use '../core/typography/typography';
  6. @use '../core/theming/theming';
  7. @use '../core/theming/inspection';
  8. @use '../core/theming/validation';
  9. @use '../core/tokens/token-utils';
  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. }
  15. }
  16. @mixin color($theme) {
  17. @if inspection.get-theme-version($theme) == 1 {
  18. @include _theme-from-tokens(inspection.get-theme-tokens($theme, color));
  19. } @else {
  20. @include sass-utils.current-selector-or-root() {
  21. @include token-utils.create-token-values(
  22. tokens-mat-paginator.$prefix,
  23. tokens-mat-paginator.get-color-tokens($theme)
  24. );
  25. }
  26. }
  27. }
  28. @mixin typography($theme) {
  29. @if inspection.get-theme-version($theme) == 1 {
  30. @include _theme-from-tokens(inspection.get-theme-tokens($theme, typography));
  31. } @else {
  32. @include sass-utils.current-selector-or-root() {
  33. @include token-utils.create-token-values(
  34. tokens-mat-paginator.$prefix,
  35. tokens-mat-paginator.get-typography-tokens($theme)
  36. );
  37. }
  38. }
  39. }
  40. @mixin density($theme) {
  41. $density-scale: inspection.get-theme-density($theme);
  42. $form-field-density: if(
  43. (meta.type-of($density-scale) == 'number' and $density-scale >= -4) or
  44. ($density-scale == maximum),
  45. -4,
  46. $density-scale
  47. );
  48. @if inspection.get-theme-version($theme) == 1 {
  49. @include _theme-from-tokens(inspection.get-theme-tokens($theme, density));
  50. } @else {
  51. @include sass-utils.current-selector-or-root() {
  52. @include token-utils.create-token-values(
  53. tokens-mat-paginator.$prefix,
  54. tokens-mat-paginator.get-density-tokens($theme)
  55. );
  56. }
  57. }
  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-mat-paginator.$prefix,
  64. tokens: tokens-mat-paginator.get-token-slots(),
  65. ),
  66. );
  67. }
  68. @mixin overrides($tokens: ()) {
  69. @include token-utils.batch-create-token-values($tokens, _define-overrides()...);
  70. }
  71. @mixin theme($theme) {
  72. @include theming.private-check-duplicate-theme-styles($theme, 'mat-paginator') {
  73. @if inspection.get-theme-version($theme) == 1 {
  74. @include _theme-from-tokens(inspection.get-theme-tokens($theme));
  75. } @else {
  76. @include base($theme);
  77. @if inspection.theme-has($theme, color) {
  78. @include color($theme);
  79. }
  80. @if inspection.theme-has($theme, density) {
  81. @include density($theme);
  82. }
  83. @if inspection.theme-has($theme, typography) {
  84. @include typography($theme);
  85. }
  86. }
  87. }
  88. }
  89. @mixin _theme-from-tokens($tokens) {
  90. @include validation.selector-defined(
  91. 'Calls to Angular Material theme mixins with an M3 theme must be wrapped in a selector'
  92. );
  93. @if ($tokens != ()) {
  94. @include token-utils.create-token-values(
  95. tokens-mat-paginator.$prefix,
  96. map.get($tokens, tokens-mat-paginator.$prefix)
  97. );
  98. }
  99. }