|
| 1 | +@use 'sass:map'; |
1 | 2 | @use 'sass:meta';
|
2 | 3 | @use '../core/tokens/m2/mat/paginator' as tokens-mat-paginator;
|
3 | 4 | @use '../core/style/sass-utils';
|
|
7 | 8 | @use '../core/tokens/token-utils';
|
8 | 9 | @use '../form-field/form-field-density';
|
9 | 10 |
|
10 |
| -@mixin base($theme) {} |
| 11 | +@mixin base($theme) { |
| 12 | + @if inspection.get-theme-version($theme) == 1 { |
| 13 | + @include _theme-from-tokens(inspection.get-theme-tokens($theme, base)); |
| 14 | + } |
| 15 | + @else {} |
| 16 | +} |
11 | 17 |
|
12 | 18 | @mixin color($theme) {
|
13 |
| - @include sass-utils.current-selector-or-root() { |
14 |
| - @include token-utils.create-token-values(tokens-mat-paginator.$prefix, |
15 |
| - tokens-mat-paginator.get-color-tokens($theme)); |
| 19 | + @if inspection.get-theme-version($theme) == 1 { |
| 20 | + @include _theme-from-tokens(inspection.get-theme-tokens($theme, color)); |
| 21 | + } |
| 22 | + @else { |
| 23 | + @include sass-utils.current-selector-or-root() { |
| 24 | + @include token-utils.create-token-values(tokens-mat-paginator.$prefix, |
| 25 | + tokens-mat-paginator.get-color-tokens($theme)); |
| 26 | + } |
16 | 27 | }
|
17 | 28 | }
|
18 | 29 |
|
19 | 30 | @mixin typography($theme) {
|
20 |
| - @include sass-utils.current-selector-or-root() { |
21 |
| - @include token-utils.create-token-values(tokens-mat-paginator.$prefix, |
22 |
| - tokens-mat-paginator.get-typography-tokens($theme)); |
| 31 | + @if inspection.get-theme-version($theme) == 1 { |
| 32 | + @include _theme-from-tokens(inspection.get-theme-tokens($theme, typography)); |
| 33 | + } |
| 34 | + @else { |
| 35 | + @include sass-utils.current-selector-or-root() { |
| 36 | + @include token-utils.create-token-values(tokens-mat-paginator.$prefix, |
| 37 | + tokens-mat-paginator.get-typography-tokens($theme)); |
| 38 | + } |
23 | 39 | }
|
24 | 40 | }
|
25 | 41 |
|
26 | 42 | @mixin density($theme) {
|
27 |
| - $density-scale: inspection.get-theme-density($theme); |
28 |
| - |
29 |
| - @include sass-utils.current-selector-or-root() { |
30 |
| - @include token-utils.create-token-values(tokens-mat-paginator.$prefix, |
31 |
| - tokens-mat-paginator.get-density-tokens($theme)); |
| 43 | + @if inspection.get-theme-version($theme) == 1 { |
| 44 | + @include _theme-from-tokens(inspection.get-theme-tokens($theme, density)); |
32 | 45 | }
|
| 46 | + @else { |
| 47 | + $density-scale: inspection.get-theme-density($theme); |
33 | 48 |
|
34 |
| - // TODO: this should be done through tokens once the form field has been switched over. |
35 |
| - .mat-mdc-paginator { |
36 |
| - // We need the form field to be narrower in order to fit into the paginator, |
37 |
| - // so we set its density to be -4 or denser. |
38 |
| - @if ((meta.type-of($density-scale) == 'number' and $density-scale >= -4) or |
39 |
| - $density-scale == maximum) { |
40 |
| - @include form-field-density.private-form-field-density(-4); |
| 49 | + @include sass-utils.current-selector-or-root() { |
| 50 | + @include token-utils.create-token-values(tokens-mat-paginator.$prefix, |
| 51 | + tokens-mat-paginator.get-density-tokens($theme)); |
41 | 52 | }
|
42 |
| - @else { |
43 |
| - @include form-field-density.private-form-field-density($density-scale); |
| 53 | + |
| 54 | + // TODO: this should be done through tokens once the form field has been switched over. |
| 55 | + .mat-mdc-paginator { |
| 56 | + // We need the form field to be narrower in order to fit into the paginator, |
| 57 | + // so we set its density to be -4 or denser. |
| 58 | + @if ((meta.type-of($density-scale) == 'number' and $density-scale >= -4) or |
| 59 | + $density-scale == maximum) { |
| 60 | + @include form-field-density.private-form-field-density(-4); |
| 61 | + } |
| 62 | + @else { |
| 63 | + @include form-field-density.private-form-field-density($density-scale); |
| 64 | + } |
44 | 65 | }
|
45 | 66 | }
|
46 | 67 | }
|
47 | 68 |
|
48 | 69 | @mixin theme($theme) {
|
49 | 70 | @include theming.private-check-duplicate-theme-styles($theme, 'mat-paginator') {
|
50 |
| - @include base($theme); |
51 |
| - @if inspection.theme-has($theme, color) { |
52 |
| - @include color($theme); |
53 |
| - } |
54 |
| - @if inspection.theme-has($theme, density) { |
55 |
| - @include density($theme); |
| 71 | + @if inspection.get-theme-version($theme) == 1 { |
| 72 | + @include _theme-from-tokens(inspection.get-theme-tokens($theme)); |
56 | 73 | }
|
57 |
| - @if inspection.theme-has($theme, typography) { |
58 |
| - @include typography($theme); |
| 74 | + @else { |
| 75 | + @include base($theme); |
| 76 | + @if inspection.theme-has($theme, color) { |
| 77 | + @include color($theme); |
| 78 | + } |
| 79 | + @if inspection.theme-has($theme, density) { |
| 80 | + @include density($theme); |
| 81 | + } |
| 82 | + @if inspection.theme-has($theme, typography) { |
| 83 | + @include typography($theme); |
| 84 | + } |
59 | 85 | }
|
60 | 86 | }
|
61 | 87 | }
|
| 88 | + |
| 89 | +@mixin _theme-from-tokens($tokens) { |
| 90 | + @if ($tokens != ()) { |
| 91 | + @include token-utils.create-token-values( |
| 92 | + tokens-mat-paginator.$prefix, map.get($tokens, tokens-mat-paginator.$prefix)); |
| 93 | + } |
| 94 | +} |
0 commit comments