Skip to content
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

Improve handling of centered 1-col galleries with small images #11040

Merged
merged 2 commits into from
Oct 25, 2018

Conversation

jasmussen
Copy link
Contributor

If you insert a gallery that has a single column, and multiple smallish images, then center it, the images inside do not appear centered.

This is technically correct, since the gallery itself is centered, but because it's full width and because the images might vary in widths, this doesn't appear to make any difference to the content inside. So although "correct", it's not a good user experience.

This PR simply centers the content also.

This fixes #9531.

Centered 1 column gallery with small images before:

before

After:

after

Note this also has the following effect if you apply more than one column, while centered:

screen shot 2018-10-25 at 09 44 59

But that's fun! And remember, that's only if you disable cropping. If you enable cropping again, you get this recognizable friend:

screen shot 2018-10-25 at 09 45 04

If you insert a gallery that has a single column, and multiple smallish images, then center it, the images inside do not appear centered.

This is technically correct, since the _gallery itself_ is centered, but because it's full width and because the images might vary in widths, this doesn't appear to make any difference to the content inside. So although "correct", it's not a good user experience.

This PR simply centers the content also.
@jasmussen jasmussen added the [Type] Enhancement A suggestion for improvement. label Oct 25, 2018
@jasmussen jasmussen added this to the 4.2 milestone Oct 25, 2018
@jasmussen jasmussen self-assigned this Oct 25, 2018
@jasmussen jasmussen requested a review from a team October 25, 2018 07:48
Copy link
Member

@jorgefilipecosta jorgefilipecosta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes work as described 👍 I left a comment regarding the usage of editor specific selectors on frontend styles.

@@ -148,4 +148,12 @@
&.alignright {
display: flex;
}

// If the gallery is centered, center the content inside as well.
[data-align="center"] &,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @jasmussen is [data-align="center"] &really needed? It looks like even in the editor the align center class is being applied.
If it is really needed I think we should add this selector in editor.scss. I think this selector will never be used on the frontend and is editor specific, so we should avoid sending editor specific CSS to sites frontend.
I checked that we have other editor selectors in this file we should probably remove them as well maybe in other PR as it is not related to this changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The data-align properties, I'm almost completely convinced, used to be necessary in order for the styles to take on both front and editor, as in editor those alignment classes were not present. I may be misremembering, but I'm almost certain, which is why those classes were also present for left and right alignments. Those are all removed now, in fedf089, because as you note, they seem to be present, and it's working:

screenshot 2018-10-25 at 14 14 17

Those alignment classes are still not present for images, but I suppose that's a separate issue.

Copy link
Member

@jorgefilipecosta jorgefilipecosta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for iterating on this changes they look good to me 👍

@jasmussen jasmussen merged commit 37e6b13 into master Oct 25, 2018
@jasmussen jasmussen deleted the fix/centered-uncropped-gallery branch October 25, 2018 14:03
antpb pushed a commit to antpb/gutenberg that referenced this pull request Oct 26, 2018
…ress#11040)

* Improve handling of centered 1-col galleries with small images

If you insert a gallery that has a single column, and multiple smallish images, then center it, the images inside do not appear centered.

This is technically correct, since the _gallery itself_ is centered, but because it's full width and because the images might vary in widths, this doesn't appear to make any difference to the content inside. So although "correct", it's not a good user experience.

This PR simply centers the content also.

* Remove editor specific alignments.
daniloercoli added a commit that referenced this pull request Oct 26, 2018
…rnmobile/merge-blocks-on-backspace

* 'master' of https://github.com/WordPress/gutenberg:
  Do not add isDirty prop to DOM (#11093)
  Format API (#10209)
  Remove 4.2 deprecated features (#10952)
  Update `@wordpress/hooks` README to include namespace mention (#11061)
  Feature: save lock control via actions (#10649)
  Fix usage of `preg_quote()` (#10998)
  Update plugin version to 4.1.1 (#11078)
  Improve preloading request code (#11007)
  Fix dynamic blocks not rendering in the frontend (#11050)
  Media & Text: Fixing vertical alignment of the image (#11025)
  Date: Mark getSettings as experimental (#10636)
  Improve handling of centered 1-col galleries with small images (#11040)
  Use better help text for ALT text input; fixes #8391. (#11052)

# Conflicts:
#	packages/editor/src/components/rich-text/index.native.js
@mtias mtias added the [Block] Gallery Affects the Gallery Block - used to display groups of images label Oct 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Gallery Affects the Gallery Block - used to display groups of images [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Alignment: problem with centering gallery
3 participants