jellyfin / jellyfin-web

Web Client for Jellyfin
https://jellyfin.org
GNU General Public License v2.0
2.28k stars 1.22k forks source link

Changing stylesheets to SCSS #836

Closed h1nk closed 3 years ago

h1nk commented 4 years ago

Seeing as this project is already using Webpack it'd be nice to make use of SCSS to allow for more DRY and organized stylesheets. I believe @MrTimscampi has already brought this idea up before. An initial transition to SCSS could be made without any stylesheet refactoring or changes since CSS3 is automatically valid SCSS.


(Edit by MrTimscampi)

Here's a list of the files to convert after merging #862, in order to keep track of progress.

When converting a file, don't hesitate to reorganize everything, try to find dead rules and, if necessary, create more files (variables.scss is one that comes to mind, for example)

dkanada commented 4 years ago

I believe we will need to finish the transition to Webpack before we can use SCSS in the source, but that's already getting done so it might not be too long.

heyhippari commented 4 years ago

Dependent on #681

JustAMan commented 4 years ago

Should be dependent on https://github.com/jellyfin/jellyfin-web/pull/862 now, right @MrTimscampi?

heyhippari commented 4 years ago

Yep, I need to go through the issues to see what I can mark as fixed in #862

h1nk commented 4 years ago

@MrTimscampi now that #862 is merged into master is it possible for the transition to be made now? I'd like to tackle the initial refactoring to SCSS but I'm not familiar with how to the development pipeline works (Webpack dev server, yarn, Gulp etc.). Could you describe how to start working with SCSS under the new build/dev pipeline?

heyhippari commented 4 years ago

@h1nk It is ready to be started, indeed!

The relevant lies for Gulp are here: https://github.com/jellyfin/jellyfin-web/blob/master/gulpfile.js#L82-L90

Basically, use git mv to move files around if needed (to be in .scss for example), then you do your changes in the files.

You can use yarn serve to open a dev server and look at your changes, it will reload things as you make changes.

h1nk commented 4 years ago

@MrTimscampi, hey thanks for the reply.

I did try this initially as you described but SCSS wasn't being picked up and compiled, here for example a SASS comment is being left in the stylesheet:

image

I basically ran:

> yarn serve
> git mv .\src\assets\css\site.css .\src\assets\css\site.scss
> # Edit the files accordingly...
heyhippari commented 4 years ago

@h1nk This works for me: https://github.com/jellyfin/jellyfin-web/commit/ae82957d798dfe53e717d5253424591104ad7fb5

You might need to move the files first and we might need to adjust how Browsersync watches files, but it does compile and the dark theme still looks normal.

GuilhermeHideki commented 4 years ago

Hi! I was looking into the files and would like to ask somethings

heyhippari commented 4 years ago

Hi @GuilhermeHideki.

We do want to make use of CSS variables, as it makes a lot of things nicer and easier (themes for example).

However, due to targeting some really old browsers (Chrome 27 is our oldest, afaik) for Smart TV compatibility, we'll need to use this ponyfill to enable compatibility.
As such, when using them, we need to make sure to keep the limitations of that ponyfill in mind:

So feel free to use them :smiley:

For mixins, absolutely. If you notice something that is done often, absolutely make use of mixins to reduce the amount of CSS we have.

And for ampersands, I'm all for using them. So once again, feel free to do so.

As for the folder, we have three types of style folders at the moment:

In addition to that, we still have a bunch of inline styles that we'd like to clean up (but haven't taken the time to do so yet).

We're open to changing that structure, but themes should likely stay separate.

GuilhermeHideki commented 4 years ago

Is configuring stylelint for scss code a blocker for this issue?

GuilhermeHideki commented 4 years ago

Files:

heyhippari commented 4 years ago

We currently have a large number of media queries with different breakpoints. From a quick look in the source they are all over the place (32em, 50em, 84em, 70em, 34.375em, 31.25em, 720px, 1000px, 37.5em, 68.75em, and many, many more).

The logic of these is a bit lost on me, so I propose the following: adopt Bootstrap's breakpoints.

They have the following:

Phone (portrait): 0
Phone (landscape): 576px
Tablets: 768px
Desktop: 992px
Large Desktop: 1200px
Very Large Desktop: 1400px

This gives us a rational set of breakpoints, while having a familiar (and limited) set that is not confusing for contributors and is battle-tested by what is likely the largest CSS framework out there.

thornbill commented 3 years ago

Everything except for themes has been converted to Sass now. Themes will require some additional webpack configuration to be individual outuputs since they are loaded in dynamically at run time.