-
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
Gallery: Use space-between instead of negative margins #9670
Conversation
style: Add align rules to gallery
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.
Hi @SofiaSousa thank you for your contribution 👍
I think one of the reasons for the use of negative margins was to align the gallery with the placeholder and with the content of other blocks, e.g., the paragraph.
And with this changes galleries are a little bit out of the content area.
Before:
One option we have to make the gallery look inside the content area is move the margins to the editor.scss file so they only affect the editor, and on the front end, we avoid the negative margins.
On the front end, the difference I noticed is that the space between the images got a little bit bigger.
@jasmussen, @karmatosed would it be possible to have a look at the design changes.
Thanks so much for the PR! From the branch name, Jorge is right, the reason for the negative margins was to ensure the gallery was both spaced evenly between images, but also was only as wide as the main column of text and placeholders. I'm not opposed to using space-between or more flexiness, but I need to understand the problem this is trying to solve first. I'm notably a little concerned about the new float rules (https://github.com/WordPress/gutenberg/pull/9670/files#diff-9ffb7855d1c617407b369408c6c01fe4R99), given we've had some challenges with floats in the first case. |
Well we are trying to use gutenberg outside of the box, I mean outside of the wordpress and wordpress core style. The margins in So the solution I saw was removing |
Hmm that's a good point. I will think about how this can be done, but a plan B could be to move those margin styles to |
The stock gallery features white gutters between items. Currently in `master`, every item has an even 8px margin all around. We then compensate for this, left and right, of the gallery, to make sure items in the gallery align correctly with text width above and below the gallery. This PR attempts a different approach. It sets only the right and bottom margin on gallery items, and then unsets the right margin on the rightmost item in each row. This is a little more complex in the rules that are output, but it solves the issue presented here: #9670 (comment) Let me know your thoughts.
@jasmussen @SofiaSousa, should we close this one in favor of #10027? |
@jasmussen yes, thanks! |
* Try a simpler spacing setup for gallery items The stock gallery features white gutters between items. Currently in `master`, every item has an even 8px margin all around. We then compensate for this, left and right, of the gallery, to make sure items in the gallery align correctly with text width above and below the gallery. This PR attempts a different approach. It sets only the right and bottom margin on gallery items, and then unsets the right margin on the rightmost item in each row. This is a little more complex in the rules that are output, but it solves the issue presented here: #9670 (comment) Let me know your thoughts. * Clean up the mess. Remove debug comments. Sorry, long day. Clarify comments. * Address feedback. * Address feedback. * Bugfix. * Adjust gallery css layout math, and ensure margin is reset correctly at mobile breakpoints Co-authored-by: Sofia Sousa <[email protected]> * Fix odd rule Props @SofiaSousa * Add fixed rule
Description
Using
justify-content: space-between
in gallery block instead of negative margins. Also removed margins of gallery items.Added missing alignment rules for galleries.
How has this been tested?
In the browser, adding 3 images to a gallery block for example and checking the width and space between images.
Types of changes
Just style.
Checklist: