|
| 1 | +@use 'sass:map'; |
| 2 | +@use '@material/elevation/elevation-theme' as mdc-elevation; |
| 3 | + |
| 4 | +// Prefix for elevation-related selectors. |
| 5 | +$prefix: 'mat-mdc-elevation-z'; |
| 6 | + |
| 7 | +// The default color for elevation shadows. |
| 8 | +$color: black !default; |
| 9 | + |
| 10 | +// Applies the correct css rules to an element to give it the elevation specified by $zValue. |
| 11 | +// The $zValue must be between 0 and 24. |
| 12 | +@mixin elevation($zValue, $color: $color) { |
| 13 | + @include mdc-elevation.elevation($zValue, $color); |
| 14 | +} |
| 15 | + |
| 16 | +// Applies the elevation to an element in a manner that allows |
| 17 | +// consumers to override it via the Material elevation classes. |
| 18 | +@mixin overridable-elevation($zValue, $color: $color) { |
| 19 | + &:not([class*='#{$prefix}']) { |
| 20 | + @include elevation($zValue, $color); |
| 21 | + } |
| 22 | +} |
| 23 | + |
| 24 | +@mixin private-theme-elevation($zValue, $config) { |
| 25 | + @debug $config; |
| 26 | + $foreground: map.get($config, foreground); |
| 27 | + $elevation-color: map.get($foreground, elevation); |
| 28 | + $elevation-color-or-default: if($elevation-color == null, $color, $elevation-color); |
| 29 | + |
| 30 | + @include elevation($zValue, $elevation-color-or-default); |
| 31 | +} |
| 32 | + |
| 33 | +@mixin private-theme-overridable-elevation($zValue, $config) { |
| 34 | + $foreground: map.get($config, foreground); |
| 35 | + $elevation-color: map.get($foreground, elevation); |
| 36 | + $elevation-color-or-default: if($elevation-color == null, $color, $elevation-color); |
| 37 | + |
| 38 | + @include overridable-elevation($zValue, $elevation-color-or-default); |
| 39 | +} |
0 commit comments