Peertube: Custom CSS not working correctly

Created on 5 Jul 2018  路  8Comments  路  Source: Chocobozzz/PeerTube

Here's my CSS: https://pastebin.com/Y43iYKTp

Type

Most helpful comment

In any case, we should think of a better way to customize CSS/JS.

All 8 comments

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?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gegeweb picture gegeweb  路  3Comments

XenonFiber picture XenonFiber  路  3Comments

filmaidykai picture filmaidykai  路  3Comments

zilti picture zilti  路  3Comments

MikaXII picture MikaXII  路  3Comments