_table-theme.scss 3.0 KB

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