Skip to content

Add workaround to avoid duplicating theme css #5323

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

syeopite
Copy link
Member

@syeopite syeopite commented May 22, 2025

This PR is a stop-gap measure to prevent having to duplicate the theming styles two times for each theme, and to avoid the pains of having to jump around the behemoth default.css file whilst duplicating the theme color.

Until we can agree to a proper solution this at least makes adding and changing colors much less of a headache.

Of course there's still some duplication in that you still need to define the selectors twice (once for light and once for dark) but I don't think this can be fixed by anything short of an actual CSS pre-processor.

Closes #5056

In order to support both a theme toggle and to automatically use the
user's selected theme based on browser/system defaults the stylesheets
has to be duplicated twice since the latter requires the css to be
wrapped around a media query.

This duplication is a painful experience to deal with when adding or
changing existing styles. Even more so when it involves jumping around
the behemoth default.css from and back to whatever sections you were
just working on.

I don't believe the we the Invidious team will be able to agree to a
proper solution anytime soon (eg css post-processor, modern css
light-dark feature, etc) so this commit is here as a stopgap measure.

The workaround is to move the theming styles to two separate files
which are read at runtime and used to generate a combined stylesheet
with the necessary duplication for the media query. This combined
stylesheet is then delivered on a new route added to Invidious,
bypassing the static file handler.
@syeopite syeopite requested a review from a team as a code owner May 22, 2025 02:10
@syeopite syeopite requested review from Fijxu and removed request for a team May 22, 2025 02:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Enhancement] CSS: Overhaul the way theming is done
1 participant