-
Notifications
You must be signed in to change notification settings - Fork 6.8k
feat(dialog): add dialog content elements #2090
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
Merged
jelbourn
merged 9 commits into
angular:master
from
crisbeto:1624/dialog-content-elements
Dec 16, 2016
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
33cb741
feat(dialog): add dialog content elements
crisbeto becff1d
Rename the dialog directives file.
crisbeto cf767fe
Add the selectors for Material 1 compatibility.
crisbeto e7712cb
Remove the closeTop method and use the dialogRef instead.
crisbeto 4f078ec
Add an aria-label to the close button and simplify the testing setup.
crisbeto 6e89905
Remove redundant element roles.
crisbeto 1c88fbc
Use the computed value on the dialog title font size.
crisbeto 8043139
Remove the letter spacing override on the dialog title.
crisbeto eeff3e1
Add a comment regarding the negative bottom margin on the dialog acti…
crisbeto File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 was deleted.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import {Directive, Input} from '@angular/core'; | ||
import {MdDialogRef} from './dialog-ref'; | ||
|
||
|
||
/** | ||
* Button that will close the current dialog. | ||
*/ | ||
@Directive({ | ||
selector: 'button[md-dialog-close], button[mat-dialog-close]', | ||
host: { | ||
'(click)': 'dialogRef.close()', | ||
'[attr.aria-label]': 'ariaLabel' | ||
} | ||
}) | ||
export class MdDialogClose { | ||
/** Screenreader label for the button. */ | ||
@Input('aria-label') ariaLabel: string = 'Close dialog'; | ||
|
||
constructor(public dialogRef: MdDialogRef<any>) { } | ||
} | ||
|
||
/** | ||
* Title of a dialog element. Stays fixed to the top of the dialog when scrolling. | ||
*/ | ||
@Directive({ | ||
selector: '[md-dialog-title], [mat-dialog-title]' | ||
}) | ||
export class MdDialogTitle { } | ||
|
||
|
||
/** | ||
* Scrollable content container of a dialog. | ||
*/ | ||
@Directive({ | ||
selector: '[md-dialog-content], md-dialog-content, [mat-dialog-content], mat-dialog-content' | ||
}) | ||
export class MdDialogContent { } | ||
|
||
|
||
/** | ||
* Container for the bottom action buttons in a dialog. | ||
* Stays fixed to the bottom when scrolling. | ||
*/ | ||
@Directive({ | ||
selector: '[md-dialog-actions], md-dialog-actions, [mat-dialog-actions], mat-dialog-actions' | ||
}) | ||
export class MdDialogActions { } |
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
@import '../core/style/elevation'; | ||
@import '../core/a11y/a11y'; | ||
|
||
|
||
$md-dialog-padding: 24px !default; | ||
$md-dialog-border-radius: 2px !default; | ||
$md-dialog-max-width: 80vw !default; | ||
$md-dialog-max-height: 65vh !default; | ||
|
||
md-dialog-container { | ||
@include md-elevation(24); | ||
|
||
display: block; | ||
padding: $md-dialog-padding; | ||
border-radius: $md-dialog-border-radius; | ||
box-sizing: border-box; | ||
overflow: auto; | ||
max-width: $md-dialog-max-width; | ||
|
||
// The dialog container should completely fill its parent overlay element. | ||
width: 100%; | ||
height: 100%; | ||
|
||
@include md-high-contrast { | ||
outline: solid 1px; | ||
} | ||
} | ||
|
||
md-dialog-content, [md-dialog-content], mat-dialog-content, [mat-dialog-content] { | ||
display: block; | ||
margin: 0 $md-dialog-padding * -1; | ||
padding: 0 $md-dialog-padding; | ||
max-height: $md-dialog-max-height; | ||
overflow: auto; | ||
} | ||
|
||
[md-dialog-title], [mat-dialog-title] { | ||
font-size: 20px; | ||
font-weight: bold; | ||
margin: 0 0 20px; | ||
display: block; | ||
} | ||
|
||
md-dialog-actions, [md-dialog-actions], mat-dialog-actions, [mat-dialog-actions] { | ||
padding: $md-dialog-padding / 2 0; | ||
display: block; | ||
|
||
&:last-child { | ||
// If the actions are the last element in a dialog, we need to pull them down | ||
// over the dialog padding, in order to avoid the action's padding stacking | ||
// with the dialog's. | ||
margin-bottom: -$md-dialog-padding; | ||
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. Add a comment explaining what this style is for? |
||
} | ||
} |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Where do these max-height and max-width come from?
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.
The
max-width
is the same that Material 1 used, themax-height
is arbitrary. M1 has 80% for themax-height
as well, although that's for the entire dialog, whereas here we only have it on themd-dialog-content
.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.
Do we need to set a max-width and max-height at all, then? I could imagine some people wanting to do a full-screen dialog.
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.
I'd say so, otherwise the dialog content won't become scrollable. Also I'm not sure whether fullscreen dialogs are in the spec.
Uh oh!
There was an error while loading. Please reload this page.
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.
actually yes, there are fullscreen dialogs in material guidelines https://material.io/guidelines/components/dialogs.html#dialogs-full-screen-dialogs