|
| 1 | +@use 'sass:map'; |
1 | 2 | @use '@material/tooltip/plain-tooltip-theme' as mdc-plain-tooltip-theme;
|
2 | 3 | @use '../core/style/sass-utils';
|
3 | 4 | @use '../core/theming/theming';
|
4 | 5 | @use '../core/theming/inspection';
|
5 | 6 | @use '../core/typography/typography';
|
6 |
| -@use '../core/tokens/m2/mdc/plain-tooltip' as m2-mdc-plain-tooltip; |
| 7 | +@use '../core/tokens/m2/mdc/plain-tooltip' as tokens-mdc-plain-tooltip; |
7 | 8 |
|
8 | 9 | @mixin base($theme) {
|
9 |
| - // Add default values for tokens not related to color, typography, or density. |
10 |
| - @include sass-utils.current-selector-or-root() { |
11 |
| - @include mdc-plain-tooltip-theme.theme(m2-mdc-plain-tooltip.get-unthemable-tokens()); |
| 10 | + @if inspection.get-theme-version($theme) == 1 { |
| 11 | + @include _theme-from-tokens(inspection.get-theme-tokens($theme, base)); |
| 12 | + } |
| 13 | + @else { |
| 14 | + // Add default values for tokens not related to color, typography, or density. |
| 15 | + @include sass-utils.current-selector-or-root() { |
| 16 | + @include mdc-plain-tooltip-theme.theme(tokens-mdc-plain-tooltip.get-unthemable-tokens()); |
| 17 | + } |
12 | 18 | }
|
13 | 19 | }
|
14 | 20 |
|
15 | 21 | @mixin color($theme) {
|
16 |
| - $mdc-tooltip-color-tokens: m2-mdc-plain-tooltip.get-color-tokens($theme); |
| 22 | + @if inspection.get-theme-version($theme) == 1 { |
| 23 | + @include _theme-from-tokens(inspection.get-theme-tokens($theme, color)); |
| 24 | + } |
| 25 | + @else { |
| 26 | + $mdc-tooltip-color-tokens: tokens-mdc-plain-tooltip.get-color-tokens($theme); |
17 | 27 |
|
18 |
| - // Add values for MDC tooltip tokens. |
19 |
| - @include sass-utils.current-selector-or-root() { |
20 |
| - @include mdc-plain-tooltip-theme.theme($mdc-tooltip-color-tokens); |
| 28 | + // Add values for MDC tooltip tokens. |
| 29 | + @include sass-utils.current-selector-or-root() { |
| 30 | + @include mdc-plain-tooltip-theme.theme($mdc-tooltip-color-tokens); |
| 31 | + } |
21 | 32 | }
|
22 | 33 | }
|
23 | 34 |
|
24 | 35 | @mixin typography($theme) {
|
25 |
| - $mdc-tooltip-typography-tokens: m2-mdc-plain-tooltip.get-typography-tokens($theme); |
| 36 | + @if inspection.get-theme-version($theme) == 1 { |
| 37 | + @include _theme-from-tokens(inspection.get-theme-tokens($theme, typography)); |
| 38 | + } |
| 39 | + @else { |
| 40 | + $mdc-tooltip-typography-tokens: tokens-mdc-plain-tooltip.get-typography-tokens($theme); |
26 | 41 |
|
27 |
| - // Add values for MDC tooltip tokens. |
28 |
| - @include sass-utils.current-selector-or-root() { |
29 |
| - @include mdc-plain-tooltip-theme.theme($mdc-tooltip-typography-tokens); |
| 42 | + // Add values for MDC tooltip tokens. |
| 43 | + @include sass-utils.current-selector-or-root() { |
| 44 | + @include mdc-plain-tooltip-theme.theme($mdc-tooltip-typography-tokens); |
| 45 | + } |
30 | 46 | }
|
31 | 47 | }
|
32 | 48 |
|
33 | 49 | @mixin density($theme) {
|
34 |
| - $mdc-tooltip-density-tokens: m2-mdc-plain-tooltip.get-density-tokens($theme); |
| 50 | + @if inspection.get-theme-version($theme) == 1 { |
| 51 | + @include _theme-from-tokens(inspection.get-theme-tokens($theme, density)); |
| 52 | + } |
| 53 | + @else { |
| 54 | + $mdc-tooltip-density-tokens: tokens-mdc-plain-tooltip.get-density-tokens($theme); |
35 | 55 |
|
36 |
| - // Add values for MDC tooltip tokens. |
37 |
| - @include sass-utils.current-selector-or-root() { |
38 |
| - @include mdc-plain-tooltip-theme.theme($mdc-tooltip-density-tokens); |
| 56 | + // Add values for MDC tooltip tokens. |
| 57 | + @include sass-utils.current-selector-or-root() { |
| 58 | + @include mdc-plain-tooltip-theme.theme($mdc-tooltip-density-tokens); |
| 59 | + } |
39 | 60 | }
|
40 | 61 | }
|
41 | 62 |
|
42 | 63 | @mixin theme($theme) {
|
43 | 64 | @include theming.private-check-duplicate-theme-styles($theme, 'mat-tooltip') {
|
44 |
| - @include base($theme); |
45 |
| - @if inspection.theme-has($theme, color) { |
46 |
| - @include color($theme); |
47 |
| - } |
48 |
| - @if inspection.theme-has($theme, density) { |
49 |
| - @include density($theme); |
| 65 | + @if inspection.get-theme-version($theme) == 1 { |
| 66 | + @include _theme-from-tokens(inspection.get-theme-tokens($theme)); |
50 | 67 | }
|
51 |
| - @if inspection.theme-has($theme, typography) { |
52 |
| - @include typography($theme); |
| 68 | + @else { |
| 69 | + @include base($theme); |
| 70 | + @if inspection.theme-has($theme, color) { |
| 71 | + @include color($theme); |
| 72 | + } |
| 73 | + @if inspection.theme-has($theme, density) { |
| 74 | + @include density($theme); |
| 75 | + } |
| 76 | + @if inspection.theme-has($theme, typography) { |
| 77 | + @include typography($theme); |
| 78 | + } |
53 | 79 | }
|
54 | 80 | }
|
55 | 81 | }
|
| 82 | + |
| 83 | +@mixin _theme-from-tokens($tokens) { |
| 84 | + @if $tokens != () { |
| 85 | + @include mdc-plain-tooltip-theme.theme(map.get($tokens, tokens-mdc-plain-tooltip.$prefix)); |
| 86 | + } |
| 87 | +} |
0 commit comments