Skip to content

Commit

Permalink
feat(dialogs): extend MatDialogConfig to leverage all the dialog conf…
Browse files Browse the repository at this point in the history
…ig (closes #1011) (#1059)

* feat(dialogs): extend MatDialogConfig to leverage all the dialog configurations

we are going away from hardcoding widths so this is technically a breaking change, but now you will be able to pass any widths and update the dialog configuration as needed.. also long words wrap properly

* feat(): add 400px width by default
  • Loading branch information
emoralesb05 authored Jan 4, 2018
1 parent b92a6dc commit eb2ca43
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 33 deletions.
3 changes: 3 additions & 0 deletions src/app/components/components/dialogs/dialogs.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ <h3>Example(after setup):</h3>
viewContainerRef: this._viewContainerRef, //OPTIONAL
title: 'Alert', //OPTIONAL, hides if not provided
closeButton: 'Close', //OPTIONAL, defaults to 'CLOSE'
width: '400px', //OPTIONAL, defaults to 400px
});
}

Expand All @@ -59,6 +60,7 @@ <h3>Example(after setup):</h3>
title: 'Confirm', //OPTIONAL, hides if not provided
cancelButton: 'Disagree', //OPTIONAL, defaults to 'CANCEL'
acceptButton: 'Agree', //OPTIONAL, defaults to 'ACCEPT'
width: '500px', //OPTIONAL, defaults to 400px
}).afterClosed().subscribe((accept: boolean) => {
if (accept) {
// DO SOMETHING
Expand All @@ -77,6 +79,7 @@ <h3>Example(after setup):</h3>
value: 'Prepopulated value', //OPTIONAL
cancelButton: 'Cancel', //OPTIONAL, defaults to 'CANCEL'
acceptButton: 'Ok', //OPTIONAL, defaults to 'ACCEPT'
width: '400px', //OPTIONAL, defaults to 400px
}).afterClosed().subscribe((newValue: string) => {
if (newValue) {
// DO SOMETHING
Expand Down
1 change: 1 addition & 0 deletions src/app/components/components/dialogs/dialogs.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export class DialogsDemoComponent {
message: 'This is how simple it is to create a confirm with this wrapper service. Do you agree?',
cancelButton: 'Disagree',
acceptButton: 'Agree',
width: '500px',
});
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
@media (min-width: 600px) {
td-dialog {
width: 400px;
}
}
@media (max-width: 599px) {
td-dialog {
width: 250px;
}
.td-dialog-message {
word-break: break-word;
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
@media (min-width: 600px) {
td-dialog {
width: 400px;
}
}
@media (max-width: 599px) {
td-dialog {
width: 250px;
}
.td-dialog-message {
word-break: break-word;
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
@media (min-width: 600px) {
td-dialog {
width: 400px;
}
}
@media (max-width: 599px) {
td-dialog {
width: 250px;
}
}
.td-dialog-input-wrapper {
// layout row
flex-direction: row;
Expand All @@ -19,3 +9,7 @@
box-sizing: border-box;
}
}

.td-dialog-message {
word-break: break-word;
}
10 changes: 5 additions & 5 deletions src/platform/core/dialogs/services/dialog.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ import { TdAlertDialogComponent } from '../alert-dialog/alert-dialog.component';
import { TdConfirmDialogComponent } from '../confirm-dialog/confirm-dialog.component';
import { TdPromptDialogComponent } from '../prompt-dialog/prompt-dialog.component';

export interface IDialogConfig {
export interface IDialogConfig extends MatDialogConfig {
title?: string;
message: string;
viewContainerRef?: ViewContainerRef;
disableClose?: boolean;
}

export interface IAlertConfig extends IDialogConfig {
Expand Down Expand Up @@ -137,8 +135,10 @@ export class TdDialogService {

private _createConfig(config: MatDialogConfig): MatDialogConfig {
let dialogConfig: MatDialogConfig = new MatDialogConfig();
dialogConfig.viewContainerRef = config.viewContainerRef;
dialogConfig.disableClose = config.disableClose;
dialogConfig.width = '400px';
for (let key in config) {
dialogConfig[key] = config[key];
}
return dialogConfig;
}

Expand Down

0 comments on commit eb2ca43

Please sign in to comment.