Skip to content
This repository has been archived by the owner on May 16, 2023. It is now read-only.

Styles for dark/light theme are leaking to other components #130

Closed
ghost opened this issue Jul 30, 2019 · 6 comments
Closed

Styles for dark/light theme are leaking to other components #130

ghost opened this issue Jul 30, 2019 · 6 comments

Comments

@ghost
Copy link

ghost commented Jul 30, 2019

Given the following example:

<h1 class="dark-theme">Some header</h1>
<ng-chat [adapter]="adapter" [userId]="userId"></ng-chat>

The <h1> element will inherit the styles for "dark-theme", even though it is not part of ng-chat.

The ng-chat decorator uses encapsulation: core.ViewEncapsulation.None, so the generated styles for "dark-theme" or "light-theme" will be applied to any element of the Angular app that match the class name "dark-theme":

.dark-theme,.dark-theme .primary-text{color:#fff;font-family:Arial,Helvetica,sans-serif}.dark-theme .primary-background{background-color:#565656}.dark-theme .secondary-background{background-color:#444}.dark-theme .primary-outline-color{border-color:#353535}.dark-theme .friends-search-bar{background-color:#444;border:1px solid #444;color:#fff}.dark-theme .ng-chat-people-action,.dark-theme .ng-chat-people-action>i,.dark-theme .unread-messages-counter-container{background-color:#fff;color:#444}.dark-theme .load-history-action{background-color:#444}.dark-theme .chat-window-input{background-color:#444;color:#fff}.dark-theme .file-message-container,.dark-theme .sent-chat-message-container{border-color:#444;background-color:#444}.dark-theme .file-message-container.received,.dark-theme .received-chat-message-container{background-color:#565656;border-color:#444}.dark-theme .ng-chat-footer{background-color:#444}

A quick solution would be to add a custom prefix to all generated styles. If the basic class is changed to ng-chat-dark-theme then no other components in Angular should be affected.

@rpaschoal
Copy link
Owner

Hi @centigrade-thomas-becker ,

Thanks for pointing this out! Will consider this enhancement for a next release!

Cheers

@rpaschoal
Copy link
Owner

Hi @centigrade-thomas-becker ,

I haven't released this with 2.0.5 but I'm still planning to release this at some point.

Cheers.

@ghost
Copy link
Author

ghost commented Sep 2, 2019

Another solution would be to add the element name to the css rules, like ng-chat.dark-theme. What do you think which solution would be better?

@rpaschoal
Copy link
Owner

Hi @centigrade-thomas-becker , I think that adding a selector prefix to it would be ideal (Such as .ng-chat).

Would you be comfortable in getting a PR for this? If you want to work around this just remember to do some dev testing around the default light and dark themes and also to test the custom theme support as well.

Cheers

@ghost
Copy link
Author

ghost commented Sep 3, 2019

Sorry, I am short on time right now.

@rpaschoal
Copy link
Owner

The changes discussed here were released with https://github.com/rpaschoal/ng-chat/releases/tag/3.0.1

The changes were pushed with this pull request: #156

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant