Skip to content

feat(ripple): no longer require additional setup when using MatRipple directive #11913

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/lib/button-toggle/button-toggle.scss
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ $mat-button-toggle-border-radius: 2px !default;
}
}

.mat-button-toggle-ripple {
// Increase specificity because ripple styles are part of the `mat-core` mixin and can
// potentially overwrite the absolute position of the container.
.mat-button-toggle .mat-button-toggle-ripple {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider nesting this under the .mat-button-toggle selector. Same goes for the other changed child selectors in this PR.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I considered doing that, but went with that approach because I wanted to separate the ripple stuff as much as I can from the actual component styles.

@include mat-fill;

// Disable pointer events for the ripple container, because the container will overlay the user
Expand Down
7 changes: 5 additions & 2 deletions src/lib/button/button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,11 @@
}
}

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

// Disable pointer events for the ripple container and focus overlay because the container
Expand Down
4 changes: 3 additions & 1 deletion src/lib/checkbox/checkbox.scss
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,9 @@ $_mat-checkbox-mark-stroke-size: 2 / 15 * $mat-checkbox-size !default;
left: 50%;
}

.mat-checkbox-ripple {
// Increase specificity because ripple styles are part of the `mat-core` mixin and can
// potentially overwrite the absolute position of the container.
.mat-checkbox .mat-checkbox-ripple {
position: absolute;
left: calc(50% - #{$_mat-checkbox-ripple-radius});
top: calc(50% - #{$_mat-checkbox-ripple-radius});
Expand Down
4 changes: 3 additions & 1 deletion src/lib/core/option/option.scss
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@
text-overflow: ellipsis;
}

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

// Disable pointer events for the ripple container because the container will overlay the
Expand Down
7 changes: 6 additions & 1 deletion src/lib/core/ripple/_ripple.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@
$mat-ripple-color-opacity: 0.1;

@mixin mat-ripple() {

// The host element of an mat-ripple directive should always have a position of "absolute" or
// "relative" so that the ripple divs it creates inside itself are correctly positioned.
// "relative" so that the ripples inside are correctly positioned relatively to the container.
.mat-ripple {
overflow: hidden;

// By default, every ripple container should have position: relative in favor of creating an
// easy API for developers using the MatRipple directive.
position: relative;
}

.mat-ripple.mat-ripple-unbounded {
Expand Down
4 changes: 3 additions & 1 deletion src/lib/menu/menu.scss
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ button.mat-menu-item {
width: 100%;
}

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

// Prevent any pointer events on the ripple container for a menu item. The ripple container is
Expand Down
4 changes: 3 additions & 1 deletion src/lib/radio/radio.scss
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ $mat-radio-ripple-radius: 25px;
cursor: default;
}

.mat-radio-ripple {
// Increase specificity because ripple styles are part of the `mat-core` mixin and can
// potentially overwrite the absolute position of the container.
.mat-radio-button .mat-radio-ripple {
position: absolute;
left: calc(50% - #{$mat-radio-ripple-radius});
top: calc(50% - #{$mat-radio-ripple-radius});
Expand Down
4 changes: 3 additions & 1 deletion src/lib/slide-toggle/slide-toggle.scss
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,9 @@ $mat-slide-toggle-bar-track-width: $mat-slide-toggle-bar-width - $mat-slide-togg
}

// Ripple positioning for the slide-toggle. Moves the ripple container into the center of the thumb.
.mat-slide-toggle-ripple {
// Increase specificity because ripple styles are part of the `mat-core` mixin and can
// potentially overwrite the absolute position of the container.
.mat-slide-toggle .mat-slide-toggle-ripple {
position: absolute;
top: calc(50% - #{$mat-slide-toggle-ripple-radius});
left: calc(50% - #{$mat-slide-toggle-ripple-radius});
Expand Down
4 changes: 3 additions & 1 deletion src/lib/stepper/step-header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ $mat-step-header-icon-size: 16px !default;
overflow: hidden;
}

.mat-step-header-ripple {
// Increase specificity because ripple styles are part of the `mat-core` mixin and can
// potentially overwrite the absolute position of the container.
.mat-step-header .mat-step-header-ripple {
@include mat-fill;
pointer-events: none;
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
.example-ripple-container {
/** Necessary until: https://github.com/angular/material2/pull/11913*/
position: relative;

cursor: pointer;
text-align: center;

Expand Down