|
2 | 2 | @use '../core/style/sass-utils';
|
3 | 3 | @use '../core/theming/theming';
|
4 | 4 | @use '../core/theming/inspection';
|
5 |
| -@use '../core/theming/validation'; |
6 | 5 | @use '../core/typography/typography';
|
7 | 6 | @use '../core/tokens/token-utils';
|
8 |
| -@use '../core/tokens/m2/mat/card' as tokens-mat-card; |
9 |
| -@use '../core/tokens/m2/mdc/elevated-card' as tokens-mdc-elevated-card; |
10 |
| -@use '../core/tokens/m2/mdc/outlined-card' as tokens-mdc-outlined-card; |
| 7 | +@use 'm2-tokens' as m2-tokens; |
| 8 | +@use 'm3-tokens' as m3-tokens; |
11 | 9 |
|
12 | 10 | @mixin base($theme) {
|
13 | 11 | @if inspection.get-theme-version($theme) == 1 {
|
14 |
| - @include _theme-from-tokens(inspection.get-theme-tokens($theme, base)); |
| 12 | + @include token-utils.define-token-values( |
| 13 | + m3-tokens.get-unthemable-tokens($theme) |
| 14 | + ); |
15 | 15 | } @else {
|
16 | 16 | @include sass-utils.current-selector-or-root() {
|
17 |
| - @include token-utils.create-token-values-mixed( |
18 |
| - tokens-mdc-elevated-card.$prefix, |
19 |
| - tokens-mdc-elevated-card.get-unthemable-tokens() |
20 |
| - ); |
21 |
| - @include token-utils.create-token-values-mixed( |
22 |
| - tokens-mdc-outlined-card.$prefix, |
23 |
| - tokens-mdc-outlined-card.get-unthemable-tokens() |
24 |
| - ); |
25 |
| - @include token-utils.create-token-values-mixed( |
26 |
| - tokens-mat-card.$prefix, |
27 |
| - tokens-mat-card.get-unthemable-tokens() |
| 17 | + @include token-utils.define-token-values-mixed( |
| 18 | + m2-tokens.get-unthemable-tokens() |
28 | 19 | );
|
29 | 20 | }
|
30 | 21 | }
|
31 | 22 | }
|
32 | 23 |
|
33 | 24 | @mixin color($theme) {
|
34 | 25 | @if inspection.get-theme-version($theme) == 1 {
|
35 |
| - @include _theme-from-tokens(inspection.get-theme-tokens($theme, color)); |
| 26 | + @include token-utils.define-token-values( |
| 27 | + m3-tokens.get-color-tokens($theme) |
| 28 | + ); |
36 | 29 | } @else {
|
37 | 30 | @include sass-utils.current-selector-or-root() {
|
38 |
| - @include token-utils.create-token-values-mixed( |
39 |
| - tokens-mdc-elevated-card.$prefix, |
40 |
| - tokens-mdc-elevated-card.get-color-tokens($theme) |
41 |
| - ); |
42 |
| - @include token-utils.create-token-values-mixed( |
43 |
| - tokens-mdc-outlined-card.$prefix, |
44 |
| - tokens-mdc-outlined-card.get-color-tokens($theme) |
45 |
| - ); |
46 |
| - @include token-utils.create-token-values-mixed( |
47 |
| - tokens-mat-card.$prefix, |
48 |
| - tokens-mat-card.get-color-tokens($theme) |
| 31 | + @include token-utils.define-token-values-mixed( |
| 32 | + m2-tokens.get-color-tokens($theme) |
49 | 33 | );
|
50 | 34 | }
|
51 | 35 | }
|
52 | 36 | }
|
53 | 37 |
|
54 | 38 | @mixin typography($theme) {
|
55 | 39 | @if inspection.get-theme-version($theme) == 1 {
|
56 |
| - @include _theme-from-tokens(inspection.get-theme-tokens($theme, typography)); |
| 40 | + @include token-utils.define-token-values( |
| 41 | + m3-tokens.get-typography-tokens($theme) |
| 42 | + ); |
57 | 43 | } @else {
|
58 | 44 | @include sass-utils.current-selector-or-root() {
|
59 |
| - @include token-utils.create-token-values-mixed( |
60 |
| - tokens-mdc-elevated-card.$prefix, |
61 |
| - tokens-mdc-elevated-card.get-typography-tokens($theme) |
62 |
| - ); |
63 |
| - @include token-utils.create-token-values-mixed( |
64 |
| - tokens-mdc-outlined-card.$prefix, |
65 |
| - tokens-mdc-outlined-card.get-typography-tokens($theme) |
66 |
| - ); |
67 |
| - @include token-utils.create-token-values-mixed( |
68 |
| - tokens-mat-card.$prefix, |
69 |
| - tokens-mat-card.get-typography-tokens($theme) |
| 45 | + @include token-utils.define-token-values-mixed( |
| 46 | + m2-tokens.get-typography-tokens($theme) |
70 | 47 | );
|
71 | 48 | }
|
72 | 49 | }
|
73 | 50 | }
|
74 | 51 |
|
75 | 52 | @mixin density($theme) {
|
76 | 53 | @if inspection.get-theme-version($theme) == 1 {
|
77 |
| - @include _theme-from-tokens(inspection.get-theme-tokens($theme, density)); |
| 54 | + @include token-utils.define-token-values( |
| 55 | + m3-tokens.get-density-tokens($theme) |
| 56 | + ); |
78 | 57 | } @else {
|
79 | 58 | @include sass-utils.current-selector-or-root() {
|
80 |
| - @include token-utils.create-token-values-mixed( |
81 |
| - tokens-mdc-elevated-card.$prefix, |
82 |
| - tokens-mdc-elevated-card.get-density-tokens($theme) |
83 |
| - ); |
84 |
| - @include token-utils.create-token-values-mixed( |
85 |
| - tokens-mdc-outlined-card.$prefix, |
86 |
| - tokens-mdc-outlined-card.get-density-tokens($theme) |
87 |
| - ); |
88 |
| - @include token-utils.create-token-values-mixed( |
89 |
| - tokens-mat-card.$prefix, |
90 |
| - tokens-mat-card.get-density-tokens($theme) |
| 59 | + @include token-utils.define-token-values-mixed( |
| 60 | + m2-tokens.get-density-tokens($theme) |
91 | 61 | );
|
92 | 62 | }
|
93 | 63 | }
|
|
97 | 67 | @function _define-overrides() {
|
98 | 68 | @return (
|
99 | 69 | (
|
100 |
| - namespace: tokens-mat-card.$prefix, |
101 |
| - tokens: tokens-mat-card.get-token-slots(), |
102 |
| - ), |
103 |
| - ( |
104 |
| - namespace: tokens-mdc-elevated-card.$prefix, |
105 |
| - tokens: tokens-mdc-elevated-card.get-token-slots(), |
106 |
| - prefix: 'elevated-', |
107 |
| - ), |
108 |
| - ( |
109 |
| - namespace: tokens-mdc-outlined-card.$prefix, |
110 |
| - tokens: tokens-mdc-outlined-card.get-token-slots(), |
111 |
| - prefix: 'outlined-', |
| 70 | + component: card, |
| 71 | + namespace: (mat), |
| 72 | + tokens: m3-tokens.get-system-fallbacks(), |
| 73 | + overrideTransforms: $overrideTransforms, |
112 | 74 | ),
|
113 | 75 | );
|
114 | 76 | }
|
115 | 77 |
|
| 78 | +/// Map of override keys that should be transformed to their corresponding token name |
| 79 | +$overrideTransforms: ( |
| 80 | + elevated-container-shape: elevated-card-container-shape, |
| 81 | + outlined-container-shape: outlined-card-container-shape, |
| 82 | + outlined-outline-width: outlined-card-outline-width, |
| 83 | + elevated-container-color: elevated-card-container-color, |
| 84 | + elevated-container-elevation: elevated-card-container-elevation, |
| 85 | + outlined-container-color: outlined-card-container-color, |
| 86 | + outlined-outline-color: outlined-card-outline-color, |
| 87 | + outlined-container-elevation: outlined-card-container-elevation |
| 88 | +); |
| 89 | + |
116 | 90 | @mixin overrides($tokens: ()) {
|
117 |
| - @include token-utils.batch-create-token-values($tokens, _define-overrides()...); |
| 91 | + $override-tokens: (); |
| 92 | + @each $key, $value in $tokens { |
| 93 | + $token: map.get($overrideTransforms, $key) or $key; |
| 94 | + $override-tokens: map.set($override-tokens, $token, $value); |
| 95 | + } |
| 96 | + |
| 97 | + @include token-utils.batch-create-token-values($override-tokens, _define-overrides()...); |
118 | 98 | }
|
119 | 99 |
|
120 | 100 | @mixin theme($theme) {
|
121 | 101 | @include theming.private-check-duplicate-theme-styles($theme, 'mat-card') {
|
122 |
| - @if inspection.get-theme-version($theme) == 1 { |
123 |
| - @include _theme-from-tokens(inspection.get-theme-tokens($theme)); |
124 |
| - } @else { |
125 |
| - @include base($theme); |
126 |
| - @if inspection.theme-has($theme, color) { |
127 |
| - @include color($theme); |
128 |
| - } |
129 |
| - @if inspection.theme-has($theme, density) { |
130 |
| - @include density($theme); |
131 |
| - } |
132 |
| - @if inspection.theme-has($theme, typography) { |
133 |
| - @include typography($theme); |
134 |
| - } |
| 102 | + @include base($theme); |
| 103 | + @if inspection.theme-has($theme, color) { |
| 104 | + @include color($theme); |
| 105 | + } |
| 106 | + @if inspection.theme-has($theme, density) { |
| 107 | + @include density($theme); |
| 108 | + } |
| 109 | + @if inspection.theme-has($theme, typography) { |
| 110 | + @include typography($theme); |
135 | 111 | }
|
136 |
| - } |
137 |
| -} |
138 |
| - |
139 |
| -@mixin _theme-from-tokens($tokens) { |
140 |
| - @include validation.selector-defined( |
141 |
| - 'Calls to Angular Material theme mixins with an M3 theme must be wrapped in a selector' |
142 |
| - ); |
143 |
| - @if ($tokens != ()) { |
144 |
| - @include token-utils.create-token-values( |
145 |
| - tokens-mdc-elevated-card.$prefix, |
146 |
| - map.get($tokens, tokens-mdc-elevated-card.$prefix) |
147 |
| - ); |
148 |
| - @include token-utils.create-token-values( |
149 |
| - tokens-mdc-outlined-card.$prefix, |
150 |
| - map.get($tokens, tokens-mdc-outlined-card.$prefix) |
151 |
| - ); |
152 |
| - @include token-utils.create-token-values( |
153 |
| - tokens-mat-card.$prefix, |
154 |
| - map.get($tokens, tokens-mat-card.$prefix) |
155 |
| - ); |
156 | 112 | }
|
157 | 113 | }
|
0 commit comments