_bottom-sheet-theme.scss 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. @use 'sass:map';
  2. @use '../core/typography/typography';
  3. @use '../core/theming/theming';
  4. @use '../core/theming/inspection';
  5. @use '../core/theming/validation';
  6. @use '../core/style/sass-utils';
  7. @use '../core/tokens/token-utils';
  8. @use '../core/tokens/m2/mat/bottom-sheet' as tokens-mat-bottom-sheet;
  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-bottom-sheet.$prefix,
  16. tokens-mat-bottom-sheet.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-bottom-sheet.$prefix,
  28. tokens-mat-bottom-sheet.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-bottom-sheet.$prefix,
  40. tokens-mat-bottom-sheet.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. }
  50. }
  51. /// Defines the tokens that will be available in the `overrides` mixin and for docs extraction.
  52. @function _define-overrides() {
  53. @return (
  54. (
  55. namespace: tokens-mat-bottom-sheet.$prefix,
  56. tokens: tokens-mat-bottom-sheet.get-token-slots(),
  57. ),
  58. );
  59. }
  60. @mixin overrides($tokens: ()) {
  61. @include token-utils.batch-create-token-values($tokens, _define-overrides()...);
  62. }
  63. @mixin theme($theme) {
  64. @include theming.private-check-duplicate-theme-styles($theme, 'mat-bottom-sheet') {
  65. @if inspection.get-theme-version($theme) == 1 {
  66. @include _theme-from-tokens(inspection.get-theme-tokens($theme));
  67. } @else {
  68. @include base($theme);
  69. @if inspection.theme-has($theme, color) {
  70. @include color($theme);
  71. }
  72. @if inspection.theme-has($theme, density) {
  73. @include density($theme);
  74. }
  75. @if inspection.theme-has($theme, typography) {
  76. @include typography($theme);
  77. }
  78. }
  79. }
  80. }
  81. @mixin _theme-from-tokens($tokens) {
  82. @include validation.selector-defined(
  83. 'Calls to Angular Material theme mixins with an M3 theme must be wrapped in a selector'
  84. );
  85. @if ($tokens != ()) {
  86. @include token-utils.create-token-values(
  87. tokens-mat-bottom-sheet.$prefix,
  88. map.get($tokens, tokens-mat-bottom-sheet.$prefix)
  89. );
  90. }
  91. }