Skip to content

Commit 6e94a4b

Browse files
committed
fix(dialog,bottom-sheet): invert backdrop color on dark themes
Similarly to how we handle the sidenav backdrop and ripples, these changes invert the color for the dialog and bottom sheet backdrops in dark themes.
1 parent d22f48c commit 6e94a4b

File tree

6 files changed

+16
-6
lines changed

6 files changed

+16
-6
lines changed

src/dev-app/dialog/dialog-demo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class DialogDemo {
2828
disableClose: false,
2929
panelClass: 'custom-overlay-pane-class',
3030
hasBackdrop: true,
31-
backdropClass: '',
31+
backdropClass: defaultDialogConfig.backdropClass,
3232
width: '',
3333
height: '',
3434
minWidth: '',

src/lib/bottom-sheet/_bottom-sheet-theme.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,17 @@
55
@mixin mat-bottom-sheet-theme($theme) {
66
$background: map-get($theme, background);
77
$foreground: map-get($theme, foreground);
8+
$backdrop-color: invert(mat-color($background, card, 0.288));
89

910
.mat-bottom-sheet-container {
1011
@include _mat-theme-elevation(16, $theme);
1112
background: mat-color($background, dialog);
1213
color: mat-color($foreground, text);
1314
}
15+
16+
.mat-bottom-sheet-backdrop {
17+
background: $backdrop-color;
18+
}
1419
}
1520

1621
@mixin mat-bottom-sheet-typography($config) {

src/lib/bottom-sheet/bottom-sheet-config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export class MatBottomSheetConfig<D = any> {
3232
hasBackdrop?: boolean = true;
3333

3434
/** Custom class for the backdrop. */
35-
backdropClass?: string;
35+
backdropClass?: string = 'mat-bottom-sheet-backdrop';
3636

3737
/** Whether the user can use escape or clicking outside to close the bottom sheet. */
3838
disableClose?: boolean = false;

src/lib/dialog/_dialog-theme.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,17 @@
77
@mixin mat-dialog-theme($theme) {
88
$background: map-get($theme, background);
99
$foreground: map-get($theme, foreground);
10+
$backdrop-color: invert(mat-color($background, card, 0.288));
1011

1112
.mat-dialog-container {
1213
@include _mat-theme-elevation(24, $theme);
1314
background: mat-color($background, dialog);
1415
color: mat-color($foreground, text);
1516
}
17+
18+
.mat-dialog-backdrop {
19+
background: $backdrop-color;
20+
}
1621
}
1722

1823
@mixin mat-dialog-typography($config) {

src/lib/dialog/dialog-config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export class MatDialogConfig<D = any> {
5454
hasBackdrop?: boolean = true;
5555

5656
/** Custom class for the backdrop, */
57-
backdropClass?: string = '';
57+
backdropClass?: string = 'mat-dialog-backdrop';
5858

5959
/** Whether the user can use escape or clicking on the backdrop to close the modal. */
6060
disableClose?: boolean = false;

src/lib/dialog/dialog.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ export class MatDialog implements OnDestroy {
191191
* @returns The overlay configuration.
192192
*/
193193
private _getOverlayConfig(dialogConfig: MatDialogConfig): OverlayConfig {
194-
const state = new OverlayConfig({
194+
const overlayConfig = new OverlayConfig({
195195
positionStrategy: this._overlay.position().global(),
196196
scrollStrategy: dialogConfig.scrollStrategy || this._scrollStrategy(),
197197
panelClass: dialogConfig.panelClass,
@@ -205,10 +205,10 @@ export class MatDialog implements OnDestroy {
205205
});
206206

207207
if (dialogConfig.backdropClass) {
208-
state.backdropClass = dialogConfig.backdropClass;
208+
overlayConfig.backdropClass = dialogConfig.backdropClass;
209209
}
210210

211-
return state;
211+
return overlayConfig;
212212
}
213213

214214
/**

0 commit comments

Comments
 (0)