Skip to content

Commit 9fb92f0

Browse files
authored
refactor(cdk/overlay): clean up variable names (#22359)
This is follow-up from the PR that introduced the theming API migration (#22304 (comment)). It renames a few variables in the CDK to align them with the new API.
1 parent 0c83adc commit 9fb92f0

File tree

6 files changed

+40
-24
lines changed

6 files changed

+40
-24
lines changed

src/cdk/_index.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
@forward './overlay/overlay' show overlay, $z-index-overlay-container, $z-index-overlay,
2-
$z-index-overlay-backdrop, $dark-backdrop-background;
1+
@forward './overlay/overlay' show overlay, $overlay-container-z-index, $overlay-z-index,
2+
$overlay-backdrop-z-index, $overlay-backdrop-color;
33
@forward './a11y/a11y' show a11y-visually-hidden, high-contrast;
44
@forward './text-field/text-field' show text-field-autosize, text-field-autofill,
55
text-field-autofill-color,
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
@use './overlay';
2+
3+
// @deprecated Use `$overlay-container-z-index`.
4+
$z-index-overlay-container: overlay.$overlay-container-z-index;
5+
6+
// @deprecated Use `$overlay-z-index`.
7+
$z-index-overlay: overlay.$overlay-z-index;
8+
9+
// @deprecated Use `$overlay-backdrop-color`.
10+
$dark-backdrop-background: overlay.$overlay-backdrop-color;
11+
12+
// @deprecated Use `$overlay-backdrop-z-index`.
13+
$z-index-overlay-backdrop: overlay.$overlay-backdrop-z-index;

src/cdk/overlay/_overlay.import.scss

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
@forward '../a11y/a11y' as cdk-*;
2-
@forward 'overlay' hide $dark-backdrop-background, $z-index-overlay, $z-index-overlay-backdrop,
3-
$z-index-overlay-container, overlay;
2+
@forward 'overlay' hide $overlay-backdrop-color, $overlay-z-index, $overlay-backdrop-z-index,
3+
$overlay-container-z-index, overlay;
44
@forward 'overlay' as cdk-* hide $cdk-backdrop-animation-duration,
5-
$cdk-backdrop-animation-timing-function, $cdk-dark-backdrop-background;
5+
$cdk-backdrop-animation-timing-function, $cdk-overlay-backdrop-color;
66
@forward 'overlay' as cdk-overlay-* hide $cdk-overlay-backdrop-animation-duration,
7-
$cdk-overlay-backdrop-animation-timing-function, $cdk-overlay-z-index-overlay,
8-
$cdk-overlay-z-index-overlay-backdrop, $cdk-overlay-z-index-overlay-container, cdk-overlay-overlay;
7+
$cdk-overlay-backdrop-animation-timing-function, $cdk-overlay-overlay-z-index,
8+
$cdk-overlay-overlay-backdrop-z-index, $cdk-overlay-overlay-container-z-index,
9+
cdk-overlay-overlay;
10+
@forward './overlay-deprecated' as cdk-*;
11+
@forward './overlay-deprecated' as cdk-overlay-*;
912

1013
@import '../a11y/a11y';

src/cdk/overlay/_overlay.scss

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
// We want overlays to always appear over user content, so set a baseline
22
// very high z-index for the overlay container, which is where we create the new
33
// stacking context for all overlays.
4-
$z-index-overlay-container: 1000 !default;
5-
$z-index-overlay: 1000 !default;
6-
$z-index-overlay-backdrop: 1000 !default;
4+
$overlay-container-z-index: 1000 !default;
5+
$overlay-z-index: 1000 !default;
6+
$overlay-backdrop-z-index: 1000 !default;
77

88
// Background color for all of the backdrops
9-
$dark-backdrop-background: rgba(0, 0, 0, 0.32) !default;
9+
$overlay-backdrop-color: rgba(0, 0, 0, 0.32) !default;
1010

1111
// Default backdrop animation is based on the Material Design swift-ease-out.
1212
$backdrop-animation-duration: 400ms !default;
@@ -28,7 +28,7 @@ $backdrop-animation-timing-function: cubic-bezier(0.25, 0.8, 0.25, 1) !default;
2828
// The overlay-container is an invisible element which contains all individual overlays.
2929
.cdk-overlay-container {
3030
position: fixed;
31-
z-index: $z-index-overlay-container;
31+
z-index: $overlay-container-z-index;
3232

3333
&:empty {
3434
// Hide the element when it doesn't have any child nodes. This doesn't
@@ -44,7 +44,7 @@ $backdrop-animation-timing-function: cubic-bezier(0.25, 0.8, 0.25, 1) !default;
4444
.cdk-global-overlay-wrapper {
4545
display: flex;
4646
position: absolute;
47-
z-index: $z-index-overlay;
47+
z-index: $overlay-z-index;
4848
}
4949

5050
// A single overlay pane.
@@ -54,7 +54,7 @@ $backdrop-animation-timing-function: cubic-bezier(0.25, 0.8, 0.25, 1) !default;
5454
position: absolute;
5555
pointer-events: auto;
5656
box-sizing: border-box;
57-
z-index: $z-index-overlay;
57+
z-index: $overlay-z-index;
5858

5959
// For connected-position overlays, we set `display: flex` in
6060
// order to force `max-width` and `max-height` to take effect.
@@ -71,7 +71,7 @@ $backdrop-animation-timing-function: cubic-bezier(0.25, 0.8, 0.25, 1) !default;
7171
left: 0;
7272
right: 0;
7373

74-
z-index: $z-index-overlay-backdrop;
74+
z-index: $overlay-backdrop-z-index;
7575
pointer-events: auto;
7676
-webkit-tap-highlight-color: transparent;
7777
transition: opacity $backdrop-animation-duration $backdrop-animation-timing-function;
@@ -92,7 +92,7 @@ $backdrop-animation-timing-function: cubic-bezier(0.25, 0.8, 0.25, 1) !default;
9292
}
9393

9494
.cdk-overlay-dark-backdrop {
95-
background: $dark-backdrop-background;
95+
background: $overlay-backdrop-color;
9696
}
9797

9898
.cdk-overlay-transparent-backdrop {
@@ -109,7 +109,7 @@ $backdrop-animation-timing-function: cubic-bezier(0.25, 0.8, 0.25, 1) !default;
109109
// overlay element's size to fit within the viewport.
110110
.cdk-overlay-connected-position-bounding-box {
111111
position: absolute;
112-
z-index: $z-index-overlay;
112+
z-index: $overlay-z-index;
113113

114114
// We use `display: flex` on this element exclusively for centering connected overlays.
115115
// When *not* centering, a top/left/bottom/right will be set which overrides the normal

src/material/schematics/ng-generate/theming-api/index.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ describe('Material theming API schematic', () => {
104104
`@include cdk.overlay();`,
105105
``,
106106
`.my-dialog {`,
107-
`z-index: cdk.$z-index-overlay-container + 1;`,
107+
`z-index: cdk.$overlay-container-z-index + 1;`,
108108
`}`,
109109
``,
110110
`@include cdk.high-contrast(active, off) {`,
@@ -161,7 +161,7 @@ describe('Material theming API schematic', () => {
161161
`@include mat.all-component-themes($candy-app-theme);`,
162162

163163
`.my-dialog {`,
164-
`z-index: cdk.$z-index-overlay-container + 1;`,
164+
`z-index: cdk.$overlay-container-z-index + 1;`,
165165
`}`
166166
]);
167167
});
@@ -284,7 +284,7 @@ describe('Material theming API schematic', () => {
284284
expect(getFileContent(tree, '/components/dialog.scss').split('\n')).toEqual([
285285
`@use '~@angular/cdk' as cdk;`,
286286
`.my-dialog {`,
287-
`z-index: cdk.$z-index-overlay-container + 1;`,
287+
`z-index: cdk.$overlay-container-z-index + 1;`,
288288
`}`,
289289
]);
290290
});

src/material/schematics/ng-generate/theming-api/migration.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ const materialVariables: Record<string, string> = {
7878

7979
/** Mapping of CDK variables that should be renamed. */
8080
const cdkVariables: Record<string, string> = {
81-
'cdk-z-index-overlay-container': 'z-index-overlay-container',
82-
'cdk-z-index-overlay': 'z-index-overlay',
83-
'cdk-z-index-overlay-backdrop': 'z-index-overlay-backdrop',
84-
'cdk-overlay-dark-backdrop-background': 'overlay-dark-backdrop-background',
81+
'cdk-z-index-overlay-container': 'overlay-container-z-index',
82+
'cdk-z-index-overlay': 'overlay-z-index',
83+
'cdk-z-index-overlay-backdrop': 'overlay-backdrop-z-index',
84+
'cdk-overlay-dark-backdrop-background': 'overlay-backdrop-color',
8585
};
8686

8787
/** Mapping of CDK mixins that should be renamed. */

0 commit comments

Comments
 (0)