_sidenav-theme.scss 2.6 KB

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