1
+ @use ' sass:map' ;
2
+ @use ' @material/ripple/ripple-theme' as mdc-ripple-theme ;
1
3
@use ' @material/theme/theme-color' as mdc-theme-color ;
2
- @use ' @material/theme/theme' as mdc-theme ;
3
4
@use ' ../../material/core/ripple/ripple-theme' ;
4
5
5
- // Selector for the element that has a background color and opacity applied to its ::before and
6
- // ::after for state interactions (hover, active, focus). Their API calls this their
7
- // "ripple target", but we do not use it as our ripple, just state color.
8
- $button-state-target : ' .mdc-button__ripple' ;
9
- $fab-state-target : ' .mdc-fab__ripple' ;
10
-
11
- // The MDC button's ripple ink color is based on the theme color, not on the foreground base
12
- // which is what the ripple mixin uses. This creates a new theme that sets the color to the
13
- // foreground base to appropriately color the ink.
14
- @mixin ripple-ink-color ($mdc-color ) {
15
- @include ripple-theme .color ((
16
- foreground: (
17
- base: mdc-theme-color .prop-value ($mdc-color )
18
- ),
19
- ));
6
+ @mixin _ripple-color ($color ) {
7
+ --mat-mdc-button-persistent-ripple-color : #{$color } ;
8
+ --mat-mdc-button-ripple-color : #{rgba ($color , 0.1 )} ;
20
9
}
21
10
22
- // Applies the disabled theme color to the text color.
23
- @mixin apply-disabled-color () {
24
- @include mdc-theme .prop (color ,
25
- mdc-theme-color .ink-color-for-fill_ (disabled , mdc-theme-color .$background ));
11
+ @mixin ripple-theme-styles ($config , $is-filled ) {
12
+ $opacities : if (map .get ($config , is-dark ),
13
+ mdc-ripple-theme .$light-ink-opacities , mdc-ripple-theme .$dark-ink-opacities );
14
+
15
+ // Ideally these styles would be structural, but MDC bases some of the opacities on the theme.
16
+ & :hover .mat-mdc-button-persistent-ripple ::before {
17
+ opacity : map .get ($opacities , hover );
18
+ }
19
+
20
+ & :focus .mat-mdc-button-persistent-ripple ::before {
21
+ opacity : map .get ($opacities , focus );
22
+ }
23
+
24
+ & :active .mat-mdc-button-persistent-ripple ::before {
25
+ opacity : map .get ($opacities , press );
26
+ }
27
+
28
+ @include _ripple-color (mdc-theme-color .prop-value (on-surface ));
29
+
30
+ & .mat-primary {
31
+ @include _ripple-color (mdc-theme-color .prop-value (if ($is-filled , on-primary , primary )));
32
+ }
33
+
34
+ & .mat-accent {
35
+ @include _ripple-color (mdc-theme-color .prop-value (if ($is-filled , on-secondary , secondary )));
36
+ }
37
+
38
+ & .mat-warn {
39
+ @include _ripple-color (mdc-theme-color .prop-value (if ($is-filled , on-error , error )));
40
+ }
26
41
}
27
42
28
43
// Wraps the content style in a selector for the disabled state.
@@ -37,14 +52,6 @@ $fab-state-target: '.mdc-fab__ripple';
37
52
}
38
53
}
39
54
40
- // Applies the disabled theme background color for raised buttons. Value is taken from
41
- // mixin `mdc-button--filled`.
42
- // TODO(andrewseguin): Discuss with the MDC team about providing a variable for the 0.12 value
43
- // or otherwise have a mixin we can call to apply this style for both button and anchors.
44
- @mixin apply-disabled-background () {
45
- @include mdc-theme .prop (background-color , rgba (mdc-theme-color .prop-value (on-surface ), 0.12 ));
46
- }
47
-
48
55
// Hides the touch target on lower densities.
49
56
@mixin touch-target-density ($scale ) {
50
57
@if ($scale == -2 or $scale == ' minimum' ) {
0 commit comments