-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dialog): add styles and ability to close. (#862)
- Loading branch information
Showing
8 changed files
with
93 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,14 @@ | ||
@import 'elevation'; | ||
@import 'default-theme'; | ||
|
||
$md-dialog-padding: 24px !default; | ||
|
||
:host { | ||
// TODO(jelbourn): add real Material Design dialog styles. | ||
display: block; | ||
background: deeppink; | ||
@include md-elevation(2); | ||
overflow: hidden; | ||
|
||
padding: $md-dialog-padding; | ||
|
||
background: md-color($md-background, dialog); | ||
@include md-elevation(24); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,36 @@ | ||
import {OverlayRef} from '@angular2-material/core/overlay/overlay-ref'; | ||
import {Observable} from 'rxjs/Observable'; | ||
import {Subject} from 'rxjs/Subject'; | ||
|
||
|
||
// TODO(jelbourn): resizing | ||
// TODO(jelbourn): afterOpen and beforeClose | ||
|
||
|
||
/** | ||
* Reference to a dialog opened via the MdDialog service. | ||
*/ | ||
export class MdDialogRef<T> { | ||
/** The instance of component opened into the dialog. */ | ||
componentInstance: T; | ||
|
||
// TODO(jelbourn): Add methods to resize, close, and get results from the dialog. | ||
/** Subject for notifying the user that the dialog has finished closing. */ | ||
private _afterClosed: Subject<any> = new Subject(); | ||
|
||
constructor(private _overlayRef: OverlayRef) { } | ||
|
||
/** | ||
* Close the dialog. | ||
* @param dialogResult Optional result to return to the dialog opener. | ||
*/ | ||
close(dialogResult?: any): void { | ||
this._overlayRef.dispose(); | ||
this._afterClosed.next(dialogResult); | ||
this._afterClosed.complete(); | ||
} | ||
|
||
/** Gets an observable that is notified when the dialog is finished closing. */ | ||
afterClosed(): Observable<any> { | ||
return this._afterClosed.asObservable(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
<h1>Dialog demo</h1> | ||
|
||
<button (click)="open()" [disabled]="dialogRef">Open dialog</button> | ||
|
||
<p> | ||
Last close result: {{lastCloseResult}} | ||
</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters