-
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
Block width (content width) needs to be resizeable #1483
Comments
Just to add some references, and note there was some discussion about the Also, other minor references: |
Good ticket. Let's explore a hypothetical for a moment, though — pure speculation and daydreaming. What if there was no editor stylesheet ( |
From a readability point of view, once you go too wide (although there is discussion on what is too wide: https://www.paulolyslager.com/optimal-text-layout-line-length/) it can get harder to read the lines of text. Right now I'm seeing that the box has 65 characters (the lowercase x) which is considered pretty optimal (although there are variables of course) There are a few approaches you could take:
I think option 2. makes the most sense. Agreed/disagreed? Edit: Another option could be to allow for increasing the font as you increase the width of the content area. From this article: http://mikeyanderson.com/optimal_characters_per_line. From this article: "I’m sick and tired of cramped websites that have tiny type and don’t use the whole screen well." |
As I mentioned above, I'd prefer to see it use the I very rarely see themes displaying extremely long lines of text, for the exact reason you mention. They're too hard to read. Using the same width on the edit screens, as is being displayed on the front-end, keeps a consistency between the two. |
Ah I missed that! I think that's a great idea for the editor to use the same size as the frontend. It would help if the fonts were the same too.. I know WordPress uses the default system font, and a theme could use any font. If the fonts stay different then it won't be a perfect comparison. Is that a concern? |
@jwold Ideally, a theme should make use of the |
I think this makes sense. Do you think there's value in defaulting to the width of the frontend and then giving you the ability to change it for writing your posts? That way if I prefer it wider or shorter I can just focus on writing and not worry about the final output. |
I think that would be great. You get the best of both worlds then. Having it default to the front-end width but also the option to change it if you prefer. Sounds perfect! 👍🏼 |
That would be the "grand finale" moment when the content creating experience will be consistent all over the place: while editing and on the front end preview. I highly support this approach, even if we provide some core styling for blocks that are automatically loaded into the front end until the theme adds support for them. These days of dynamic and responsive design, I cannot imagine a static defined |
See also #2420 |
@maddisondesigns, this was reviewed during a Gutenberg bug scrub today and the following came from the discussion:
|
As per a recent refactor, the Gutenberg variables stylesheet now includes a single This variable is currently used in 11 places: Although we are in a responsive and mobile first world, probably themes or even blocks will probably always, for flexibility reasons, need to know what the width of the main column is. JavaScript and mixins could probably reduce this dependency further. Noting this as context for anyone who might want to take a stab at connecting the |
I think the existing fixation of content width in Gutenberg is - according to a lot of Gutenberg reviews - a really big problem for a lot of people. So this should be addressed in the Gutenberg core before going live with WP 5.0! Let me collect the arguments to change something: |
At the very least could the editor default to 100% width so it can mimic a real page? It's really weird dragging something inside a column block when it's so narrow, but will actually render full screen. |
One way you can change the width of the main column today is the following. Paste this in your
Now create a new CSS file in your theme directory,
You can set any max-width here, in px, percent or whatever unit you prefer. |
@jasmussen Adding that one style makes a mess of the layout. Check out the following samples: Layout after adding your one style: There's a number of issues:
These are the styles that I've found to work properly:
*Obviously This is what the page looks like after using my styles. I've calculated the max-width for each section based on a customizer setting which allows the user to specify the width of their content on the front-end. |
Nice, thanks for updating those styles. Do you think an editor style like yours could be part of the solution here? It feels like it might get us closer. |
I've found those styles seem to be working ok so far. One of the issues I've found though in trying to get the editor width to match the width of the front-end content, is having to allow for all the extra padding and margin on the containers in the editor. As an example, I mentioned above that in the theme I've edited, I'm calculating the max-width based on a Customizer control. I have a control in the theme that allows the user to specify the width of the main content area on the front-end. e.g. 1200px for example. If I simply set those editor classes all to 1200px pixels, then it still wont match the front-end due to markup used in the editor. So, get the editor blocks to match the same width on the front end, I've had to take into account the various margin and padding of all your block containers. And of course, because this final max-width value is calculated based on a Customizer setting, I obviously can't add the value to a static stylesheet, so this is my full code that's injected into
Obviously, if we could simply set a On a side note, if there was a hook that I could use other than |
Interesting, I thought I had solved that, at least for non-nested blocks (with an incoming fix for nested blocks in #6408). But I can see that there's a 2x14px discrepancy left and right of blocks, that matches the left and right padding. I'll take a look in a bit.
Can |
With a couple of small tweaks, yep, that works. Thanks!
This not a big deal, but it does mean I've had to add a bit more specificity to the styles, like you had in your original example. There's a couple of things I had to do... On the plus side, using the Here's my updated code:
Or to simplify things, these are the styles to now set...
|
🎉 Very cool work, thank you. I would imagine we can continue to refine aspects of this, to improve the hooks, and to make styling the editor more easy — I'm also doing some work on that in #6406. The ultimate goal would be to make it possible to load in your theme style itself, with no changes, so you didn't have to create a separate editor style, but it's likely going to be a while before we can get there. Baby steps. |
Being able to enqueue the same stylsheet on both front-end and back-end sounds great in theory, but not sure how practical it would end up being. At least for the foreseeable few years, our themes on .org will now have to accommodate both the Gutenberg editor and the Classic editor. This means that its not as easy as simply having a separate style sheet for both. For example, there's obviously a lot of common styles that need to be used when using either editor (font styles for example). There's also a considerable amount of styles that aren't compatible with each other, and also styles that we now have to override due to the default styles output by Gutenberg. So yeah, while it sounds like it would be a great idea, I'm a bit doubtful that it would actually work in practice for the majority theme developers, unless you're specifically developing a theme purely for use with Gutenberg only. |
So, given your improved styles in #1483 (comment), could this ticket be closed with some improvements to documentation? I.e. if I wrote some new documentation that showed how to change the theme-width per your code, would that essentially address this ticket? |
Yep, that's fine. Thanks. Having a content width variable would be nice, but those above styles work fine and there's only really 4 styles that need to be set, so it's not a big deal to set them if needed. Having the doco updated for other devs would be great too. Thanks for your help with that. |
This updates the extensibility document, and adds a section around loading editor styles. It gives examples for how to change the colors of the editor (which will look good once #6406 gets merged), as well as how to change the width of the editor. The last part fixes #1483. CC: @maddisondesigns
Created #6531 to update the documentation. |
) * Update theme extensibility documentation to include editor widths This updates the extensibility document, and adds a section around loading editor styles. It gives examples for how to change the colors of the editor (which will look good once #6406 gets merged), as well as how to change the width of the editor. The last part fixes #1483. CC: @maddisondesigns * Simplify syntax a bit. * Trim whitespace
I agree. The editor HTML has very little in common with what the content will look like on the front-end. Loading the whole theme CSS will certainly "bleed" in many places where it shouldn't. Ideally there should be few variables that hold the different widths, and can be reused on the front. These variables can also go in the |
WordPress has a
$content_width
variable that allows you to set the maximum allowed width for any content in the theme. Although this is mainly used on the front-end, in the back-end TinyMCE editor, you can use the following css in your editor-style.css file so that you can set the editor width to match the front-end content width.The editable area in the Gutenberg blocks are currently only 608px wide, which, when used on a large monitor, are pretty tiny. It would be good to see the editor make use of the
$content_width
variable so that we can accomplish the same as the current editor.The text was updated successfully, but these errors were encountered: