|
1 |
| -@use 'sass:map'; |
2 | 1 | @use '@material/fab/fab' as mdc-fab;
|
3 | 2 | @use '@material/fab/fab-theme' as mdc-fab-theme;
|
4 | 3 | @use '@material/fab/extended-fab-theme' as mdc-extended-fab-theme;
|
|
7 | 6 | @use '../core/mdc-helpers/mdc-helpers';
|
8 | 7 | @use '../core/style/sass-utils';
|
9 | 8 | @use '../core/theming/theming';
|
| 9 | +@use '../core/theming/inspection'; |
10 | 10 | @use '../core/tokens/m2/mdc/fab' as tokens-mdc-fab;
|
11 | 11 | @use '../core/tokens/m2/mdc/extended-fab' as tokens-mdc-extended-fab;
|
12 | 12 | @use '../core/typography/typography';
|
13 | 13 |
|
14 |
| -@mixin base($config-or-theme) { |
| 14 | +@mixin base($theme) { |
15 | 15 | // Add default values for tokens not related to color, typography, or density.
|
16 | 16 | @include sass-utils.current-selector-or-root() {
|
17 | 17 | @include mdc-fab-theme.theme(tokens-mdc-fab.get-unthemable-tokens());
|
|
21 | 21 | }
|
22 | 22 | }
|
23 | 23 |
|
24 |
| -@mixin _fab-variant($config, $foreground, $background) { |
25 |
| - $color-config: map.merge( |
26 |
| - $config, |
27 |
| - ( |
28 |
| - primary: ( |
29 |
| - default: $background, |
30 |
| - default-contrast: $foreground, |
31 |
| - ), |
32 |
| - ) |
| 24 | +@mixin _fab-variant($foreground, $background) { |
| 25 | + $color-tokens: ( |
| 26 | + container-color: $background, |
| 27 | + icon-color: $foreground |
33 | 28 | );
|
34 |
| - $color-tokens: tokens-mdc-fab.get-color-tokens($color-config); |
35 | 29 | @include mdc-fab-theme.theme($color-tokens);
|
36 | 30 |
|
37 | 31 | --mat-mdc-fab-color: #{$foreground};
|
|
41 | 35 | @return if(mdc-helpers.variable-safe-contrast-tone($color, $is-dark) == 'dark', #000, #fff);
|
42 | 36 | }
|
43 | 37 |
|
44 |
| -@mixin color($config-or-theme) { |
45 |
| - $config: theming.get-color-config($config-or-theme); |
| 38 | +@mixin color($theme) { |
| 39 | + $is-dark: inspection.get-theme-type($theme) == dark; |
46 | 40 |
|
47 |
| - $is-dark: map.get($config, is-dark); |
48 |
| - $background: map.get($config, background); |
49 |
| - |
50 |
| - $surface: theming.get-color-from-palette($background, card); |
51 |
| - $primary: theming.get-color-from-palette(map.get($config, primary)); |
52 |
| - $accent: theming.get-color-from-palette(map.get($config, accent)); |
53 |
| - $warn: theming.get-color-from-palette(map.get($config, warn)); |
| 41 | + $surface: inspection.get-theme-color($theme, background, card); |
| 42 | + $primary: inspection.get-theme-color($theme, primary); |
| 43 | + $accent: inspection.get-theme-color($theme, accent); |
| 44 | + $warn: inspection.get-theme-color($theme, warn); |
54 | 45 |
|
55 | 46 | $on-surface: white-or-black($surface, $is-dark);
|
56 | 47 | $on-primary: white-or-black($primary, $is-dark);
|
57 | 48 | $on-accent: white-or-black($accent, $is-dark);
|
58 | 49 | $on-warn: white-or-black($warn, $is-dark);
|
59 | 50 |
|
60 | 51 | $disabled: rgba($on-surface, 0.12);
|
61 |
| - $on-disabled: rgba($on-surface, if(map.get($config, is-dark), 0.5, 0.38)); |
| 52 | + $on-disabled: rgba($on-surface, if($is-dark, 0.5, 0.38)); |
62 | 53 |
|
63 | 54 | .mat-mdc-fab,
|
64 | 55 | .mat-mdc-mini-fab {
|
65 | 56 | // TODO(wagnermaciel): The ripple-theme-styles mixin depends heavily on
|
66 | 57 | // being wrapped by using-mdc-theme. This workaround needs to be
|
67 | 58 | // revisited w/ a more holistic solution.
|
68 |
| - @include mdc-helpers.using-mdc-theme($config) { |
69 |
| - @include button-theme-private.ripple-theme-styles($config, true); |
| 59 | + @include mdc-helpers.using-mdc-theme($theme) { |
| 60 | + @include button-theme-private.ripple-theme-styles($theme, true); |
70 | 61 | }
|
71 | 62 |
|
72 | 63 | @include button-theme-private.apply-disabled-style() {
|
73 |
| - @include _fab-variant($config, $on-disabled, $disabled); |
| 64 | + @include _fab-variant($on-disabled, $disabled); |
74 | 65 | }
|
75 | 66 |
|
76 | 67 | &.mat-unthemed {
|
77 |
| - @include _fab-variant($config, $on-surface, $surface); |
| 68 | + @include _fab-variant($on-surface, $surface); |
78 | 69 | }
|
79 | 70 |
|
80 | 71 | &.mat-primary {
|
81 |
| - @include _fab-variant($config, $on-primary, $primary); |
| 72 | + @include _fab-variant($on-primary, $primary); |
82 | 73 | }
|
83 | 74 |
|
84 | 75 | &.mat-accent {
|
85 |
| - @include _fab-variant($config, $on-accent, $accent); |
| 76 | + @include _fab-variant($on-accent, $accent); |
86 | 77 | }
|
87 | 78 |
|
88 | 79 | &.mat-warn {
|
89 |
| - @include _fab-variant($config, $on-warn, $warn); |
| 80 | + @include _fab-variant($on-warn, $warn); |
90 | 81 | }
|
91 | 82 | }
|
92 | 83 | }
|
93 | 84 |
|
94 |
| -@mixin typography($config-or-theme) { |
95 |
| - $config: typography.private-typography-to-2018-config( |
96 |
| - theming.get-typography-config($config-or-theme) |
97 |
| - ); |
98 |
| - |
99 |
| - @include mdc-helpers.using-mdc-typography($config) { |
| 85 | +@mixin typography($theme) { |
| 86 | + @include mdc-helpers.using-mdc-typography($theme) { |
100 | 87 | @include mdc-fab.without-ripple($query: mdc-helpers.$mdc-typography-styles-query);
|
101 | 88 | }
|
102 | 89 |
|
103 |
| - $typography-tokens: tokens-mdc-extended-fab.get-typography-tokens($config); |
| 90 | + $typography-tokens: tokens-mdc-extended-fab.get-typography-tokens($theme); |
104 | 91 | .mat-mdc-extended-fab {
|
105 | 92 | @include mdc-extended-fab-theme.theme($typography-tokens);
|
106 | 93 | }
|
107 | 94 | }
|
108 | 95 |
|
109 |
| -@mixin density($config-or-theme) { |
| 96 | +@mixin density($theme) { |
110 | 97 | }
|
111 | 98 |
|
112 |
| -@mixin theme($theme-or-color-config) { |
113 |
| - $theme: theming.private-legacy-get-theme($theme-or-color-config); |
| 99 | +@mixin theme($theme) { |
114 | 100 | @include theming.private-check-duplicate-theme-styles($theme, 'mat-fab') {
|
115 |
| - $color: theming.get-color-config($theme); |
116 |
| - $density: theming.get-density-config($theme); |
117 |
| - $typography: theming.get-typography-config($theme); |
118 |
| - |
119 | 101 | @include base($theme);
|
120 |
| - @if $color != null { |
121 |
| - @include color($color); |
| 102 | + @if inspection.theme-has($theme, color) { |
| 103 | + @include color($theme); |
122 | 104 | }
|
123 |
| - @if $density != null { |
124 |
| - @include density($density); |
| 105 | + @if inspection.theme-has($theme, density) { |
| 106 | + @include density($theme); |
125 | 107 | }
|
126 |
| - @if $typography != null { |
127 |
| - @include typography($typography); |
| 108 | + @if inspection.theme-has($theme, typography) { |
| 109 | + @include typography($theme); |
128 | 110 | }
|
129 | 111 | }
|
130 | 112 | }
|
0 commit comments