|
1 | 1 | @use 'sass:map';
|
2 | 2 | @use '../core/style/sass-utils';
|
3 | 3 | @use '../core/theming/theming';
|
| 4 | +@use '../core/theming/inspection'; |
4 | 5 | @use '../core/typography/typography';
|
5 | 6 | @use '../core/tokens/token-utils';
|
6 | 7 | @use '../core/tokens/m2/mat/card' as tokens-mat-card;
|
|
10 | 11 | @use '@material/card/outlined-card-theme' as mdc-outlined-card-theme;
|
11 | 12 |
|
12 | 13 | @mixin base($config-or-theme) {
|
13 |
| - @include sass-utils.current-selector-or-root() { |
14 |
| - @include mdc-elevated-card-theme.theme(tokens-mdc-elevated-card.get-unthemable-tokens()); |
15 |
| - @include mdc-outlined-card-theme.theme(tokens-mdc-outlined-card.get-unthemable-tokens()); |
16 |
| - @include token-utils.create-token-values( |
17 |
| - tokens-mat-card.$prefix, tokens-mat-card.get-unthemable-tokens()); |
| 14 | + @if inspection.get-theme-version($config-or-theme) == 1 { |
| 15 | + @include _theme-from-tokens(inspection.get-theme-tokens($config-or-theme, base)); |
| 16 | + } |
| 17 | + @else { |
| 18 | + @include sass-utils.current-selector-or-root() { |
| 19 | + @include mdc-elevated-card-theme.theme(tokens-mdc-elevated-card.get-unthemable-tokens()); |
| 20 | + @include mdc-outlined-card-theme.theme(tokens-mdc-outlined-card.get-unthemable-tokens()); |
| 21 | + @include token-utils.create-token-values( |
| 22 | + tokens-mat-card.$prefix, tokens-mat-card.get-unthemable-tokens()); |
| 23 | + } |
18 | 24 | }
|
19 | 25 | }
|
20 | 26 |
|
21 | 27 | @mixin color($config-or-theme) {
|
22 | 28 | $config: theming.get-color-config($config-or-theme);
|
23 |
| - $mdc-elevated-card-color-tokens: token-utils.resolve-elevation( |
24 |
| - tokens-mdc-elevated-card.get-color-tokens($config), |
25 |
| - container-elevation, |
26 |
| - container-shadow-color |
27 |
| - ); |
28 |
| - $mdc-outlined-card-color-tokens: token-utils.resolve-elevation( |
29 |
| - tokens-mdc-outlined-card.get-color-tokens($config), |
30 |
| - container-elevation, |
31 |
| - container-shadow-color, |
32 |
| - ); |
33 |
| - $mat-card-color-tokens: tokens-mat-card.get-color-tokens($config); |
34 | 29 |
|
35 |
| - // Add values for card tokens. |
36 |
| - @include sass-utils.current-selector-or-root() { |
37 |
| - @include mdc-elevated-card-theme.theme($mdc-elevated-card-color-tokens); |
38 |
| - @include mdc-outlined-card-theme.theme($mdc-outlined-card-color-tokens); |
39 |
| - @include token-utils.create-token-values(tokens-mat-card.$prefix, $mat-card-color-tokens); |
| 30 | + @if inspection.get-theme-version($config-or-theme) == 1 { |
| 31 | + @include _theme-from-tokens(inspection.get-theme-tokens($config-or-theme, color)); |
| 32 | + } |
| 33 | + @else { |
| 34 | + $mdc-elevated-card-color-tokens: token-utils.resolve-elevation( |
| 35 | + tokens-mdc-elevated-card.get-color-tokens($config), |
| 36 | + container-elevation, |
| 37 | + container-shadow-color |
| 38 | + ); |
| 39 | + $mdc-outlined-card-color-tokens: token-utils.resolve-elevation( |
| 40 | + tokens-mdc-outlined-card.get-color-tokens($config), |
| 41 | + container-elevation, |
| 42 | + container-shadow-color, |
| 43 | + ); |
| 44 | + $mat-card-color-tokens: tokens-mat-card.get-color-tokens($config); |
| 45 | + |
| 46 | + // Add values for card tokens. |
| 47 | + @include sass-utils.current-selector-or-root() { |
| 48 | + @include mdc-elevated-card-theme.theme($mdc-elevated-card-color-tokens); |
| 49 | + @include mdc-outlined-card-theme.theme($mdc-outlined-card-color-tokens); |
| 50 | + @include token-utils.create-token-values(tokens-mat-card.$prefix, $mat-card-color-tokens); |
| 51 | + } |
40 | 52 | }
|
41 | 53 | }
|
42 | 54 |
|
43 | 55 | @mixin typography($config-or-theme) {
|
44 | 56 | $config: typography.private-typography-to-2018-config(
|
45 | 57 | theming.get-typography-config($config-or-theme));
|
46 |
| - $mdc-elevated-card-typography-tokens: tokens-mdc-elevated-card.get-typography-tokens($config); |
47 |
| - $mdc-outlined-card-typography-tokens: tokens-mdc-outlined-card.get-typography-tokens($config); |
48 |
| - $mat-card-typography-tokens: tokens-mat-card.get-typography-tokens($config); |
49 | 58 |
|
50 |
| - // Add values for card tokens. |
51 |
| - @include sass-utils.current-selector-or-root() { |
52 |
| - @include mdc-elevated-card-theme.theme($mdc-elevated-card-typography-tokens); |
53 |
| - @include mdc-outlined-card-theme.theme($mdc-outlined-card-typography-tokens); |
54 |
| - @include token-utils.create-token-values(tokens-mat-card.$prefix, $mat-card-typography-tokens); |
| 59 | + @if inspection.get-theme-version($config-or-theme) == 1 { |
| 60 | + @include _theme-from-tokens(inspection.get-theme-tokens($config-or-theme, typography)); |
| 61 | + } |
| 62 | + @else { |
| 63 | + $mdc-elevated-card-typography-tokens: tokens-mdc-elevated-card.get-typography-tokens($config); |
| 64 | + $mdc-outlined-card-typography-tokens: tokens-mdc-outlined-card.get-typography-tokens($config); |
| 65 | + $mat-card-typography-tokens: tokens-mat-card.get-typography-tokens($config); |
| 66 | + |
| 67 | + // Add values for card tokens. |
| 68 | + @include sass-utils.current-selector-or-root() { |
| 69 | + @include mdc-elevated-card-theme.theme($mdc-elevated-card-typography-tokens); |
| 70 | + @include mdc-outlined-card-theme.theme($mdc-outlined-card-typography-tokens); |
| 71 | + @include token-utils.create-token-values( |
| 72 | + tokens-mat-card.$prefix, $mat-card-typography-tokens); |
| 73 | + } |
55 | 74 | }
|
56 | 75 | }
|
57 | 76 |
|
58 | 77 | @mixin density($config-or-theme) {
|
59 | 78 | $density-scale: theming.get-density-config($config-or-theme);
|
60 |
| - $mdc-elevated-card-density-tokens: tokens-mdc-elevated-card.get-density-tokens($density-scale); |
61 |
| - $mdc-outlined-card-density-tokens: tokens-mdc-outlined-card.get-density-tokens($density-scale); |
62 |
| - $mat-card-density-tokens: tokens-mat-card.get-density-tokens($density-scale); |
63 | 79 |
|
64 |
| - // Add values for card tokens. |
65 |
| - @include sass-utils.current-selector-or-root() { |
66 |
| - @include mdc-elevated-card-theme.theme($mdc-elevated-card-density-tokens); |
67 |
| - @include mdc-outlined-card-theme.theme($mdc-outlined-card-density-tokens); |
68 |
| - @include token-utils.create-token-values(tokens-mat-card.$prefix, $mat-card-density-tokens); |
| 80 | + @if inspection.get-theme-version($config-or-theme) == 1 { |
| 81 | + @include _theme-from-tokens(inspection.get-theme-tokens($config-or-theme, density)); |
| 82 | + } |
| 83 | + @else { |
| 84 | + $mdc-elevated-card-density-tokens: tokens-mdc-elevated-card.get-density-tokens($density-scale); |
| 85 | + $mdc-outlined-card-density-tokens: tokens-mdc-outlined-card.get-density-tokens($density-scale); |
| 86 | + $mat-card-density-tokens: tokens-mat-card.get-density-tokens($density-scale); |
| 87 | + |
| 88 | + // Add values for card tokens. |
| 89 | + @include sass-utils.current-selector-or-root() { |
| 90 | + @include mdc-elevated-card-theme.theme($mdc-elevated-card-density-tokens); |
| 91 | + @include mdc-outlined-card-theme.theme($mdc-outlined-card-density-tokens); |
| 92 | + @include token-utils.create-token-values(tokens-mat-card.$prefix, $mat-card-density-tokens); |
| 93 | + } |
69 | 94 | }
|
70 | 95 | }
|
71 | 96 |
|
72 | 97 | @mixin theme($theme-or-color-config) {
|
73 | 98 | $theme: theming.private-legacy-get-theme($theme-or-color-config);
|
74 |
| - @include theming.private-check-duplicate-theme-styles($theme, 'mat-card') { |
75 |
| - $color: theming.get-color-config($theme); |
76 |
| - $density: theming.get-density-config($theme); |
77 |
| - $typography: theming.get-typography-config($theme); |
78 | 99 |
|
79 |
| - @include base($theme); |
80 |
| - @if $color != null { |
81 |
| - @include color($color); |
82 |
| - } |
83 |
| - @if $density != null { |
84 |
| - @include density($density); |
85 |
| - } |
86 |
| - @if $typography != null { |
87 |
| - @include typography($typography); |
| 100 | + @if inspection.get-theme-version($theme-or-color-config) == 1 { |
| 101 | + @include _theme-from-tokens(inspection.get-theme-tokens($theme-or-color-config)); |
| 102 | + } |
| 103 | + @else { |
| 104 | + @include theming.private-check-duplicate-theme-styles($theme, 'mat-card') { |
| 105 | + $color: theming.get-color-config($theme); |
| 106 | + $density: theming.get-density-config($theme); |
| 107 | + $typography: theming.get-typography-config($theme); |
| 108 | + |
| 109 | + @include base($theme); |
| 110 | + @if $color != null { |
| 111 | + @include color($color); |
| 112 | + } |
| 113 | + @if $density != null { |
| 114 | + @include density($density); |
| 115 | + } |
| 116 | + @if $typography != null { |
| 117 | + @include typography($typography); |
| 118 | + } |
88 | 119 | }
|
89 | 120 | }
|
90 | 121 | }
|
|
0 commit comments