-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
feat(dialog): add dialog content elements #2090
feat(dialog): add dialog content elements #2090
Conversation
Out of interest, why is the md-dialog-title selector just an attribute? |
It's there to encourage you to use the appropriate native elements @pietie (e.g. |
Have you considered an "align" attribute on md-dialog-actions similar to md-card? "center" would also be a nice addition to start|end as well. |
Nope, I followed the example from #1624, but it sounds reasonable. |
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 pulled it down and this looks like just what I had in mind. Thanks!
I like the idea of adding align
to md-dialog-actions
in a follow-up PR.
@Directive({ | ||
selector: '[md-dialog-title]', | ||
host: { | ||
role: 'heading' |
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 don't think we should put a role
on this- the user should just put it on the appropriate element (h2
, header
, etc.)
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 added it in case the attribute was added to something like a div
. I'll scope the selector to the proper nodes.
@Directive({ | ||
selector: '[md-dialog-content], md-dialog-content', | ||
host: { | ||
role: 'main' |
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 don't think we should have this role; nothing in the W3C authoring practices mentiones it and the docs for role="main" says there should only be one per "document" (for which a modal dialog doesn't count).
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.
Shouldn't the content have some kind of role? The main
was the only one I could find that seemed to fit.
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 don't think it needs a role at all
} | ||
|
||
[md-dialog-title] { | ||
font-size: rem(2); |
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 like to avoid using this rem
function for now... the fact that it's even here is a leftover from an earlier version. During beta we're going to work on a more comprehensive typography solution.
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.
What should I go with in this case? Put in the computed value?
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.
Yeah, go ahead with the computed value for now.
display: block; | ||
|
||
&:last-child { | ||
margin-bottom: -$md-dialog-padding; |
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.
Add a comment explaining what this style is for?
* Button that will close the current dialog. | ||
*/ | ||
@Directive({ | ||
selector: 'button[md-dialog-close]', |
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.
Also add mat-
prefixed selectors (will be used for material1 compatibility mode).
$md-dialog-padding: 24px !default; | ||
$md-dialog-border-radius: 2px !default; | ||
$md-dialog-max-width: 80vw !default; | ||
$md-dialog-max-height: 65vh !default; |
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, the max-height
is arbitrary. M1 has 80% for the max-height
as well, although that's for the entire dialog, whereas here we only have it on the md-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.
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
[md-dialog-title] { | ||
font-size: rem(2); | ||
font-weight: bold; | ||
letter-spacing: 0.005em; |
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.
Why is letter-spacing
necessary here?
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 went with whatever M1 was doing, I'm not sure what the reasoning for it was.
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.
Let's remove it, then.
selector: 'button[md-dialog-close]', | ||
host: { | ||
'(click)': 'dialog.closeTop()' | ||
} |
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.
We need to add a default aria-label
to this that says "Close dialog". Also a unit test that ensures an aria-label
set by the user overrides the default.
@@ -0,0 +1,49 @@ | |||
import {Directive} from '@angular/core'; |
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.
Let's call this file dialog-content-directives.ts
@Directive({ | ||
selector: 'button[md-dialog-close]', | ||
host: { | ||
'(click)': 'dialog.closeTop()' |
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 don't think this will work for situations where there are two dialogs open side-by-side instead of one on top of the other. I took a poke at the code and found that you can inject the MdDialogRef
here because the content is loaded with an instance of DialogInjector
, so this works:
/**
* Button that will close the current dialog.
*/
@Directive({
selector: 'button[md-dialog-close]',
host: {
'(click)': 'dialogRef.close()'
}
})
export class MdDialogClose {
constructor(public dialogRef: MdDialogRef<any>) { }
}
With this change, I don't think we need closeTop
any more.
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.
Was going to say pretty much the same thing. As is it will break some more exotic use cases.
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 went this route since it's not currently possible to have multiple dialogs side-by-side. Also I wasn't aware of the DialogInjector
. I'll try it out.
Addressed the feedback @jelbourn. |
LGTM, just needs rebase. Go ahead and apply the |
Adds the following dialog-specific directives: * `md-dialog-close` - Closes the current dialog. * `md-dialog-title` - Title of a dialog. * `md-dialog-content` - Scrollable content for a dialog. * `md-dialog-actions` - Container for the bottom buttons in a dialog. Fixes angular#1624. Fixes angular#2042.
54ae810
to
eeff3e1
Compare
is it possible to override md-dialog-max-width somehow? I'm unable to change it to anything else in spite of !default attribute. The space is precious especially in xs-sm, hard coded 80vw seems to be too small |
one more thing - material design guidelines for dialogs (except for alertdialog) have an toolbar at the top, did you consider the possibility to give an option of aligning md-dialog-actions to the top or introducing one more directive like md-dialog-toolbar? It would be also awesome if that toolbar could have home button, title and action areas |
md-dialog-container {
max-width: <some value>;
}
|
|
@crisbeto Where exactly might you override the max-width in the CSS? Setting it on the parent component calling the Dialog or the Dialog itself's style does not seem to change the max-width to whatever it is set to. http://plnkr.co/edit/7CE3VG1LUj2VtLCtdaOM?p=preview @chpasha Did you have any luck? |
yes, I did succeed http://plnkr.co/edit/B46euKJxtf8RXu1O0smZ?p=preview
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Adds the following dialog-specific directives:
md-dialog-close
- Closes the current dialog.md-dialog-title
- Title of a dialog.md-dialog-content
- Scrollable content for a dialog.md-dialog-actions
- Container for the bottom buttons in a dialog.Fixes #1624.
Fixes #2042.