@@ -18,7 +18,6 @@ $prefix: (mat, fab-small);
1818// Tokens that can be configured through Angular Material's color theming API.
1919@function get-color-tokens ($theme ) {
2020 $is-dark : inspection .get-theme-type ($theme ) == dark ;
21- $on-surface : if ($is-dark , #fff , #000 );
2221 $ripple-opacities : if ($is-dark ,
2322 mdc-ripple-theme .$light-ink-opacities ,
2423 mdc-ripple-theme .$dark-ink-opacities
@@ -29,13 +28,13 @@ $prefix: (mat, fab-small);
2928 foreground- color: inspection .get-theme-color ($theme , foreground , base ),
3029
3130 // 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 ) ,
3332
3433 // 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 ) ,
3635
3736 // 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 ),
3938
4039 // Opacity of the ripple when the button is hovered.
4140 hover- state- layer- opacity: map .get ($ripple-opacities , hover ),
@@ -48,24 +47,42 @@ $prefix: (mat, fab-small);
4847
4948 // MDC doesn't have tokens for disabled FABs so we need to implemented them ourselves.
5049 // 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 ),
5252
5353 // 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 )),
5556 );
5657}
5758
5859// Generates the mapping for the properties that change based on the FAB palette color.
5960@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+ }
6481
6582 @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 ,
6986 );
7087}
7188
0 commit comments