Skip to content
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

Closed
wants to merge 2 commits into from

Conversation

amcdnl
Copy link
Contributor

@amcdnl amcdnl commented Oct 1, 2017

This PR does the following:

  • Adds a new utility method for parsing string|string[]|{key/value} to ngClass-like object
  • Adds a new utility method for parsing a ngClass-like object to string array
  • Updates overlay implementation to accept ngClass-like object
  • Adds panelClass to date picker
  • Deprecates extraClasses to panelClass in snackbar
  • Deprecates class input to panelClass and accepts ngClass-like object in menu
  • Updates dialog implementation to ngClass like object

I 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.

@amcdnl amcdnl self-assigned this Oct 1, 2017
@amcdnl amcdnl requested a review from jelbourn October 1, 2017 16:45
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Oct 1, 2017
*/

/* Parses arguments into a ngClass-like object */
export function parseClassList(classList:
Copy link
Member

@crisbeto crisbeto Oct 1, 2017

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.

Copy link
Contributor Author

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

Copy link
Contributor

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!

Copy link
Member

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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.

@amcdnl
Copy link
Contributor Author

amcdnl commented Oct 26, 2017

Closing in favor of #8056

@amcdnl amcdnl closed this Oct 26, 2017
@amcdnl amcdnl deleted the overlay-class-6372 branch October 26, 2017 19:28
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 7, 2019
@mmalerba mmalerba added the in progress This issue is currently in progress label Mar 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes PR author has agreed to Google's Contributor License Agreement in progress This issue is currently in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants