|
| 1 | +@use 'sass:map'; |
1 | 2 | @use 'sass:color'; |
2 | 3 | @use '@material/chips/chip-theme' as mdc-chip-theme; |
3 | 4 | @use '../core/tokens/m2/mdc/chip' as tokens-mdc-chip; |
|
6 | 7 | @use '../core/typography/typography'; |
7 | 8 |
|
8 | 9 | @mixin base($theme) { |
9 | | - .mat-mdc-standard-chip { |
10 | | - @include mdc-chip-theme.theme(tokens-mdc-chip.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 | + .mat-mdc-standard-chip { |
| 15 | + @include mdc-chip-theme.theme(tokens-mdc-chip.get-unthemable-tokens()); |
| 16 | + } |
11 | 17 | } |
12 | 18 | } |
13 | 19 |
|
14 | 20 | @mixin color($theme) { |
15 | | - .mat-mdc-standard-chip { |
16 | | - $default-color-tokens: tokens-mdc-chip.get-color-tokens($theme); |
17 | | - @include mdc-chip-theme.theme($default-color-tokens); |
| 21 | + @if inspection.get-theme-version($theme) == 1 { |
| 22 | + @include _theme-from-tokens(inspection.get-theme-tokens($theme, color)); |
| 23 | + } |
| 24 | + @else { |
| 25 | + .mat-mdc-standard-chip { |
| 26 | + $default-color-tokens: tokens-mdc-chip.get-color-tokens($theme); |
| 27 | + @include mdc-chip-theme.theme($default-color-tokens); |
18 | 28 |
|
19 | | - &.mat-mdc-chip-selected, |
20 | | - &.mat-mdc-chip-highlighted { |
21 | | - &.mat-primary { |
22 | | - $primary-color-tokens: tokens-mdc-chip.get-color-tokens($theme, primary); |
23 | | - @include mdc-chip-theme.theme($primary-color-tokens); |
24 | | - } |
| 29 | + &.mat-mdc-chip-selected, |
| 30 | + &.mat-mdc-chip-highlighted { |
| 31 | + &.mat-primary { |
| 32 | + $primary-color-tokens: tokens-mdc-chip.get-color-tokens($theme, primary); |
| 33 | + @include mdc-chip-theme.theme($primary-color-tokens); |
| 34 | + } |
25 | 35 |
|
26 | | - &.mat-accent { |
27 | | - $accent-color-tokens: tokens-mdc-chip.get-color-tokens($theme, accent); |
28 | | - @include mdc-chip-theme.theme($accent-color-tokens); |
29 | | - } |
| 36 | + &.mat-accent { |
| 37 | + $accent-color-tokens: tokens-mdc-chip.get-color-tokens($theme, accent); |
| 38 | + @include mdc-chip-theme.theme($accent-color-tokens); |
| 39 | + } |
30 | 40 |
|
31 | | - &.mat-warn { |
32 | | - $warn-color-tokens: tokens-mdc-chip.get-color-tokens($theme, warn); |
33 | | - @include mdc-chip-theme.theme($warn-color-tokens); |
| 41 | + &.mat-warn { |
| 42 | + $warn-color-tokens: tokens-mdc-chip.get-color-tokens($theme, warn); |
| 43 | + @include mdc-chip-theme.theme($warn-color-tokens); |
| 44 | + } |
34 | 45 | } |
35 | 46 | } |
36 | 47 | } |
37 | 48 | } |
38 | 49 |
|
39 | 50 | @mixin typography($theme) { |
40 | | - $typography-tokens: tokens-mdc-chip.get-typography-tokens($theme); |
| 51 | + @if inspection.get-theme-version($theme) == 1 { |
| 52 | + @include _theme-from-tokens(inspection.get-theme-tokens($theme, typography)); |
| 53 | + } |
| 54 | + @else { |
| 55 | + $typography-tokens: tokens-mdc-chip.get-typography-tokens($theme); |
41 | 56 |
|
42 | | - .mat-mdc-standard-chip { |
43 | | - @include mdc-chip-theme.theme($typography-tokens); |
| 57 | + .mat-mdc-standard-chip { |
| 58 | + @include mdc-chip-theme.theme($typography-tokens); |
| 59 | + } |
44 | 60 | } |
45 | 61 | } |
46 | 62 |
|
47 | 63 | @mixin density($theme) { |
48 | | - $density-tokens: tokens-mdc-chip.get-density-tokens($theme); |
| 64 | + @if inspection.get-theme-version($theme) == 1 { |
| 65 | + @include _theme-from-tokens(inspection.get-theme-tokens($theme, density)); |
| 66 | + } |
| 67 | + @else { |
| 68 | + $density-tokens: tokens-mdc-chip.get-density-tokens($theme); |
49 | 69 |
|
50 | | - .mat-mdc-chip.mat-mdc-standard-chip { |
51 | | - @include mdc-chip-theme.theme($density-tokens); |
| 70 | + .mat-mdc-chip.mat-mdc-standard-chip { |
| 71 | + @include mdc-chip-theme.theme($density-tokens); |
| 72 | + } |
52 | 73 | } |
53 | 74 | } |
54 | 75 |
|
55 | 76 | @mixin theme($theme) { |
56 | 77 | @include theming.private-check-duplicate-theme-styles($theme, 'mat-chips') { |
57 | | - @include base($theme); |
58 | | - @if inspection.theme-has($theme, color) { |
59 | | - @include color($theme); |
60 | | - } |
61 | | - @if inspection.theme-has($theme, density) { |
62 | | - @include density($theme); |
| 78 | + @if inspection.get-theme-version($theme) == 1 { |
| 79 | + @include _theme-from-tokens(inspection.get-theme-tokens($theme)); |
63 | 80 | } |
64 | | - @if inspection.theme-has($theme, typography) { |
65 | | - @include typography($theme); |
| 81 | + @else { |
| 82 | + @include base($theme); |
| 83 | + @if inspection.theme-has($theme, color) { |
| 84 | + @include color($theme); |
| 85 | + } |
| 86 | + @if inspection.theme-has($theme, density) { |
| 87 | + @include density($theme); |
| 88 | + } |
| 89 | + @if inspection.theme-has($theme, typography) { |
| 90 | + @include typography($theme); |
| 91 | + } |
66 | 92 | } |
67 | 93 | } |
68 | 94 | } |
| 95 | + |
| 96 | +@mixin _theme-from-tokens($tokens) { |
| 97 | + @if ($tokens != ()) { |
| 98 | + @include mdc-chip-theme.theme(map.get($tokens, tokens-mdc-chip.$prefix)); |
| 99 | + } |
| 100 | +} |
0 commit comments