-
Notifications
You must be signed in to change notification settings - Fork 279
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
Modularize CSS #315
Comments
Thank you for this feedback, @iamkunaldesai. We would like to modularize the CSS too. I'll leave this issue open as a placeholder for that future work, and to discuss the strategy here before the implementation is done. |
Questions I have about the basic implementation of this that anyone reading is free to contribute answers to:
Once we have some opinions on these, the next steps would be to:
|
Great summary @nickcernis ! As a small agency building a lot of custom themes over the years we having explored a lot of this territory and I've got opinions.
¯_(ツ)_/¯ We're 100% SCSS. I'd be totally fine with moving to PostCSS or PlainCSS+Features. As much as this is about neatly modularizing the files, for me the far more important part to get right is the build script. (specifically running it through autoprefixer and building a css sourcemap). Hence I'm not concerned about which pre-css language, but rather that whatever the build process is, it allows folks to easily swap between them. I'm confident whatever is chosen, someone outside will maintain a forked version converted to their preferred style. Converting the CSS and their plugins/mixins/etc... is generally not difficult until you get into very advanced and complex approaches that I wouldn't expect in sample.
No. I think we should just give users the option to use source files or the compiled files as a starting point, but they should always be modularized. For the former we'd just give users the intructions: "If you do not wish to use the build tools / modularized CSS as a starting point you can safely delete the /scss folder (/assets, etc...), and then use the following css files as your starting point. An important question becomes, do you use style.css at all?
Per above, I'd communicate to the developer how to ignore/remove, heck concatenate if they wish, the modular content but I wouldn't maintain two versions. Part of the goal of Genesis Sample is to teach, so teach rather than try to accommodate every need.
Per above, invest more energy in teaching them how to tweak sample (and not just for this). We still run across sites built by others where the theme NAME is "Genesis Sample"... In some cases people using sample don't even know how to rename a theme!
100% Modular loading. I think Tadlock's article is the best (in terms of discussing the topic, not necessary in advocating the best solution), but Yoast (Jono) did some writing on the topic of modular css How far to go with that I don't have an answer to though. ie. main.css, sidebar.css, footer.css... or all the way to individual blocks like some advocate. I will say @billerickson turned me onto having a single blocks.css file that could be loaded back (same for editor-style.css) and front end and that's been awesome.
We usually do: We've organized it lotsof different ways though, I guess the next most often is: That's kind of nice if you're pulling assets (npm/bower/composer) into your destination directory and not processing them. More likely JS than CSS, but same idea.
See above... Load the exact same CSS file on the front end and block editor. |
This is the main reason I have a custom starter theme based on sample rather than just using sample directly – I'm not willing to reorganize the css and spit it into more manageable files every time I spin up a new site. I'm doing this to better use sass, not because I want to load more files for load speed. I'd love to see scss/sass used, ideally with a build process in place for it. There are three types of css files that need to be loaded:
Really, though, those three categories only apply to the component files. The compiled files should generally either be loaded on the frontend or the backend, not on both (some component files can be @included into both the frontend and backend files). I'd also love to see different organization of css: I think the media-queries file/chunk of code isn't the ideal way to handle media queries. I'd rather see that done inline, so that if you're looking at how the sidebar should style on mobile, you'd look to _sidebar.scss and not to media-queries, since that's a more logical place to look.
As long as it compiles down to css (and not postCSS or something like that), I don't know why it would affect the average user at all in that way.
In my own themes, style.css is blank, and I compile everything else into a frontend and into a backend file. I don't know why I do it that way, though. I have a global.scss file that's the first thing to load in all of the individual scss files so that color variables, media query includes, etc. are being loaded consistently in both the frontend and backend files. Anyway, just saw this and got excited about it and thought I'd share some of my own practices in case they spark any useful ideas. |
definitely Sass the current theme has a lot of bugs in the CSS |
I'd like to add my opinion in response to @nickcernis points above:
|
In the era of HTTP/2 it is better to have multiple smaller CSS than a One big one.
Current CSS can be divided into 3-4 parts.
Here the print css can be added seperately which will load only if you print the webpage.
Just suggesting.
The text was updated successfully, but these errors were encountered: