-
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
chore(api): overlay class audits #6372 #7454
Conversation
*/ | ||
|
||
/* Parses arguments into a ngClass-like object */ | ||
export function parseClassList(classList: |
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'm sure that we need to support all of these formats. NgClass
has them, presumably, because the expressions are dynamic and there a lot of ways to combine static classes and dynamic ones. In our case we only add the classes on init and we don't care about updating them, which can be done just as easily with an array.
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 original ticket expressed desire to standardize this format. Ref: #6372
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.
FWIW NgClass seemed like a natural thing to support for template-based overlays like select, menu, autocomplete, tooltip. For dialog and snackbar, it's probably less important, but there are some good use cases for having the ability to dynamically update classes, #6206 (comment).
Further, I would personally find an NgClass cdk utility useful for custom overlay-based 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.
Template-based overlays should "just work" as they are at the moment (you can stick an NgClass
on an element inside the TemplateRef
). This PR adds a similar signature to the programmatic API, but it's not really NgClass
because it won't update dynamically.
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.
Ok tbh, I hadn't actually read the pr 😄 . My initial concern in filing #6372 was how snackbar and dialog differed in support and naming. Combined with little type info available in the docs (as #6947 is trying to solve) it's hard to anticipate exactly what will happen just by looking at the docs.
I agree, {[klass: string]: any}
is probably extraneous (and maybe misrepresenting) if classes don't update dynamically. While I still think that's a valid feature via #6206, maybe for another time.
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.
Ya, so basically this PR:
- Unifies all the css class names to
panelClass
- Normalizes all the signatures to
ngClass
-like
That means you can pass it an string, string array or object key/value pair. In the cases of the snackbar and overlay, there is no ngClass
used so it just does a evaluate of the condition and matches it. I personally think the consistent signature is valuable and in the situation where there isn't real ngClass
I could do an actual implementation I just didn't do it because I didn't know how far we wanted to take this.
@jelbourn - Can you advise on next steps with this? Currently the PR is just in a evaluation phase and I know you expressed concerns with adding another CDK lib here too so I didn't want to take it too far without first review.
Closing in favor of #8056 |
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. |
This PR does the following:
panelClass
to date pickerextraClasses
topanelClass
in snackbarclass
input topanelClass
and accepts ngClass-like object in menuI really didn't like the fact I had to add this to the CDK. I originally had it as a utility inside material but the overlay lives in the CDK and needed it there too. @jelbourn - do you have any thoughts on better place for this?
This is still very WIP.