Skip to content

Commit

Permalink
fix(dialog,bottom-sheet): invert backdrop color on dark themes
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
crisbeto committed Sep 10, 2018
1 parent 4ddbde9 commit 9e797b1
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/demo-app/dialog/dialog-demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class DialogDemo {
disableClose: false,
panelClass: 'custom-overlay-pane-class',
hasBackdrop: true,
backdropClass: '',
backdropClass: defaultDialogConfig.backdropClass,
width: '',
height: '',
minWidth: '',
Expand Down
5 changes: 5 additions & 0 deletions src/lib/bottom-sheet/_bottom-sheet-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@
@mixin mat-bottom-sheet-theme($theme) {
$background: map-get($theme, background);
$foreground: map-get($theme, foreground);
$backdrop-color: invert(mat-color($background, card, 0.288));

.mat-bottom-sheet-container {
background: mat-color($background, dialog);
color: mat-color($foreground, text);
}

.mat-bottom-sheet-backdrop {
background: $backdrop-color;
}
}

@mixin mat-bottom-sheet-typography($config) {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/bottom-sheet/bottom-sheet-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class MatBottomSheetConfig<D = any> {
hasBackdrop?: boolean = true;

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

/** Whether the user can use escape or clicking outside to close the bottom sheet. */
disableClose?: boolean = false;
Expand Down
5 changes: 5 additions & 0 deletions src/lib/dialog/_dialog-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@
@mixin mat-dialog-theme($theme) {
$background: map-get($theme, background);
$foreground: map-get($theme, foreground);
$backdrop-color: invert(mat-color($background, card, 0.288));

.mat-dialog-container {
background: mat-color($background, dialog);
color: mat-color($foreground, text);
}

.mat-dialog-backdrop {
background: $backdrop-color;
}
}

@mixin mat-dialog-typography($config) {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/dialog/dialog-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class MatDialogConfig<D = any> {
hasBackdrop?: boolean = true;

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

/** Whether the user can use escape or clicking on the backdrop to close the modal. */
disableClose?: boolean = false;
Expand Down
6 changes: 3 additions & 3 deletions src/lib/dialog/dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ export class MatDialog {
* @returns The overlay configuration.
*/
private _getOverlayConfig(dialogConfig: MatDialogConfig): OverlayConfig {
const state = new OverlayConfig({
const overlayConfig = new OverlayConfig({
positionStrategy: this._overlay.position().global(),
scrollStrategy: dialogConfig.scrollStrategy || this._scrollStrategy(),
panelClass: dialogConfig.panelClass,
Expand All @@ -200,10 +200,10 @@ export class MatDialog {
});

if (dialogConfig.backdropClass) {
state.backdropClass = dialogConfig.backdropClass;
overlayConfig.backdropClass = dialogConfig.backdropClass;
}

return state;
return overlayConfig;
}

/**
Expand Down

0 comments on commit 9e797b1

Please sign in to comment.