Skip to content

Commit b104e75

Browse files
devversionvivian-hu-zz
authored andcommittedNov 8, 2018
fix(button): ripple color not correct for standard, icon and stroked buttons (#13235)
With c3a8d0c, we already ensured that the text color is **inherited** in order to make sure that buttons without a background color are readable on various themed backgrounds (e.g. themed toolbars) This is a follow-up that ensures that the ripple color for such transparent buttons is contrasting to the background color (e.g. in themed toolbars). Fixes #13232
1 parent caf65e5 commit b104e75

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed
 

‎src/demo-app/toolbar/toolbar-demo.html

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<span>Default Toolbar</span>
99
<span class="demo-fill-remaining"></span>
1010

11+
<button mat-button color="accent">Text</button>
1112
<button mat-button>Text</button>
1213
<button mat-icon-button>
1314
<mat-icon>code</mat-icon>

‎src/lib/button/_button-theme.scss

+10-10
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
@import '../core/style/elevation';
33
@import '../core/typography/typography-utils';
44

5+
$_mat-button-ripple-opacity: 0.1;
6+
57
// Applies a focus style to an mat-button element for each of the supported palettes.
68
@mixin _mat-button-focus-overlay-color($theme) {
79
$primary: map-get($theme, primary);
@@ -25,7 +27,7 @@
2527
}
2628
}
2729

28-
@mixin _mat-button-ripple-color($theme, $hue, $opacity: 0.1) {
30+
@mixin _mat-button-ripple-color($theme, $hue, $opacity: $_mat-button-ripple-opacity) {
2931
$primary: map-get($theme, primary);
3032
$accent: map-get($theme, accent);
3133
$warn: map-get($theme, warn);
@@ -87,9 +89,13 @@
8789
@include _mat-button-theme-property($theme, 'color', default);
8890
@include _mat-button-focus-overlay-color($theme);
8991

90-
// Setup the ripple color to be based on the color palette. The opacity can be a bit weaker
91-
// than for icon-buttons, because normal and stroked buttons have a focus overlay.
92-
@include _mat-button-ripple-color($theme, default);
92+
// Setup the ripple color to be based on the text color. This ensures that the ripples
93+
// are matching with the current theme palette and are in contrast to the background color
94+
// (e.g in themed toolbars).
95+
.mat-ripple-element {
96+
opacity: $_mat-button-ripple-opacity;
97+
background-color: currentColor;
98+
}
9399
}
94100

95101
.mat-button-focus-overlay {
@@ -112,12 +118,6 @@
112118
@include _mat-button-ripple-color($theme, default-contrast);
113119
}
114120

115-
// Since icon buttons don't have a focus overlay, the ripple opacity should be the higher
116-
// than the default value.
117-
.mat-icon-button {
118-
@include _mat-button-ripple-color($theme, default, 0.2);
119-
}
120-
121121
.mat-stroked-button, .mat-flat-button {
122122
@include _mat-theme-overridable-elevation(0, $theme);
123123
}

0 commit comments

Comments
 (0)
Please sign in to comment.