-
Notifications
You must be signed in to change notification settings - Fork 6.8k
feat(overlay): replace OverlayContainer themeClass w/ addClass/removeClass methods #6975
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
Conversation
3c23fc5 to
f473a2d
Compare
src/cdk/overlay/overlay-container.ts
Outdated
| if (value) { | ||
| this._containerElement.classList.add(value); | ||
| } | ||
| addClass(cssClass: 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.
Since the getContainerElement() is public, I'm not sure that these methods are even necessary.
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, I considered that. I was worried that the change would be "too complicated" for people, but maybe I'm overthinking it. I'll just remove the themeClass completely.
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.
IMO we still need some easy way for people to pass the theme to overlays, though. Perhaps a provider that injects the overlay container and applies the class?
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.
Is getContainerElement().classList.add('dark-theme') that must worse than themeClasss = 'dark-theme';?
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 is, but I guess that it's not as obvious that that's the way to theme all 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.
IMO while getContainerElement().classList.add('dark-theme') isn't immediately obvious, it reduces the magic, which is nice.
Just don't forget the example in the theming guide needs to be updated with whichever solution!
5ad9bf9 to
593aa7b
Compare
|
I went ahead and just removed |
guides/theming.md
Outdated
| (`.unicorn-dark-theme` in the example above). | ||
|
|
||
| To do this, you can specify a `themeClass` on the global overlay container. For the example above, | ||
| To do this, you can add the approviate class to the global overlay container. For the example above, |
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.
typo "appropriate"
crisbeto
left a comment
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.
LGTM after correcting the typo.
593aa7b to
7dca378
Compare
…Class methods
BREAKING CHANGE: Now that the Overlay is part of the cdk rather than Angular Material directly,
the `themeClass` property has been removed. To add a class to the
overlay for theming, you can do
```ts
overlayContainer.getContainerElement().classList.add('my-theme-class');
```
7dca378 to
fafe4c5
Compare
|
Fixed typo and demo-app (which I missed before) |
|
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. |
BREAKING CHANGE: Now that the Overlay is part of the cdk rather than Angular Material directly,
the
themeClassproperty has been removed. To add a class to theoverlay for theming, you can do