-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
enhancement: improve how extenders can add global CSS to editor and frontend #48454
Comments
There is no need for extra CSS and media queries, use build-in fluid font sizes: https://make.wordpress.org/core/2022/10/03/fluid-font-sizes-in-wordpress-6-1/ |
@tresorama Congratulations on working on your first block theme! Super exciting stuff. I completely understand that the documentation which is work-in-progress might be overwhelming when there's so many new things to learn. That doesn't necessarily mean Gutenberg is a mess right now, just that it takes a bit more effort than what you're already familiar with. I think this isn't a problem of what's possible, but of the approach you're taking. It's discouraged to overwrite the font size like this, cause it breaks the option to change the font size in the block's settings. First you define font sizes in your theme.json. If it's an external theme and you're a plugin developer, you can define font sizes in your stylesheets in block.json, one for both front- and backend and one for just the backend. If you want to alter an existing block, try block variations. Good luck! |
I explain my block theme workflow to have more context. I try to do almost everything on This is the design system primitive. Then i go in the editor and create template parts and templates, extracting these into While designing/developing templates in the block editor I use core blocks only and adjust font size, padding, color, using tokens defined in Then i check my templates and page with So i started researching how to compensate for responsiveness, and tried different plugin also. This is what i found.
Other key aspect ,at least for me, that made me prefer CSS utilities classes:
So I tried to adopt this "way" to deal with responsiveness. This mens that i "design" the desktop version with the UI, and apply overrides with CSS utilities only for Coming back to original question, that was "how hard is to add a global CSS file, that will be loaded both in frontend, both in editor iframe", there is a better solution than what i describe in the blogpost attached in this issue. I was not aware that |
What problem does this address?
While working on a block theme for the first time, i was stuck at loading a global CSS with utilities classes inside.
The Developer experience is a mess currently.
This should be improved because extenders (theme dev /plugin dev) are crucial for Wordpress.
There are various bad "things" currently in place that a dev must fight against to complete a simple task.
I have made a tutorial post to illustrate the process
https://jacopomarrone.netlify.app/blog/load-global-css-in-block-theme-in-wordpress
Main Painponts
Should be easies to inject a simple CSS. With Javascript ??
We should know that iframe receive CSS assets only if some CSS selector are present. This alone is big ALARM that maybe a refactor is necessary.
Inject CSS to the editor iframe should be done with a dedicated hook or similar process, and now is not present.
Core css specificity is high for an extendible system:
It difficult to say to wordpress when to inject our custom css relative to the theme.json one. This lead us to increase even more the specificity of CSS selectors.
It impossible to add a medium amount of CSS without a CSS preprocessor that support nesting.
Imagine a child theme that want to overrides ?!?!?
Related
#48437
#41821
#38673 (comment)
#33212
What is your proposed solution?
Start discussing about how to improve these, and if necessary :
The text was updated successfully, but these errors were encountered: