Skip to content

Commit d796776

Browse files
devversionjosephperrott
authored andcommitted
feat(ripple): no longer require additional setup when using MatRipple directive (#11913)
1 parent 9a191b3 commit d796776

File tree

10 files changed

+32
-13
lines changed

10 files changed

+32
-13
lines changed

src/lib/button-toggle/button-toggle.scss

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ $mat-button-toggle-border-radius: 2px !default;
9393
}
9494
}
9595

96-
.mat-button-toggle-ripple {
96+
// Increase specificity because ripple styles are part of the `mat-core` mixin and can
97+
// potentially overwrite the absolute position of the container.
98+
.mat-button-toggle .mat-button-toggle-ripple {
9799
@include mat-fill;
98100

99101
// Disable pointer events for the ripple container, because the container will overlay the user

src/lib/button/button.scss

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,11 @@
7575
}
7676
}
7777

78-
// The ripple container should match the bounds of the entire button.
79-
.mat-button-ripple, .mat-button-focus-overlay {
78+
// The ripple container and focus overlay should match the bounds of the entire button.
79+
// Increase specificity for the ripple container because ripple styles are part of
80+
// the `mat-core` mixin and can potentially overwrite the absolute position of the container.
81+
.mat-button-ripple.mat-ripple,
82+
.mat-button-focus-overlay {
8083
@include mat-fill;
8184

8285
// Disable pointer events for the ripple container and focus overlay because the container

src/lib/checkbox/checkbox.scss

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,9 @@ $_mat-checkbox-mark-stroke-size: 2 / 15 * $mat-checkbox-size !default;
431431
left: 50%;
432432
}
433433

434-
.mat-checkbox-ripple {
434+
// Increase specificity because ripple styles are part of the `mat-core` mixin and can
435+
// potentially overwrite the absolute position of the container.
436+
.mat-checkbox .mat-checkbox-ripple {
435437
position: absolute;
436438
left: calc(50% - #{$_mat-checkbox-ripple-radius});
437439
top: calc(50% - #{$_mat-checkbox-ripple-radius});

src/lib/core/option/option.scss

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@
5858
text-overflow: ellipsis;
5959
}
6060

61-
.mat-option-ripple {
61+
// Increase specificity because ripple styles are part of the `mat-core` mixin and can
62+
// potentially overwrite the absolute position of the container.
63+
.mat-option .mat-option-ripple {
6264
@include mat-fill;
6365

6466
// Disable pointer events for the ripple container because the container will overlay the

src/lib/core/ripple/_ripple.scss

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,15 @@
44
$mat-ripple-color-opacity: 0.1;
55

66
@mixin mat-ripple() {
7+
78
// The host element of an mat-ripple directive should always have a position of "absolute" or
8-
// "relative" so that the ripple divs it creates inside itself are correctly positioned.
9+
// "relative" so that the ripples inside are correctly positioned relatively to the container.
910
.mat-ripple {
1011
overflow: hidden;
12+
13+
// By default, every ripple container should have position: relative in favor of creating an
14+
// easy API for developers using the MatRipple directive.
15+
position: relative;
1116
}
1217

1318
.mat-ripple.mat-ripple-unbounded {

src/lib/menu/menu.scss

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ button.mat-menu-item {
8383
width: 100%;
8484
}
8585

86-
.mat-menu-ripple {
86+
// Increase specificity because ripple styles are part of the `mat-core` mixin and can
87+
// potentially overwrite the absolute position of the container.
88+
.mat-menu-item .mat-menu-ripple {
8789
@include mat-fill;
8890

8991
// Prevent any pointer events on the ripple container for a menu item. The ripple container is

src/lib/radio/radio.scss

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,9 @@ $mat-radio-ripple-radius: 25px;
115115
cursor: default;
116116
}
117117

118-
.mat-radio-ripple {
118+
// Increase specificity because ripple styles are part of the `mat-core` mixin and can
119+
// potentially overwrite the absolute position of the container.
120+
.mat-radio-button .mat-radio-ripple {
119121
position: absolute;
120122
left: calc(50% - #{$mat-radio-ripple-radius});
121123
top: calc(50% - #{$mat-radio-ripple-radius});

src/lib/slide-toggle/slide-toggle.scss

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,9 @@ $mat-slide-toggle-bar-track-width: $mat-slide-toggle-bar-width - $mat-slide-togg
179179
}
180180

181181
// Ripple positioning for the slide-toggle. Moves the ripple container into the center of the thumb.
182-
.mat-slide-toggle-ripple {
182+
// Increase specificity because ripple styles are part of the `mat-core` mixin and can
183+
// potentially overwrite the absolute position of the container.
184+
.mat-slide-toggle .mat-slide-toggle-ripple {
183185
position: absolute;
184186
top: calc(50% - #{$mat-slide-toggle-ripple-radius});
185187
left: calc(50% - #{$mat-slide-toggle-ripple-radius});

src/lib/stepper/step-header.scss

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ $mat-step-header-icon-size: 16px !default;
5252
overflow: hidden;
5353
}
5454

55-
.mat-step-header-ripple {
55+
// Increase specificity because ripple styles are part of the `mat-core` mixin and can
56+
// potentially overwrite the absolute position of the container.
57+
.mat-step-header .mat-step-header-ripple {
5658
@include mat-fill;
5759
pointer-events: none;
5860
}

src/material-examples/ripple-overview/ripple-overview-example.css

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
.example-ripple-container {
2-
/** Necessary until: https://github.com/angular/material2/pull/11913*/
3-
position: relative;
4-
52
cursor: pointer;
63
text-align: center;
74

0 commit comments

Comments
 (0)