Skip to content

fix(material/chips): fix ripple element opacity when using CSS variable theming #17576

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 3 commits into from
Dec 10, 2019
Merged
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
24 changes: 15 additions & 9 deletions src/material/chips/_chips-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,25 @@ $mat-chip-remove-font-size: 18px;
}
}


// Applies the background color for a ripple element.
// If the color value provided is not a Sass color,
// we assume that we've been given a CSS variable.
// Since we can't perform alpha-blending on a CSS variable,
// we instead add the opacity directly to the ripple element.
@mixin _mat-chips-ripple-background($palette, $default-contrast, $opacity) {
$background-color: mat-color($palette, $default-contrast, $opacity);
background-color: $background-color;
@if (type-of($background-color) != color) {
opacity: $opacity;
}
}

@mixin mat-chips-theme-color($palette) {
@include mat-chips-color(mat-color($palette, default-contrast), mat-color($palette));

.mat-ripple-element {
$ripple-opacity: 0.1;
$ripple-color: mat-color($palette, default-contrast, $ripple-opacity);
background-color: $ripple-color;

// If the ripple color is a CSS variable, `mat-color` will
// return a solid color so we have to apply the opacity separately.
@if (type-of($ripple-color) != color) {
opacity: $ripple-opacity;
}
@include _mat-chips-ripple-background($palette, default-contrast, 0.1);
}
}

Expand Down