Skip to content

fix(button): allow for elevation to be overwritten #7305

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 1 commit into from
Sep 29, 2017
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
8 changes: 4 additions & 4 deletions src/lib/button/_button-base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ $mat-mini-fab-padding: 8px !default;
%mat-raised-button {
@extend %mat-button-base;

@include mat-elevation(2);
@include mat-overridable-elevation(2);

// Force hardware acceleration.
transform: translate3d(0, 0, 0);
Expand All @@ -76,7 +76,7 @@ $mat-mini-fab-padding: 8px !default;
mat-elevation-transition-property-value();

&:not([disabled]):active {
@include mat-elevation(8);
@include mat-overridable-elevation(8);
}

&[disabled] {
Expand All @@ -88,7 +88,7 @@ $mat-mini-fab-padding: 8px !default;
@mixin mat-fab($size, $padding) {
@extend %mat-raised-button;

@include mat-elevation(6);
@include mat-overridable-elevation(6);

// Reset the min-width from the button base.
min-width: 0;
Expand All @@ -101,7 +101,7 @@ $mat-mini-fab-padding: 8px !default;
flex-shrink: 0;

&:not([disabled]):active {
@include mat-elevation(12);
@include mat-overridable-elevation(12);
}

.mat-button-wrapper {
Expand Down
5 changes: 1 addition & 4 deletions src/lib/card/card.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,12 @@ $mat-card-header-size: 40px !default;

.mat-card {
@include mat-elevation-transition;
@include mat-overridable-elevation(2);
display: block;
position: relative;
padding: $mat-card-default-padding;
border-radius: $mat-card-border-radius;

&:not([class*='mat-elevation-z']) {
@include mat-elevation(2);
}

@include cdk-high-contrast {
outline: solid 1px;
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/core/_core.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
// `mat-elevation-z$zValue` where `$zValue` corresponds to the z-space to which the element is
// elevated.
@for $zValue from 0 through 24 {
.mat-elevation-z#{$zValue} {
.#{$_mat-elevation-prefix}#{$zValue} {
@include mat-elevation($zValue);
}
}
Expand Down
11 changes: 11 additions & 0 deletions src/lib/core/style/_elevation.scss
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ $mat-elevation-transition-duration: 280ms !default;
// The default easing value for elevation transitions.
$mat-elevation-transition-timing-function: $mat-fast-out-slow-in-timing-function;

// Prefix for elevation-related selectors.
$_mat-elevation-prefix: 'mat-elevation-z';

// Applies the correct css rules to an element to give it the elevation specified by $zValue.
// The $zValue must be between 0 and 24.
@mixin mat-elevation($zValue) {
Expand All @@ -141,6 +144,14 @@ $mat-elevation-transition-timing-function: $mat-fast-out-slow-in-timing-function
#{map-get($_ambient-elevation-map, $zValue)};
}

// Applies the elevation to an element in a manner that allows
// consumers to override it via the Material elevation classes.
@mixin mat-overridable-elevation($zValue) {
&:not([class*='#{$_mat-elevation-prefix}']) {
@include mat-elevation($zValue);
}
}

// Returns a string that can be used as the value for a transition property for elevation.
// Calling this function directly is useful in situations where a component needs to transition
// more than one property.
Expand Down
7 changes: 1 addition & 6 deletions src/lib/core/style/_menu-common.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,9 @@ $mat-menu-icon-margin: 16px !default;


@mixin mat-menu-base($default-elevation) {
@include mat-overridable-elevation($default-elevation);
min-width: $mat-menu-overlay-min-width;
max-width: $mat-menu-overlay-max-width;

// Allow elevation to be overwritten.
&:not([class*='mat-elevation-z']) {
@include mat-elevation($default-elevation);
}

overflow: auto;
-webkit-overflow-scrolling: touch; // for momentum scroll on mobile
}
Expand Down
5 changes: 1 addition & 4 deletions src/lib/expansion/expansion-panel.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@

.mat-expansion-panel {
@include mat-elevation-transition;
@include mat-overridable-elevation(2);
box-sizing: content-box;
display: block;
margin: 0;
transition: margin 225ms $mat-fast-out-slow-in-timing-function;

&:not([class*='mat-elevation-z']) {
@include mat-elevation(2);
}
}

.mat-expansion-panel-content {
Expand Down