-
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
Body classes based on page template #7810
Comments
@ktmn, @danielbachhuber Please see #8948 |
I would very much like to see this too. I think the ultimate goal for Gutenberg should be that the editor is WYSIWYG with the front-end. I know at least in the initial release that isn't the case. For example, the default editor width is only 640px. So they are leaving up to themes for now to control the editor width (and of course the front-end width). But without the same body classes that indicate the page template, this is impossible to do with CSS alone. Does anyone have any details as to how a theme might go about doing this? Like what editor filters to use and some sample JS to do it? But of course I really want this in core GB so that its easy for themes to handle it with simple CSS. |
@timnicholson Please see my JS solution you can currently work with (though it seems to have a flaw I haven't had time to look at yet...) |
Based on the code here, I made a little tutorial (sage9 based theme): https://discourse.roots.io/t/gutenberg-body-class-elements-by-template/15310 |
Is your feature request related to a problem? Please describe.
Page templates can have varying widths on the front end. In order to reflect that on the editor side it would be good to know which page template is currently selected.
Describe the solution you'd like
Add page template slug to
<body>
classes on the Gutenberg page and update it automatically when template is changed in page attributes.So you could do something like:
Describe alternatives you've considered
Alternatively you can let page template comments contain something like this:
and handle it automatically, making it easily possible to change the width when the template gets major changes in the child theme or when creating custom ones.
But at the end of the day body classes wouldn't hurt, could prove useful for other use cases as well.
Note
It's already possible to do this for post types for example, since they are already included in the body class:
Question
Is CSS like even the recommended way to alter the editor width or is there anything else available/planned?
The text was updated successfully, but these errors were encountered: