Skip to content

Commit ba623c1

Browse files
committed
docs: add info about custom elevation color johannesjo#4
1 parent 81fb5eb commit ba623c1

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ There are also several [utility functions and mixins](https://github.com/johanne
7878
@include mat-css-bg(300);
7979
}
8080
```
81+
82+
There are also [some additional hacks](additional-hacks.md) (e.g. adding a color to the elevation shadow) available in case you need them.
83+
8184
## Initialization Options
8285
You can provide different options before initialization to change the body class used for the dark theme and to provide different default styles:
8386
```scss

additional-hacks.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
## Custom elevation shadow color
2+
In case you also want to add a color to your shadows, you can include the following mixin directly before you execute `@include initMaterialCssVars();`. Thanks goes to @picc09 for finding this out.
3+
4+
```scss
5+
$mat-css-palette-foreground: map-merge(
6+
// if you don't want to enter ALL the properties
7+
$mat-css-palette-foreground,
8+
(
9+
elevation: var(--your-elevation-color-variable)
10+
// ...
11+
)
12+
);
13+
14+
@mixin mat-elevation($zValue, $color: $mat-elevation-color, $opacity: $mat-elevation-opacity) {
15+
@if type-of($zValue) != number or not unitless($zValue) {
16+
@error '$zValue must be a unitless number';
17+
}
18+
@if $zValue < 0 or $zValue > 24 {
19+
@error '$zValue must be between 0 and 24';
20+
}
21+
22+
$color-umbra: $color;
23+
$color-penumbra: $color;
24+
$color-ambient: $color;
25+
@if type-of($color) != color {
26+
$color-umbra: rgba($color, $opacity * 0.2);
27+
$color-penumbra: rgba($color, $opacity * 0.14);
28+
$color-ambient: rgba($color, $opacity * 0.12);
29+
}
30+
31+
box-shadow: #{map-get(_get-umbra-map($color-umbra, $opacity), $zValue)},
32+
#{map-get(_get-penumbra-map($color-penumbra, $opacity), $zValue)},
33+
#{map-get(_get-ambient-map($color-ambient, $opacity), $zValue)};
34+
}
35+
36+
// finally initialize
37+
@include initMaterialCssVars();
38+
```
39+
40+
In this way you can change `elevation: black` into variables file.

0 commit comments

Comments
 (0)