|
14 | 14 |
|
15 | 15 | @mixin base($theme) {
|
16 | 16 | // Add default values for tokens not related to color, typography, or density.
|
17 |
| - @include sass-utils.current-selector-or-root() { |
18 |
| - @include mdc-list-theme.theme(tokens-mdc-list.get-unthemable-tokens()); |
| 17 | + @if inspection.get-theme-version($theme) == 1 { |
| 18 | + @include _theme-from-tokens(inspection.get-theme-tokens($theme, base)); |
| 19 | + } |
| 20 | + @else { |
| 21 | + @include sass-utils.current-selector-or-root() { |
| 22 | + @include mdc-list-theme.theme(tokens-mdc-list.get-unthemable-tokens()); |
| 23 | + } |
19 | 24 | }
|
20 | 25 | }
|
21 | 26 |
|
22 | 27 | @mixin color($theme) {
|
23 |
| - $mdc-list-color-tokens: tokens-mdc-list.get-color-tokens($theme); |
24 |
| - |
25 |
| - // Add values for MDC list tokens. |
26 |
| - @include sass-utils.current-selector-or-root() { |
27 |
| - @include mdc-list-theme.theme($mdc-list-color-tokens); |
| 28 | + @if inspection.get-theme-version($theme) == 1 { |
| 29 | + @include _theme-from-tokens(inspection.get-theme-tokens($theme, color)); |
28 | 30 | }
|
| 31 | + @else { |
| 32 | + $mdc-list-color-tokens: tokens-mdc-list.get-color-tokens($theme); |
29 | 33 |
|
30 |
| - .mdc-list-item__start, |
31 |
| - .mdc-list-item__end { |
32 |
| - @include mdc-radio-theme.theme(tokens-mdc-radio.get-color-tokens($theme, primary)); |
33 |
| - } |
| 34 | + // Add values for MDC list tokens. |
| 35 | + @include sass-utils.current-selector-or-root() { |
| 36 | + @include mdc-list-theme.theme($mdc-list-color-tokens); |
| 37 | + } |
34 | 38 |
|
35 |
| - .mat-accent { |
36 | 39 | .mdc-list-item__start,
|
37 | 40 | .mdc-list-item__end {
|
38 |
| - @include mdc-radio-theme.theme(tokens-mdc-radio.get-color-tokens($theme, accent)); |
| 41 | + @include mdc-radio-theme.theme(tokens-mdc-radio.get-color-tokens($theme, primary)); |
39 | 42 | }
|
40 |
| - } |
41 | 43 |
|
42 |
| - .mat-warn { |
43 |
| - .mdc-list-item__start, |
44 |
| - .mdc-list-item__end { |
45 |
| - @include mdc-radio-theme.theme(tokens-mdc-radio.get-color-tokens($theme, warn)); |
| 44 | + .mat-accent { |
| 45 | + .mdc-list-item__start, |
| 46 | + .mdc-list-item__end { |
| 47 | + @include mdc-radio-theme.theme(tokens-mdc-radio.get-color-tokens($theme, accent)); |
| 48 | + } |
46 | 49 | }
|
47 |
| - } |
48 | 50 |
|
49 |
| - .mat-mdc-list-option { |
50 |
| - @include mdc-checkbox-theme.theme(tokens-mdc-checkbox.get-color-tokens($theme, primary)); |
51 |
| - } |
52 |
| - .mat-mdc-list-option.mat-accent { |
53 |
| - @include mdc-checkbox-theme.theme(tokens-mdc-checkbox.get-color-tokens($theme, accent)); |
54 |
| - } |
55 |
| - .mat-mdc-list-option.mat-warn { |
56 |
| - @include mdc-checkbox-theme.theme(tokens-mdc-checkbox.get-color-tokens($theme, warn)); |
57 |
| - } |
| 51 | + .mat-warn { |
| 52 | + .mdc-list-item__start, |
| 53 | + .mdc-list-item__end { |
| 54 | + @include mdc-radio-theme.theme(tokens-mdc-radio.get-color-tokens($theme, warn)); |
| 55 | + } |
| 56 | + } |
58 | 57 |
|
59 |
| - // There is no token for activated color on nav list. |
60 |
| - // TODO(mmalerba): Add a token to MDC or make a custom one. |
61 |
| - .mat-mdc-list-base.mat-mdc-list-base { |
62 |
| - @include evolution-mixins.list-selected-ink-color(inspection.get-theme-color($theme, primary)); |
63 |
| - } |
| 58 | + .mat-mdc-list-option { |
| 59 | + @include mdc-checkbox-theme.theme(tokens-mdc-checkbox.get-color-tokens($theme, primary)); |
| 60 | + } |
| 61 | + .mat-mdc-list-option.mat-accent { |
| 62 | + @include mdc-checkbox-theme.theme(tokens-mdc-checkbox.get-color-tokens($theme, accent)); |
| 63 | + } |
| 64 | + .mat-mdc-list-option.mat-warn { |
| 65 | + @include mdc-checkbox-theme.theme(tokens-mdc-checkbox.get-color-tokens($theme, warn)); |
| 66 | + } |
64 | 67 |
|
65 |
| - // TODO(mmalerba): Leaking styles from the old MDC list mixins used in other components can cause |
66 |
| - // opacity issues, so we need this override for now. We can remove it when all Angular Material |
67 |
| - // components stop using the old MDC mixins. |
68 |
| - .mat-mdc-list-base .mdc-list-item--disabled { |
69 |
| - .mdc-list-item__start, |
70 |
| - .mdc-list-item__content, |
71 |
| - .mdc-list-item__end { |
72 |
| - opacity: 1; |
| 68 | + // There is no token for activated color on nav list. |
| 69 | + // TODO(mmalerba): Add a token to MDC or make a custom one. |
| 70 | + .mat-mdc-list-base.mat-mdc-list-base { |
| 71 | + @include evolution-mixins.list-selected-ink-color( |
| 72 | + inspection.get-theme-color($theme, primary)); |
| 73 | + } |
| 74 | + |
| 75 | + // TODO(mmalerba): Leaking styles from the old MDC list mixins used in other components can |
| 76 | + // cause opacity issues, so we need this override for now. We can remove it when all |
| 77 | + // Angular Material components stop using the old MDC mixins. |
| 78 | + .mat-mdc-list-base .mdc-list-item--disabled { |
| 79 | + .mdc-list-item__start, |
| 80 | + .mdc-list-item__content, |
| 81 | + .mdc-list-item__end { |
| 82 | + opacity: 1; |
| 83 | + } |
73 | 84 | }
|
74 | 85 | }
|
75 | 86 | }
|
76 | 87 |
|
77 | 88 | @mixin density($theme) {
|
78 |
| - $density-scale: inspection.get-theme-density($theme); |
79 |
| - $mdc-list-density-tokens: tokens-mdc-list.get-density-tokens($theme); |
80 |
| - |
81 |
| - // Add values for MDC list tokens. |
82 |
| - @include sass-utils.current-selector-or-root() { |
83 |
| - @include mdc-list-theme.theme($mdc-list-density-tokens); |
| 89 | + @if inspection.get-theme-version($theme) == 1 { |
| 90 | + @include _theme-from-tokens(inspection.get-theme-tokens($theme, density)); |
84 | 91 | }
|
| 92 | + @else { |
| 93 | + $density-scale: inspection.get-theme-density($theme); |
| 94 | + $mdc-list-density-tokens: tokens-mdc-list.get-density-tokens($theme); |
85 | 95 |
|
86 |
| - .mdc-list-item__start, |
87 |
| - .mdc-list-item__end { |
88 |
| - @include mdc-radio-theme.theme(tokens-mdc-radio.get-density-tokens($theme)); |
89 |
| - } |
| 96 | + // Add values for MDC list tokens. |
| 97 | + @include sass-utils.current-selector-or-root() { |
| 98 | + @include mdc-list-theme.theme($mdc-list-density-tokens); |
| 99 | + } |
90 | 100 |
|
91 |
| - // TODO(mmalerba): This is added to maintain the same style MDC used prior to the token-based API, |
92 |
| - // to avoid screenshot diffs. We should remove it in favor of following MDC's current style, or |
93 |
| - // add custom tokens for it. |
94 |
| - .mat-mdc-list-item { |
95 |
| - &.mdc-list-item--with-leading-avatar, |
96 |
| - &.mdc-list-item--with-leading-checkbox, |
97 |
| - &.mdc-list-item--with-leading-icon { |
98 |
| - &.mdc-list-item--with-one-line { |
99 |
| - height: map.get(( |
| 101 | + .mdc-list-item__start, |
| 102 | + .mdc-list-item__end { |
| 103 | + @include mdc-radio-theme.theme(tokens-mdc-radio.get-density-tokens($theme)); |
| 104 | + } |
| 105 | + |
| 106 | + // TODO(mmalerba): This is added to maintain the same style MDC used prior to the token-based |
| 107 | + // API, to avoid screenshot diffs. We should remove it in favor of following MDC's current |
| 108 | + // style, or add custom tokens for it. |
| 109 | + .mat-mdc-list-item { |
| 110 | + &.mdc-list-item--with-leading-avatar, |
| 111 | + &.mdc-list-item--with-leading-checkbox, |
| 112 | + &.mdc-list-item--with-leading-icon { |
| 113 | + &.mdc-list-item--with-one-line { |
| 114 | + height: map.get(( |
100 | 115 | 0: 56px,
|
101 | 116 | -1: 52px,
|
102 | 117 | -2: 48px,
|
103 | 118 | -3: 44px,
|
104 | 119 | -4: 40px,
|
105 | 120 | -5: 40px,
|
106 |
| - ), $density-scale); |
107 |
| - } |
| 121 | + ), $density-scale); |
| 122 | + } |
108 | 123 |
|
109 |
| - &.mdc-list-item--with-two-lines { |
110 |
| - height: map.get(( |
| 124 | + &.mdc-list-item--with-two-lines { |
| 125 | + height: map.get(( |
111 | 126 | 0: 72px,
|
112 | 127 | -1: 68px,
|
113 | 128 | -2: 64px,
|
114 | 129 | -3: 60px,
|
115 | 130 | -4: 56px,
|
116 | 131 | -5: 56px,
|
117 |
| - ), $density-scale); |
| 132 | + ), $density-scale); |
| 133 | + } |
118 | 134 | }
|
119 | 135 | }
|
120 | 136 | }
|
121 | 137 | }
|
122 | 138 |
|
123 | 139 | @mixin typography($theme) {
|
124 |
| - $mdc-list-typography-tokens: tokens-mdc-list.get-typography-tokens($theme); |
125 |
| - |
126 |
| - // Add values for MDC list tokens. |
127 |
| - @include sass-utils.current-selector-or-root() { |
128 |
| - @include mdc-list-theme.theme($mdc-list-typography-tokens); |
| 140 | + @if inspection.get-theme-version($theme) == 1 { |
| 141 | + @include _theme-from-tokens(inspection.get-theme-tokens($theme, typography)); |
129 | 142 | }
|
| 143 | + @else { |
| 144 | + $mdc-list-typography-tokens: tokens-mdc-list.get-typography-tokens($theme); |
130 | 145 |
|
131 |
| - // MDC does not have tokens for the subheader. |
132 |
| - // TODO(mmalerba): Discuss with MDC about adding them, or create custom tokens. |
133 |
| - .mdc-list-group__subheader { |
134 |
| - font: inspection.get-theme-typography($theme, subtitle-1, font); |
135 |
| - letter-spacing: inspection.get-theme-typography($theme, subtitle-1, letter-spacing); |
| 146 | + // Add values for MDC list tokens. |
| 147 | + @include sass-utils.current-selector-or-root() { |
| 148 | + @include mdc-list-theme.theme($mdc-list-typography-tokens); |
| 149 | + } |
| 150 | + |
| 151 | + // MDC does not have tokens for the subheader. |
| 152 | + // TODO(mmalerba): Discuss with MDC about adding them, or create custom tokens. |
| 153 | + .mdc-list-group__subheader { |
| 154 | + font: inspection.get-theme-typography($theme, subtitle-1, font); |
| 155 | + letter-spacing: inspection.get-theme-typography($theme, subtitle-1, letter-spacing); |
| 156 | + } |
136 | 157 | }
|
137 | 158 | }
|
138 | 159 |
|
139 | 160 | @mixin theme($theme) {
|
140 | 161 | @include theming.private-check-duplicate-theme-styles($theme, 'mat-list') {
|
141 |
| - @include base($theme); |
142 |
| - @if inspection.theme-has($theme, color) { |
143 |
| - @include color($theme); |
| 162 | + @if inspection.get-theme-version($theme) == 1 { |
| 163 | + @include _theme-from-tokens(inspection.get-theme-tokens($theme)); |
144 | 164 | }
|
145 |
| - @if inspection.theme-has($theme, density) { |
146 |
| - @include density($theme); |
147 |
| - } |
148 |
| - @if inspection.theme-has($theme, typography) { |
149 |
| - @include typography($theme); |
| 165 | + @else { |
| 166 | + @include base($theme); |
| 167 | + @if inspection.theme-has($theme, color) { |
| 168 | + @include color($theme); |
| 169 | + } |
| 170 | + @if inspection.theme-has($theme, density) { |
| 171 | + @include density($theme); |
| 172 | + } |
| 173 | + @if inspection.theme-has($theme, typography) { |
| 174 | + @include typography($theme); |
| 175 | + } |
150 | 176 | }
|
151 | 177 | }
|
152 | 178 | }
|
| 179 | + |
| 180 | +@mixin _theme-from-tokens($tokens) { |
| 181 | + @if ($tokens != ()) { |
| 182 | + @include mdc-list-theme.theme(map.get($tokens, tokens-mdc-list.$prefix)); |
| 183 | + } |
| 184 | +} |
0 commit comments