Skip to content

Commit d39d8fd

Browse files
committed
fix(material/core): fix opacity in elevation mixin
1 parent abc4940 commit d39d8fd

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/material/core/style/_elevation.scss

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,25 +43,30 @@ $prefix: 'mat-elevation-z';
4343
@else {
4444
// Copied from @material/elevation/_elevation-theme.scss#_box-shadow
4545
// TODO(mmalerba): Add support for graceful handling of CSS var color to MDC.
46-
$shadow-color:
47-
if(meta.type-of($color) == color and $opacity != null, rgba($color, $opacity), $color);
4846
$umbra-z-value: map.get(mdc-elevation.$umbra-map, $zValue);
4947
$penumbra-z-value: map.get(mdc-elevation.$penumbra-map, $zValue);
5048
$ambient-z-value: map.get(mdc-elevation.$ambient-map, $zValue);
49+
50+
$color-opacity: if($opacity != null, $opacity, 1);
51+
$umbra-color: rgba($color, mdc-elevation.$umbra-opacity * $color-opacity);
52+
$penumbra-color: rgba($color, mdc-elevation.$penumbra-opacity * $color-opacity);
53+
$ambient-color: rgba($color, mdc-elevation.$ambient-opacity * $color-opacity);
54+
5155
$box-shadow: (
52-
#{'#{$umbra-z-value} #{$shadow-color}'},
53-
#{'#{$penumbra-z-value} #{$shadow-color}'},
54-
#{$ambient-z-value} $shadow-color
56+
#{'#{$umbra-z-value} #{$umbra-color}'},
57+
#{'#{$penumbra-z-value} #{$penumbra-color}'},
58+
#{$ambient-z-value} $ambient-color
5559
);
60+
5661
@include mdc-elevation.shadow($box-shadow);
5762
}
5863
}
5964

6065
// Applies the elevation to an element in a manner that allows
6166
// consumers to override it via the Material elevation classes.
62-
@mixin overridable-elevation($zValue, $color: $color) {
67+
@mixin overridable-elevation($zValue, $color: $color, $opacity: null) {
6368
&:not([class*='#{$prefix}']) {
64-
@include elevation($zValue, $color);
69+
@include elevation($zValue, $color, $opacity);
6570
}
6671
}
6772

0 commit comments

Comments
 (0)