-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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(overlay): add ability to set custom class on panes #1438
Conversation
@jelbourn can I have some feedback please? I'm having a really hard time with overlays and components using them without this feature.. |
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.
Needs unit tests for all the added behaviors.
(In general, I'll hold off on reviewing PRs without tests since they seem to not be done yet)
@@ -18,6 +18,7 @@ export class DialogDemo { | |||
open() { | |||
let config = new MdDialogConfig(); | |||
config.viewContainerRef = this.viewContainerRef; | |||
config.paneClassName = 'jazz-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.
This doesn't need to be part of the demo
@@ -1,3 +1,10 @@ | |||
.demo-dialog { | |||
color: rebeccapurple; | |||
} | |||
|
|||
// apply custom z-index | |||
/deep/ .md-overlay-pane { |
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're avoiding using /deep/
at all in material2.
@@ -12,6 +12,9 @@ export class OverlayState { | |||
/** Whether the overlay has a backdrop. */ | |||
hasBackdrop: boolean = false; | |||
|
|||
/** Optional custom class to be added to the pane. */ | |||
paneClassName: string | Array<string>; |
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 would make this overlayClass
to align with backdropClass
(I don't believe we expose the term "pane" in the public API).
@@ -20,7 +20,6 @@ | |||
left: 0; | |||
height: 100%; | |||
width: 100%; | |||
z-index: $md-z-index-overlay-container; |
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 should be removed.
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 think it HAS to be removed, otherwise any inner z-index will be ignored.
See http://jsbin.com/mesujat/1/edit?html,css,output yellow is over green, despite it having thousand times higher z-index.
pane.classList.add('md-overlay-pane'); | ||
pane.classList.add(`md-has-index-${id}`); |
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 is this class for?
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.
So you can more granularly control stacking order of multiple panes inside a single overlay.. I guess you could do the same with :nth-child
.. but you know, with BEM and everything having a class could be handy.
I won't mind removing it though, you tell me.
} else { | ||
pane.classList.add(<string>state.paneClassName); | ||
} | ||
} |
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 think this is a bit cleaner:
let overlayClass = state.overlayClass;
if (overlayClass) {
if (typeof overlayClass == 'string') {
overlayClass = [overlayClass];
}
pane.classList.add(...overlayClass);
}
@@ -14,6 +14,9 @@ export class MdDialogConfig { | |||
/** The ARIA role of the dialog element. */ | |||
role: DialogRole = 'dialog'; | |||
|
|||
/** Optional custom class to be added to dialog's overlay pane. */ | |||
paneClassName: string | Array<string>; |
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.
string | string[]
@@ -120,6 +120,10 @@ export class MdDialog { | |||
.centerHorizontally() | |||
.centerVertically(); | |||
|
|||
if (dialogConfig.paneClassName) { |
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 are your use-cases for exposing this through to dialog and menu? I can see the case for custom components built on top of overlay, but I'm not sure if it's the right API surface for the leaf components.
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 whole #1432 is a use-case for menu, see http://plnkr.co/edit/AqjYdsScCYPlK9w44aHQ?p=preview (try opening the menu and then clicking on something).. if I removed z-index from md-overlay-container
, it would work, but only as long as my fixed element had z-index lower than 1000.. with this option I could simple set the menu pane to always have higher z-index.
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.
Same thing for dialog really, I could have a fixed element that will have z-index higher than 1000 and it would be overlaying the backdrop.
Closing in favour of #1584 .. |
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. |
It's more of a proof-of-concept for #1432, since I feel like you'd rather control this by passing the config a z-index value, but I think this is more flexible(for example when you need to control this with css media queries).
What I've changed:
Overlay - You can pass
paneClassName
, which can be either a string or an array of string, to a config forOverlay
screate
, it then adds it to the createdmd-overlay-pane
, I have also added a new helper class to itmd-has-index-${id}
(which can then be used along your custom class to differentiate between more panes inside one overlay)Dialog - added
paneClassName
option toMdDialogConfig
, which is then passes toOverlayState
and create example in the dialog-demoMenu - added a new
@Input
tomd-menu
, which takes either a string or array of string, and passes it down toOverlayState
in[md-menu-trigger-for]
Overlay - removed z-index from
overlay.scss
as it was making z-indexes of panes useless