@@ -12,8 +12,20 @@ $overlay-backdrop-color: rgba(0, 0, 0, 0.32) !default;
12
12
$backdrop-animation-duration : 400ms !default ;
13
13
$backdrop-animation-timing-function : cubic-bezier (0.25 , 0.8 , 0.25 , 1 ) !default ;
14
14
15
- /// Emits structural styles required for cdk/overlay to function.
16
- @mixin overlay () {
15
+ // Conditionally wraps some styles in a layer depending on a flag.
16
+ @mixin _conditional-layer ($should-wrap ) {
17
+ @if ($should-wrap ) {
18
+ @layer cdk-overlay {
19
+ @content ;
20
+ }
21
+ } @else {
22
+ @content ;
23
+ }
24
+ }
25
+
26
+ // Structural styles for the overlay. Pass `$wrap-customizable-styles` to emit
27
+ // the styles that support customization in a way that makes them easier to change.
28
+ @mixin private-overlay-structure ($wrap-customizable-styles ) {
17
29
.cdk-overlay-container , .cdk-global-overlay-wrapper {
18
30
// Disable events from being captured on the overlay container.
19
31
pointer-events : none ;
@@ -28,7 +40,10 @@ $backdrop-animation-timing-function: cubic-bezier(0.25, 0.8, 0.25, 1) !default;
28
40
// The overlay-container is an invisible element which contains all individual overlays.
29
41
.cdk-overlay-container {
30
42
position : fixed ;
31
- z-index : $overlay-container-z-index ;
43
+
44
+ @include _conditional-layer ($wrap-customizable-styles ) {
45
+ z-index : $overlay-container-z-index ;
46
+ }
32
47
33
48
& :empty {
34
49
// Hide the element when it doesn't have any child nodes. This doesn't
@@ -44,7 +59,10 @@ $backdrop-animation-timing-function: cubic-bezier(0.25, 0.8, 0.25, 1) !default;
44
59
.cdk-global-overlay-wrapper {
45
60
display : flex ;
46
61
position : absolute ;
47
- z-index : $overlay-z-index ;
62
+
63
+ @include _conditional-layer ($wrap-customizable-styles ) {
64
+ z-index : $overlay-z-index ;
65
+ }
48
66
}
49
67
50
68
// A single overlay pane.
@@ -54,13 +72,16 @@ $backdrop-animation-timing-function: cubic-bezier(0.25, 0.8, 0.25, 1) !default;
54
72
position : absolute ;
55
73
pointer-events : auto ;
56
74
box-sizing : border-box ;
57
- z-index : $overlay-z-index ;
58
75
59
76
// For connected-position overlays, we set `display: flex` in
60
77
// order to force `max-width` and `max-height` to take effect.
61
78
display : flex ;
62
79
max-width : 100% ;
63
80
max-height : 100% ;
81
+
82
+ @include _conditional-layer ($wrap-customizable-styles ) {
83
+ z-index : $overlay-z-index ;
84
+ }
64
85
}
65
86
66
87
.cdk-overlay-backdrop {
@@ -71,11 +92,14 @@ $backdrop-animation-timing-function: cubic-bezier(0.25, 0.8, 0.25, 1) !default;
71
92
left : 0 ;
72
93
right : 0 ;
73
94
74
- z-index : $overlay-backdrop-z-index ;
75
95
pointer-events : auto ;
76
96
-webkit-tap-highlight-color : transparent ;
77
- transition : opacity $backdrop-animation-duration $backdrop-animation-timing-function ;
78
97
opacity : 0 ;
98
+
99
+ @include _conditional-layer ($wrap-customizable-styles ) {
100
+ z-index : $overlay-backdrop-z-index ;
101
+ transition : opacity $backdrop-animation-duration $backdrop-animation-timing-function ;
102
+ }
79
103
}
80
104
81
105
.cdk-overlay-backdrop-showing {
@@ -84,16 +108,17 @@ $backdrop-animation-timing-function: cubic-bezier(0.25, 0.8, 0.25, 1) !default;
84
108
// Note that we can't import and use the `high-contrast` mixin from `_a11y.scss`, because
85
109
// this file will be copied to the top-level `cdk` package when putting together the files
86
110
// for npm. Any relative import paths we use here will become invalid once the file is copied.
87
- .cdk-high-contrast-active & {
111
+ @media ( forced-colors : active ) {
88
112
// In high contrast mode the rgba background will become solid
89
113
// so we need to fall back to making it opaque using `opacity`.
90
114
opacity : 0.6 ;
91
115
}
92
116
}
93
117
94
118
.cdk-overlay-dark-backdrop {
95
- // Add a CSS variable to make this easier to override.
96
- background : var (--cdk-overlay-backdrop-dark-color , $overlay-backdrop-color );
119
+ @include _conditional-layer ($wrap-customizable-styles ) {
120
+ background : $overlay-backdrop-color ;
121
+ }
97
122
}
98
123
99
124
.cdk-overlay-transparent-backdrop {
@@ -121,7 +146,6 @@ $backdrop-animation-timing-function: cubic-bezier(0.25, 0.8, 0.25, 1) !default;
121
146
// overlay element's size to fit within the viewport.
122
147
.cdk-overlay-connected-position-bounding-box {
123
148
position : absolute ;
124
- z-index : $overlay-z-index ;
125
149
126
150
// We use `display: flex` on this element exclusively for centering connected overlays.
127
151
// When *not* centering, a top/left/bottom/right will be set which overrides the normal
@@ -135,6 +159,10 @@ $backdrop-animation-timing-function: cubic-bezier(0.25, 0.8, 0.25, 1) !default;
135
159
// Add some dimensions so the element has an `innerText` which some people depend on in tests.
136
160
min-width : 1px ;
137
161
min-height : 1px ;
162
+
163
+ @include _conditional-layer ($wrap-customizable-styles ) {
164
+ z-index : $overlay-z-index ;
165
+ }
138
166
}
139
167
140
168
// Used when disabling global scrolling.
@@ -152,3 +180,8 @@ $backdrop-animation-timing-function: cubic-bezier(0.25, 0.8, 0.25, 1) !default;
152
180
overflow-y : scroll ;
153
181
}
154
182
}
183
+
184
+ /// Emits structural styles required for cdk/overlay to function.
185
+ @mixin overlay {
186
+ @include private-overlay-structure (false);
187
+ }
0 commit comments