_grid-list-theme.scss 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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/tokens/m2/mat/grid-list' as tokens-mat-grid-list;
  7. @use '../core/style/sass-utils';
  8. @use '../core/tokens/token-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. }
  14. }
  15. // Include this empty mixin for consistency with the other components.
  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. }
  21. }
  22. @mixin typography($theme) {
  23. @if inspection.get-theme-version($theme) == 1 {
  24. @include _theme-from-tokens(inspection.get-theme-tokens($theme, typography));
  25. } @else {
  26. @include sass-utils.current-selector-or-root() {
  27. @include token-utils.create-token-values(
  28. tokens-mat-grid-list.$prefix,
  29. tokens-mat-grid-list.get-typography-tokens($theme)
  30. );
  31. }
  32. }
  33. }
  34. @mixin density($theme) {
  35. @if inspection.get-theme-version($theme) == 1 {
  36. @include _theme-from-tokens(inspection.get-theme-tokens($theme, density));
  37. } @else {
  38. }
  39. }
  40. /// Defines the tokens that will be available in the `overrides` mixin and for docs extraction.
  41. @function _define-overrides() {
  42. @return (
  43. (
  44. namespace: tokens-mat-grid-list.$prefix,
  45. tokens: tokens-mat-grid-list.get-token-slots(),
  46. ),
  47. );
  48. }
  49. @mixin overrides($tokens: ()) {
  50. @include token-utils.batch-create-token-values($tokens, _define-overrides()...);
  51. }
  52. @mixin theme($theme) {
  53. @include theming.private-check-duplicate-theme-styles($theme, 'mat-grid-list') {
  54. @if inspection.get-theme-version($theme) == 1 {
  55. @include _theme-from-tokens(inspection.get-theme-tokens($theme));
  56. } @else {
  57. @include base($theme);
  58. @if inspection.theme-has($theme, color) {
  59. @include color($theme);
  60. }
  61. @if inspection.theme-has($theme, density) {
  62. @include density($theme);
  63. }
  64. @if inspection.theme-has($theme, typography) {
  65. @include typography($theme);
  66. }
  67. }
  68. }
  69. }
  70. @mixin _theme-from-tokens($tokens) {
  71. @include validation.selector-defined(
  72. 'Calls to Angular Material theme mixins with an M3 theme must be wrapped in a selector'
  73. );
  74. @if ($tokens != ()) {
  75. @include token-utils.create-token-values(
  76. tokens-mat-grid-list.$prefix,
  77. map.get($tokens, tokens-mat-grid-list.$prefix)
  78. );
  79. }
  80. }