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

Fix floats #40

Merged
merged 1 commit into from
Mar 7, 2018
Merged

Fix floats #40

merged 1 commit into from
Mar 7, 2018

Conversation

jasmussen
Copy link
Contributor

Starts work at #39.

This PR makes floats work in Gutenberg Starter Theme, right alongside wide and fullwide images. Captions work too. Before:

screen shot 2018-03-07 at 10 03 51

After:

after

However due to the addition of the inline max-width style added by Gutenberg, this PR features an !important modifier. We should strive to make changes to Gutenberg upstream, so that this is not necesary. While potentially we could find a different way to combine floats with wide and fullwide images (see https://themeshaper.com/2018/02/15/styling-themes-for-gutenberg/), the method used in this PR (based on https://codepen.io/joen/pen/oEYVXB?editors=1100) is fairly elegant in that (aside from captions) reduces complexity and the need to hide horizontal scrollbars occurring from the vw unit.

There are two issues at the core of it.

The first is that the figure element, which is a semantic element for wrapping images and captions, has no intrinsic width like the img has. That means unless we explicitly set a width on this element, it will default to filling the full available space. This is why Gutenberg adds a max-width to a floated figure, to essentially take some burden off of theme devs.

You could potentially make the figure element be inline, but then you wouldn't be able to center captions below the image. You also wouldn't be able to use this method for having wide images and floats coexist, you'd have to use something like the vw approach.

Upstream, this is tracked in WordPress/gutenberg#5292, and is also discussed in depth in this PR: WordPress/gutenberg#5209 (comment)

Unless we rethink how floats behave in a gutenberg/wide images world, I feel like the best approach is what is taken in this PR: WordPress/gutenberg#5460 — it basically adds additional markup to floated images (essentially fixing WordPress/gutenberg#5292). It's not as pretty, it's not semantic, and if a better idea surfaced I'd probably prefer that. But as it stands that's my best bet at how to proceed.

Starts work at #39.

This PR makes floats work in Gutenberg Starter Theme, right alongside wide and fullwide images. Captions work too.

However due to the addition of the inline max-width style added by Gutenberg, this PR features an !important modifier. We should strive to make changes to Gutenberg upstream, so that this is not necesary. While potentially we could find a different way to combine floats with wide and fullwide images (see https://themeshaper.com/2018/02/15/styling-themes-for-gutenberg/), the method used in this PR (based on https://codepen.io/joen/pen/oEYVXB?editors=1100) is fairly elegant in that (aside from captions) reduces complexity and the need to hide horizontal scrollbars occurring from the vw unit.
@karmatosed karmatosed merged commit 339b62a into master Mar 7, 2018
@karmatosed
Copy link
Member

Thanks for this every step helps with this issue!

@kjellr kjellr deleted the fix/floats branch July 24, 2019 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants