-
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
Image Block: Add "full width" control option #518
Conversation
blocks/library/image/style.scss
Outdated
&[data-align="full"] { | ||
width: 90%; | ||
max-width: none; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we center the image as well?
&[data-align="full"] {
img {
margin: 0 auto;
}
}
Not a huge fan of over nesting selectors but YOLO!
The formatting and application of the attribute works 👌, however when the image goes full width on a larger screen it is not centered, like I would expect it to be. Not sure what the expected behavior should be. Other than that, it looks good to me. Also totally 👍 on data-align=full, I saw somewhere else where it was brought up that full-width was not an alignment. Maybe that is true, but I am pretty sure most people will understand and this works a lot cleaner than having all sorts of names. |
editor/modes/visual-editor/index.js
Outdated
<Inserter /> | ||
<div className="editor-visual-editor__container"> | ||
<Inserter /> | ||
</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any context to this change for this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any context to this change for this PR?
To preserve the common max-width of 700px across blocks while still allowing blocks to escape out of it, the responsibility of assigning the max width was moved from the listing to the block itself. Without the changes here, the inserter would be shown to the far left of the editor canvas since it's not a true block, but should respect alignment with the rest the blocks (effected with the container).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah makes perfect sense.
blocks/library/image/style.scss
Outdated
@@ -15,6 +15,11 @@ | |||
float: right; | |||
margin-left: 15px; | |||
} | |||
|
|||
&[data-align="full"] { | |||
width: 90%; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's 90% here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is trying to go full-width but not too full-width. 100% would probably make more sense though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was a number pulled out of the air 😄 But yes, specifically it's a value close to 100% while still allowing space for the block mover.
This includes a new `align-full-width` icon. Heads up #518 Dashicons PR here: WordPress/dashicons#180
Added a new full width icon in #521
|
Maybe just |
Good catch on this @BE-Webdesign . I guess there's a question of: Do we want to force the image to take up the full width of the canvas? Its natural width (with |
I would say natural width to prevent images from overly distorting. If you want an image to fill up more space, use a bigger image. On super hi res screens, if we go full width of the canvas, images will look really silly compared to the text content. The arbitrary "expanded" might work the best, I would go with 1130px for the max-width for a nice ratio between the two. Whatever works really, I wouldn't over think it too much, the 0 auto at least will guarantee the image is centered setting the width of the image might make more sense though and a theme can change how full width looks for that theme. |
I meant to respond to this previously, but clearly missed out on this one too. Full-width, née "full bleed", is close to my heart. I feel strongly that it should be truly full width. Edge to edge. Definitely in the editor, and depending on technical implementations, also in the theme itself. Try viewing the example post, and scroll down to this image: That's the look that we're going for with this one. Big and bold. If we are too concerned about it being mega huge, we could add another option which is could be the "wide", but I still think there's a case for going edge to edge. That being said, there are some technical challenges. The UI prototype used this trick to go edge to edge, despite any max-widths applied to the main content colum:
The problem with that one is that the This suggests that we may want to leave it up to the theme itself to decide what to do, and simply apply a CSS class to the image. |
Yeah, I think it really depends on how the theme authors would use this attribute. The class already exists with the changes here, it's just deciding how to display it in the editor. The problem with the prototype version is that there's no way to move the block up and down, hence the 90% here. |
Yep. We had some ideas for this, and I'm still thinking about that. Right at this moment, I think it's okay that you can't move it when full bleed (because the controls are off screen). If you need to move it, you can temporarily pick a different alignment, or move the blocks before and after, or use drag and drop. However if in practice we find that this is annoying, let's revisit and perhaps we can move the position of the mover for this look. |
df1a6b6
to
9e5ad31
Compare
Rebased to address feedback and incorporate the new icon. But there's a hiccup now in that floated images no longer respect the block maximum width. Will have to poke at this a while longer to see if there's another way to "escape" the container. |
I've noted down a few articles on how to escape the container, perhaps worth looking at: https://css-tricks.com/full-width-containers-limited-width-parents/ There was also this one, which I thought was particularly promising: https://css-tricks.com/hassle-free-full-bleed-not/ |
@jasmussen Thanks for the links. That first one was particularly great in breaking down considerations; for us, the "non-% Parent Width" case. Inevitably this includes the viewport width unit which, as you've mentioned, doesn't account for the presence of the sidebar. I still went down this path in a2d8372, using To the other link: The issue is that if we move the burden of managing max-width and centering to the block itself, it becomes equally difficult to come up with a solution for the floated images to be aligned to the invisible left and right barriers of adjacent blocks. |
Yep, I learned of this in the example post with the left floated quote. 👍 |
@jasmussen How do you feel about the solution using |
Haha yes indeed. I personally find the unit completely useless as it presumes there are no scrollbars, and especially for Windows users, there are. However I'm also pragmatic enough to swallow that pride when presented with something that works. If it works, and works well, ship it! (And just to be clear, "works" means that there are no horizontal scrollbars, when Mac has them set to always show.) I'm assuming themes can still choose not to use |
Might have been duplicated from :before pseudo-element hover/focus bounds border
Theme styling in general needs more thought, but it would be my assumption that this would be entirely up to the theme to implement based on the presence of the class, yes. |
a2d8372
to
7f62ea7
Compare
Related: #310
Related: #416
This pull request seeks to add a new "Full width" option to the image block controls, intended for cases where the image is to break out of any constraining container.
Open questions:
Testing instructions:
Verify that the full width option can be toggled like other image alignment controls (#416), and that it visually breaks out of the editor container.
Future considerations:
align-center
icon, as there's not a Dashicon yet which fits well for the intended action. @jasmussen has committed to incorporating one.