-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Custom Gutenberg editor styles break the Dashboard #4001
Comments
I don't think so, I expect theme developers to extract the "blocks" and "common typography" styles to a dedicated stylesheet loaded both in the editor and in the frontend. So it's just a matter of reorganization, not adding something new. |
In the past, the clean way to do this would be to do exactly what you said - extract a few styles and font sizes out of your stylesheet, use Gutenberg-view currently is still very different from what you get on your site. I want to narrow that gap, at the same time I don't wan't to do the work twice. Loading an extra stylesheet on the front-end just because of Gutenberg doesn't seem like a solid solution to me. A band-aid solution I can come up with is to have 2 top-level pre-processor stylesheets: I can't wait for the twentyeighteen (or is it twentyninteen?) theme development to start. This is going to be an interesting issue for me to track. |
You can do the following in Gutenberg:
Closing as this isn't broken, you can do that above and get styles in the editor. |
Hey @karmatosed - notice that in my first post I said I can do something similar with Please reopen the ticket, as the issue I'm talking about is theme styles are bleeding into the dashboard styles and not "how to enqueue" theme styles. At the moment, it is very hard for a theme developer to achieve WYSIWYG with Gutenberg, and I really hope that changes until WordPress 5.0 is released, because WYIWYG is what Gutenberg is all about, isn't it? |
I absolutely am ok opening it, I will admit it read as though you weren't doing the same as had issues I was not experience in testing, but totally let's dig in more. That's the awesome thing with tickets, we can reopen :) I am not seeing my own editor styles bleeding, so can you perhaps link fully what styles you are doing and we can see. Maybe you have a sneaky one we need to tie down. |
@justnorris Those are all very good points and I've been mentally trying to figure out the best current approach for writing CSS. For existing themes it's going to be a little bit different and harder so I personally start from a new theme. Let's share the ideas how to optimaze CSS workflow for editor and front-end. I don't have anything concrete before I actually start building something. |
👋. I have a few thoughts to chime in from my experience applying theme styles to Gutenberg recently. The issue stems from improper editor styles that wouldn't necessarily cause a problem within the pre-Gutenberg visual editor (as they're contained), but will in Gutenberg. For example, quite a few WordPress themes (mostly commercial) are importing entire stylesheets into the current visual editor, which is obviously not a good practice. When developers start add theme styles to Gutenberg using the Instead of having a full-fledged theme-styled Gutenberg editor as seen in the screenshot below: I personally started writing an entirely separate stylesheet for Gutenberg (apart from editor-styles.css), targeting elements/block/content within the Is this something that's up left entirely up to developers do to right? Should there be some catches to prevent this sort of behavior? Do you think a lot of developers will just opt-out of styling Gutenberg because of the issues? |
This is exactly the reason I'm bringing this up. I'm excited that Gutenberg is going to bring an almost WYSIWYG editor in core WordPress. But for a WYSIWYG experience we need theme developers to style for Gutenberg. I think that most developers are not going to write a separate Gutenberg stylesheet if it's not easy enough. By the way, is there somewhere a discussion already on the various elements and how to style them? For example, Gutenberg buttons, quotes ? |
@justnorris great points, I agree completely. The process for themes would be:
We need to make sure the process of styling blocks is easy and polished. Once we agree on that, making it available for the editor is trivial. We are going to need some additional ways to style other pieces of the editor (main column width, bg, etc) that is not directly (as of this moment) block related. It might be in the future with full-on customization (a Post block, etc). So we need to take those into account as well. The biggest challenge there is how to style the container easily without having to know too many classes, or dealing with wp-admin cascade. We cannot use an iframe, but we might be able to employ Shadow DOM for it. |
Related: #5360 |
The classic editor was rendered in an iframe, which meant that theme developers could easily do this:
Something similar can now be done with the
enqueue_block_editor_assets
hook:However, because there is no longer an iframe - the styles are applied globally, so applying the main theme stylesheet is going to break the dashboard.
Does this mean that theme developers will have to write and maintain an entirely separate stylesheet just for the editor?
The text was updated successfully, but these errors were encountered: