|
1 | 1 | @use 'sass:color';
|
| 2 | +@use 'sass:map'; |
2 | 3 | @use 'sass:math';
|
3 | 4 | @use '@angular/cdk';
|
4 |
| - |
5 | 5 | @use '../core/theming/theming';
|
6 | 6 | @use '../core/theming/inspection';
|
7 | 7 | @use '../core/typography/typography';
|
@@ -164,57 +164,89 @@ $_emit-fallback-vars: true;
|
164 | 164 | }
|
165 | 165 | }
|
166 | 166 |
|
167 |
| -@mixin base($theme) {} |
| 167 | +@mixin base($theme) { |
| 168 | + @if inspection.get-theme-version($theme) == 1 { |
| 169 | + @include _theme-from-tokens(inspection.get-theme-tokens($theme, base)); |
| 170 | + } |
| 171 | + @else {} |
| 172 | +} |
168 | 173 |
|
169 | 174 | @mixin color($theme) {
|
170 |
| - @include sass-utils.current-selector-or-root() { |
171 |
| - @include token-utils.create-token-values(tokens-mat-badge.$prefix, |
172 |
| - tokens-mat-badge.get-color-tokens($theme)); |
| 175 | + @if inspection.get-theme-version($theme) == 1 { |
| 176 | + @include _theme-from-tokens(inspection.get-theme-tokens($theme, color)); |
173 | 177 | }
|
| 178 | + @else { |
| 179 | + @include sass-utils.current-selector-or-root() { |
| 180 | + @include token-utils.create-token-values(tokens-mat-badge.$prefix, |
| 181 | + tokens-mat-badge.get-color-tokens($theme)); |
| 182 | + } |
174 | 183 |
|
175 |
| - .mat-badge-accent { |
176 |
| - @include token-utils.create-token-values(tokens-mat-badge.$prefix, |
177 |
| - tokens-mat-badge.private-get-color-palette-color-tokens($theme, accent)); |
178 |
| - } |
| 184 | + .mat-badge-accent { |
| 185 | + @include token-utils.create-token-values(tokens-mat-badge.$prefix, |
| 186 | + tokens-mat-badge.private-get-color-palette-color-tokens($theme, accent)); |
| 187 | + } |
179 | 188 |
|
180 |
| - .mat-badge-warn { |
181 |
| - @include token-utils.create-token-values(tokens-mat-badge.$prefix, |
182 |
| - tokens-mat-badge.private-get-color-palette-color-tokens($theme, warn)); |
| 189 | + .mat-badge-warn { |
| 190 | + @include token-utils.create-token-values(tokens-mat-badge.$prefix, |
| 191 | + tokens-mat-badge.private-get-color-palette-color-tokens($theme, warn)); |
| 192 | + } |
183 | 193 | }
|
184 | 194 | }
|
185 | 195 |
|
186 | 196 | @mixin typography($theme) {
|
187 |
| - @include sass-utils.current-selector-or-root() { |
188 |
| - @include token-utils.create-token-values(tokens-mat-badge.$prefix, |
189 |
| - tokens-mat-badge.get-typography-tokens($theme)); |
| 197 | + @if inspection.get-theme-version($theme) == 1 { |
| 198 | + @include _theme-from-tokens(inspection.get-theme-tokens($theme, typography)); |
| 199 | + } |
| 200 | + @else { |
| 201 | + @include sass-utils.current-selector-or-root() { |
| 202 | + @include token-utils.create-token-values(tokens-mat-badge.$prefix, |
| 203 | + tokens-mat-badge.get-typography-tokens($theme)); |
| 204 | + } |
190 | 205 | }
|
191 | 206 | }
|
192 | 207 |
|
193 |
| -@mixin density($theme) {} |
| 208 | +@mixin density($theme) { |
| 209 | + @if inspection.get-theme-version($theme) == 1 { |
| 210 | + @include _theme-from-tokens(inspection.get-theme-tokens($theme, density)); |
| 211 | + } |
| 212 | + @else {} |
| 213 | +} |
194 | 214 |
|
195 | 215 | @mixin theme($theme) {
|
196 | 216 | @include theming.private-check-duplicate-theme-styles($theme, 'mat-badge') {
|
197 |
| - // Try to reduce the number of times that the structural styles are emitted. |
198 |
| - @if not $_badge-structure-emitted { |
199 |
| - @include _badge-structure; |
200 |
| - |
201 |
| - // Only flip the flag if the mixin is included at the top level. Otherwise the first |
202 |
| - // inclusion might be inside of a theme class which will exclude the structural styles |
203 |
| - // from all other themes. |
204 |
| - @if not & { |
205 |
| - $_badge-structure-emitted: true !global; |
206 |
| - } |
| 217 | + @if inspection.get-theme-version($theme) == 1 { |
| 218 | + @include _theme-from-tokens(inspection.get-theme-tokens($theme)); |
207 | 219 | }
|
| 220 | + @else { |
| 221 | + // Try to reduce the number of times that the structural styles are emitted. |
| 222 | + @if not $_badge-structure-emitted { |
| 223 | + @include _badge-structure; |
| 224 | + |
| 225 | + // Only flip the flag if the mixin is included at the top level. Otherwise the first |
| 226 | + // inclusion might be inside of a theme class which will exclude the structural styles |
| 227 | + // from all other themes. |
| 228 | + @if not & { |
| 229 | + $_badge-structure-emitted: true !global; |
| 230 | + } |
| 231 | + } |
208 | 232 |
|
209 |
| - @include base($theme); |
210 |
| - @if inspection.theme-has($theme, color) { |
211 |
| - @include color($theme); |
212 |
| - } |
213 |
| - @if inspection.theme-has($theme, density) { |
214 |
| - @include density($theme); |
215 |
| - } |
216 |
| - @if inspection.theme-has($theme, typography) { |
217 |
| - @include typography($theme); |
| 233 | + @include base($theme); |
| 234 | + @if inspection.theme-has($theme, color) { |
| 235 | + @include color($theme); |
| 236 | + } |
| 237 | + @if inspection.theme-has($theme, density) { |
| 238 | + @include density($theme); |
| 239 | + } |
| 240 | + @if inspection.theme-has($theme, typography) { |
| 241 | + @include typography($theme); |
| 242 | + } |
218 | 243 | }
|
219 | 244 | }
|
220 | 245 | }
|
| 246 | + |
| 247 | +@mixin _theme-from-tokens($tokens) { |
| 248 | + @if ($tokens != ()) { |
| 249 | + @include token-utils.create-token-values( |
| 250 | + tokens-mat-badge.$prefix, map.get($tokens, tokens-mat-badge.$prefix)); |
| 251 | + } |
| 252 | +} |
0 commit comments