@@ -18,7 +18,6 @@ $prefix: (mat, fab-small);
18
18
// Tokens that can be configured through Angular Material's color theming API.
19
19
@function get-color-tokens ($theme ) {
20
20
$is-dark : inspection .get-theme-type ($theme ) == dark ;
21
- $on-surface : if ($is-dark , #fff , #000 );
22
21
$ripple-opacities : if ($is-dark ,
23
22
mdc-ripple-theme .$light-ink-opacities ,
24
23
mdc-ripple-theme .$dark-ink-opacities
@@ -29,13 +28,13 @@ $prefix: (mat, fab-small);
29
28
foreground- color: inspection .get-theme-color ($theme , foreground , base ),
30
29
31
30
// Color of the element that shows the hover, focus and pressed states.
32
- state- layer- color: $on-surface ,
31
+ state- layer- color: inspection . get-theme-color ( $theme , foreground , base ) ,
33
32
34
33
// Color of the element that shows the hover, focus and pressed states while disabled.
35
- disabled- state- layer- color: $on-surface ,
34
+ disabled- state- layer- color: inspection . get-theme-color ( $theme , foreground , base ) ,
36
35
37
36
// Color of the ripple element.
38
- ripple- color: rgba ( $on-surface , 0.1 ),
37
+ ripple- color: inspection . get-theme-color ( $theme , foreground , base , 0.1 ),
39
38
40
39
// Opacity of the ripple when the button is hovered.
41
40
hover- state- layer- opacity: map .get ($ripple-opacities , hover ),
@@ -48,24 +47,42 @@ $prefix: (mat, fab-small);
48
47
49
48
// MDC doesn't have tokens for disabled FABs so we need to implemented them ourselves.
50
49
// Background color of the container when the FAB is disabled.
51
- disabled- state- container- color: rgba ($on-surface , 0.12 ),
50
+ disabled- state- container- color: inspection .get-theme-color ($theme , background , disabled-button ,
51
+ 0.12 ),
52
52
53
53
// Color of the icons and projected text when the FAB is disabled.
54
- disabled- state- foreground- color: rgba ($on-surface , if ($is-dark , 0.5 , 0.38 )),
54
+ disabled- state- foreground- color: inspection .get-theme-color ($theme , foreground , disabled-button ,
55
+ if ($is-dark , 0.5 , 0.38 )),
55
56
);
56
57
}
57
58
58
59
// Generates the mapping for the properties that change based on the FAB palette color.
59
60
@function private-get-color-palette-color-tokens ($theme , $palette-name ) {
60
- $is-dark : inspection .get-theme-type ($theme ) == dark ;
61
- $container-color : inspection .get-theme-color ($theme , $palette-name );
62
- $contrast-tone : mdc-helpers .variable-safe-contrast-tone ($container-color , $is-dark );
63
- $color : if ($contrast-tone == ' dark' , #000 , #fff );
61
+ // Ideally we would derive all values directly from the theme, but it causes a lot of regressions
62
+ // internally. For now we fall back to the old hardcoded behavior only for internal apps.
63
+ $foreground-color : null;
64
+ $state-layer-color : null;
65
+ $ripple-color : null;
66
+
67
+ @if (token-utils .$private-is-internal-build ) {
68
+ $is-dark : inspection .get-theme-type ($theme ) == dark ;
69
+ $container-color : inspection .get-theme-color ($theme , $palette-name );
70
+ $contrast-tone : mdc-helpers .variable-safe-contrast-tone ($container-color , $is-dark );
71
+ $color : if ($contrast-tone == ' dark' , #000 , #fff );
72
+ $foreground-color : $color ;
73
+ $state-layer-color : $color ;
74
+ $ripple-color : rgba ($color , 0.1 );
75
+ }
76
+ @else {
77
+ $foreground-color : inspection .get-theme-color ($theme , $palette-name , default-contrast , 1 );
78
+ $state-layer-color : inspection .get-theme-color ($theme , $palette-name , default-contrast , 1 );
79
+ $ripple-color : inspection .get-theme-color ($theme , $palette-name , default-contrast , 0.1 );
80
+ }
64
81
65
82
@return (
66
- foreground- color: $color ,
67
- state- layer- color: $color ,
68
- ripple- color: rgba ( $ color, 0.1 ) ,
83
+ foreground- color: $foreground- color ,
84
+ state- layer- color: $state-layer- color ,
85
+ ripple- color: $ripple- color ,
69
86
);
70
87
}
71
88
0 commit comments