-
Notifications
You must be signed in to change notification settings - Fork 6.8k
docs(demos): add dialog demos #5666
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
b78b5d1
31306d5
bcd3d7b
fba0f16
c236619
e24f244
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<p> Hi, I'm a dialog! </p> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<button md-button (click)="openDialog()">Open dialog</button> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import {Component} from '@angular/core'; | ||
import {MdDialog} from '@angular/material'; | ||
|
||
/** | ||
* @title Basic Dialog | ||
*/ | ||
@Component({ | ||
selector: 'dialog-basic-example', | ||
templateUrl: 'dialog-basic-example.html', | ||
}) | ||
export class DialogBasicExample { | ||
constructor(private dialog: MdDialog) {} | ||
|
||
openDialog() { | ||
this.dialog.open(DialogBasicExampleDialog); | ||
} | ||
} | ||
|
||
@Component({ | ||
selector: 'dialog-basic-example-dialog', | ||
templateUrl: 'dialog-basic-example-dialog.html', | ||
}) | ||
export class DialogBasicExampleDialog {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<h2 md-dialog-title>Delete all</h2> | ||
<md-dialog-content>Are you sure?</md-dialog-content> | ||
<md-dialog-actions> | ||
<button md-button tabindex="-1">Not Tabbable</button> | ||
<button md-button [md-dialog-close]="true" tabindex="1">Yes</button> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A more realistic example for this case would be to have an input and have the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @crisbeto - I have this demo in the overview, do you think we need to do it here too? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, I must've missed the one below. |
||
<button md-button md-dialog-close tabindex="2">No</button> | ||
</md-dialog-actions> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/** No CSS for this example */ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<button md-button (click)="openDialog()">Open dialog</button> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import {Component} from '@angular/core'; | ||
import {MdDialog} from '@angular/material'; | ||
|
||
/** | ||
* @title Dialog Content | ||
*/ | ||
@Component({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "Dialog content" by itself doesn't really communicate what this example is for. It should be something like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I addressed the scrolling and title, can you expand on what you had in mind for the button alignment? |
||
selector: 'dialog-content-example', | ||
templateUrl: 'dialog-content-example.html', | ||
}) | ||
export class DialogContentExample { | ||
constructor(public dialog: MdDialog) {} | ||
|
||
openDialog() { | ||
const dialogRef = this.dialog.open(DialogContentExampleDialog); | ||
dialogRef.afterClosed().subscribe(result => { | ||
console.log(`Dialog result: ${result}`); | ||
}); | ||
} | ||
} | ||
|
||
@Component({ | ||
selector: 'dialog-content-example-dialog', | ||
templateUrl: 'dialog-content-example-dialog.html', | ||
}) | ||
export class DialogContentExampleDialog {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<h1 md-dialog-title>Favorite Animal</h1> | ||
<div md-dialog-content> | ||
My favorite animal is: | ||
<ul> | ||
<li> | ||
<span *ngIf="data.animal === 'panda'">✓</span> Panda | ||
</li> | ||
<li> | ||
<span *ngIf="data.animal === 'unicorn'">✓</span> Unicorn | ||
</li> | ||
<li> | ||
<span *ngIf="data.animal === 'lion'">✓</span> Lion | ||
</li> | ||
</ul> | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/** No CSS for this example */ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<button md-button (click)="openDialog()">Open dialog</button> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import {Component, Inject} from '@angular/core'; | ||
import {MdDialog, MD_DIALOG_DATA} from '@angular/material'; | ||
|
||
/** | ||
* @title Dialog Data Sharing | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd call this "Injecting data when opening a dialog" |
||
*/ | ||
@Component({ | ||
selector: 'dialog-data-example', | ||
templateUrl: 'dialog-data-example.html', | ||
}) | ||
export class DialogDataExample { | ||
constructor(public dialog: MdDialog) {} | ||
|
||
openDialog() { | ||
this.dialog.open(DialogDataExampleDialog, { | ||
data: { | ||
animal: 'panda' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This data should come from an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Per our conversation, we discussed using the example of the overview to demonstrate this and keeping this demo basic. |
||
} | ||
}); | ||
} | ||
} | ||
|
||
@Component({ | ||
selector: 'dialog-data-example-dialog', | ||
templateUrl: 'dialog-data-example-dialog.html', | ||
}) | ||
export class DialogDataExampleDialog { | ||
constructor(@Inject(MD_DIALOG_DATA) public data: any) {} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,11 @@ | ||
<p> Hi, I'm a dialog! </p> | ||
<h1 md-dialog-title>Hi {{data.name}}</h1> | ||
<div md-dialog-content> | ||
<p>What's your favorite animal?</p> | ||
<md-input-container> | ||
<input mdInput tabindex="1" [(ngModel)]="data.animal"> | ||
</md-input-container> | ||
</div> | ||
<div md-dialog-actions> | ||
<button md-button [md-dialog-close]="data.animal" tabindex="2">Ok</button> | ||
<button md-button (click)="onNoClick()" tabindex="-1">No Thanks</button> | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,13 @@ | ||
<button md-button (click)="openDialog()">Open dialog</button> | ||
<ol> | ||
<li> | ||
<md-input-container> | ||
<input mdInput [(ngModel)]="name" placeholder="What's your name?"> | ||
</md-input-container> | ||
</li> | ||
<li> | ||
<button md-raised-button (click)="openDialog()">Pick one</button> | ||
</li> | ||
<li *ngIf="animal"> | ||
You chose: <i>{{animal}}</i> | ||
</li> | ||
</ol> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,46 @@ | ||
import {Component} from '@angular/core'; | ||
import {MdDialog} from '@angular/material'; | ||
import {Component, Inject} from '@angular/core'; | ||
import {MdDialog, MdDialogRef, MD_DIALOG_DATA} from '@angular/material'; | ||
|
||
/** | ||
* @title Dialog Overview | ||
*/ | ||
@Component({ | ||
selector: 'dialog-overview-example', | ||
templateUrl: 'dialog-overview-example.html', | ||
templateUrl: 'dialog-overview-example.html' | ||
}) | ||
export class DialogOverviewExample { | ||
|
||
animal: string; | ||
name: string; | ||
|
||
constructor(public dialog: MdDialog) {} | ||
|
||
openDialog() { | ||
this.dialog.open(DialogOverviewExampleDialog); | ||
openDialog(): void { | ||
let dialogRef = this.dialog.open(DialogOverviewExampleDialog, { | ||
width: '250px', | ||
data: { name: this.name, animal: this.animal } | ||
}); | ||
|
||
dialogRef.afterClosed().subscribe(result => { | ||
console.log('The dialog was closed'); | ||
this.animal = result; | ||
}); | ||
} | ||
} | ||
|
||
} | ||
|
||
@Component({ | ||
selector: 'dialog-overview-example-dialog', | ||
templateUrl: 'dialog-overview-example-dialog.html', | ||
}) | ||
export class DialogOverviewExampleDialog {} | ||
export class DialogOverviewExampleDialog { | ||
|
||
constructor( | ||
public dialogRef: MdDialogRef<DialogOverviewExampleDialog>, | ||
@Inject(MD_DIALOG_DATA) public data: any) { } | ||
|
||
onNoClick(): void { | ||
this.dialogRef.close(); | ||
} | ||
|
||
} |
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,12 +35,12 @@ import { | |
MdSliderModule, | ||
MdSidenavModule, | ||
MdSnackBarModule, | ||
MdTableModule, | ||
MdTabsModule, | ||
MdToolbarModule, | ||
MdTooltipModule, | ||
MdPaginatorModule, | ||
MdSortModule | ||
MdSortModule, | ||
MdTableModule | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like this adds |
||
] | ||
}) | ||
export class ExampleMaterialModule {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this supposed to be
dialog-overview
?I think we should probably get rid of this "dialog-basic" example because it is too basic; it doesn't really show anything. The first example really needs to showcase the component.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Moved the first demo to the complex overview example.