Skip to content

Commit e377208

Browse files
committed
fix(button): allow for elevation to be overwritten
Allows for the consumer to set the button elevation through the elevation classes, similarly to the menu, card and expansion components. Fixes #7264.
1 parent 3571f68 commit e377208

File tree

6 files changed

+15
-8
lines changed

6 files changed

+15
-8
lines changed

src/lib/button/_button-base.scss

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ $mat-mini-fab-padding: 8px !default;
6666
%mat-raised-button {
6767
@extend %mat-button-base;
6868

69-
@include mat-elevation(2);
69+
&:not([class*='#{$_mat-elevation-prefix}']) {
70+
@include mat-elevation(2);
71+
}
7072

7173
// Force hardware acceleration.
7274
transform: translate3d(0, 0, 0);
@@ -75,7 +77,7 @@ $mat-mini-fab-padding: 8px !default;
7577
transition: background $swift-ease-out-duration $swift-ease-out-timing-function,
7678
mat-elevation-transition-property-value();
7779

78-
&:not([disabled]):active {
80+
&:not([disabled]):not([class*='#{$_mat-elevation-prefix}']):active {
7981
@include mat-elevation(8);
8082
}
8183

@@ -88,7 +90,9 @@ $mat-mini-fab-padding: 8px !default;
8890
@mixin mat-fab($size, $padding) {
8991
@extend %mat-raised-button;
9092

91-
@include mat-elevation(6);
93+
&:not([class*='#{$_mat-elevation-prefix}']) {
94+
@include mat-elevation(6);
95+
}
9296

9397
// Reset the min-width from the button base.
9498
min-width: 0;
@@ -100,7 +104,7 @@ $mat-mini-fab-padding: 8px !default;
100104

101105
flex-shrink: 0;
102106

103-
&:not([disabled]):active {
107+
&:not([disabled]):not([class*='#{$_mat-elevation-prefix}']):active {
104108
@include mat-elevation(12);
105109
}
106110

src/lib/card/card.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ $mat-card-header-size: 40px !default;
1515
padding: $mat-card-default-padding;
1616
border-radius: $mat-card-border-radius;
1717

18-
&:not([class*='mat-elevation-z']) {
18+
&:not([class*='#{$_mat-elevation-prefix}']) {
1919
@include mat-elevation(2);
2020
}
2121

src/lib/core/_core.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
// `mat-elevation-z$zValue` where `$zValue` corresponds to the z-space to which the element is
2020
// elevated.
2121
@for $zValue from 0 through 24 {
22-
.mat-elevation-z#{$zValue} {
22+
.#{$_mat-elevation-prefix}#{$zValue} {
2323
@include mat-elevation($zValue);
2424
}
2525
}

src/lib/core/style/_elevation.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ $mat-elevation-transition-duration: 280ms !default;
126126
// The default easing value for elevation transitions.
127127
$mat-elevation-transition-timing-function: $mat-fast-out-slow-in-timing-function;
128128

129+
// Prefix for elevation-related selectors.
130+
$_mat-elevation-prefix: 'mat-elevation-z';
131+
129132
// Applies the correct css rules to an element to give it the elevation specified by $zValue.
130133
// The $zValue must be between 0 and 24.
131134
@mixin mat-elevation($zValue) {

src/lib/core/style/_menu-common.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ $mat-menu-icon-margin: 16px !default;
1818
max-width: $mat-menu-overlay-max-width;
1919

2020
// Allow elevation to be overwritten.
21-
&:not([class*='mat-elevation-z']) {
21+
&:not([class*='#{$_mat-elevation-prefix}']) {
2222
@include mat-elevation($default-elevation);
2323
}
2424

src/lib/expansion/expansion-panel.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
margin: 0;
99
transition: margin 225ms $mat-fast-out-slow-in-timing-function;
1010

11-
&:not([class*='mat-elevation-z']) {
11+
&:not([class*='#{$_mat-elevation-prefix}']) {
1212
@include mat-elevation(2);
1313
}
1414
}

0 commit comments

Comments
 (0)