NodeJS version:
v8.11.2
What is the expected behaviour?
The custom CSS should work as seamlessly as the default style and not require refreshing the page for some elements.
Here's my CSS: https://pastebin.com/Y43iYKTp
I am not a contributor just an admin on an instance add my opinion
To the best of my knowledge it looks like custom css and custom js is loaded from an api call after the page has already loaded causes a noticeable repaint when doing heavy css customization. This seems to be by design and I'm not sure how to fix it. It would be nice to have a more robust theme option.
@usbsnowcrash Thank you!
Just realized that some of the elements not loading until a second refresh is almost definitely a bug. Reopening, just disregard the first part of the video.
In any case, we should think of a better way to customize CSS/JS.
Hi,
See the help tooltip near the CSS textarea:
"
Prepend with #custom-css to override styles. Example:
#custom-css .logged-in-email {
color: red;
}
"
If you prepend with #custom-css, you don't need [_ngcontent-c13] stuff that are automatically generated by Angular (so they could change).
Ahh, I missed that when I glanced into the CSS. This explains the behavior observed in this issue fully. Angular allocates those _ngcontent-cX and _nghost-cX numbers arbitrarily, it may not even be consistent from load to load.
So putting that aside, there's still a gap between the page loading and application of custom CSS. The only way to avoid that gap is to either inject the custom stylesheet onto the client index.html (easy way) or use server-side rendering (hard way).
Since the PeerTube server handles serving up the client files, this could be done somewhere in the client router
https://github.com/Chocobozzz/PeerTube/blob/602a81a2137afcb5ca12341329199fbea2f08bd8/server/controllers/client.ts#L72
Such a change would let us remove the custom CSS loading done here:
https://github.com/Chocobozzz/PeerTube/blob/602a81a2137afcb5ca12341329199fbea2f08bd8/client/src/app/app.component.ts#L97
@rezonant This is a good idea. Maybe you could create another issue?
Most helpful comment
In any case, we should think of a better way to customize CSS/JS.