Closed h1nk closed 3 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.
Dependent on #681
Should be dependent on https://github.com/jellyfin/jellyfin-web/pull/862 now, right @MrTimscampi?
Yep, I need to go through the issues to see what I can mark as fixed in #862
@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?
@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.
@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:
I basically ran:
> yarn serve
> git mv .\src\assets\css\site.css .\src\assets\css\site.scss
> # Edit the files accordingly...
@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.
Hi! I was looking into the files and would like to ask somethings
:root {
--subtitle-color: white;
}
.videoSubtitles {
color: var(--subtitle-color);
}
/src/stylesheets/mixins.scss
?
@mixin position($position, $top: null, $right: null, $bottom: null, $left: null) {
position: $position;
top: $top;
right: $right;
bottom: $bottom;
left: $left;
}
.videoSubtitles {
&Inner {
}
}
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:
:root
and :host
rulesetsvar()
is limited to property valuesSo 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:
src/assets/css
contains "general" styles that probably require the most cleanup. Much of the global UI styles are defined there, instead of in per-view or per-component files.src/themes
which contains the various themes (A lot of duplicate lines in there that can probably be cleanup up).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.
Is configuring stylelint for scss code a blocker for this issue?
.stylelintrc
warns about the '@include' (and other sass constructs)
plugin/no-browser-hacks
raises false positives for scss variables, like $my-variable
Files:
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.
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.
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)