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

Try: Improve floats UI. #10085

Merged
merged 2 commits into from
Oct 6, 2018
Merged

Try: Improve floats UI. #10085

merged 2 commits into from
Oct 6, 2018

Conversation

jasmussen
Copy link
Contributor

This PR tries to improve the block UI on floated elements. It does a few things:

  • It hides the side UI entirely. Because this is now just the ellipsis and drag handle, this is not the end of the world. The argument being, that when you need to move an image up or down, you do it before you float. And the side UI overlapped with parents anyway, so the only alternative was to use the mobile UI (buttons below the block), for floats. This was not as compelling as initially thought.
  • Because the block outline is hidden on floated UI anyway (it has to be, because it doesn't know how tall the floated content is due to the nature of floats), the toolbar looked offset to the side. This PR positions the block toolbar to better align with the float.
  • Improves the mobile UI for floats, it was quite broken.
  • It adds a min-width to embeds, which after the most recent responsive feature would collapse completely when floated.

Screenshot. No side UI:

no side ui

Improved mobile UI:

improved mobile positioning

Min width for embeds:

min width for embeds

Right floated toolbar positioning:

positioning for right floated

Left floated toolbar positioning:

positioning for left floated

@jasmussen jasmussen added the [Type] Enhancement A suggestion for improvement. label Sep 21, 2018
@jasmussen jasmussen added this to the 4.0 milestone Sep 21, 2018
@jasmussen jasmussen self-assigned this Sep 21, 2018
@jasmussen jasmussen requested a review from a team September 21, 2018 09:01
@chrisvanpatten
Copy link
Contributor

This would also close #7492.

@ZebulanStanphill
Copy link
Member

It feels like bad UX to me to make it impossible to move a floated block. Perhaps if there were keyboard shortcuts for moving blocks I would not mind, but I wish there was some way to still move the floated blocks. In the Classic Editor, you would just click and drag an image to move it. Is there any reason why the same behavior could not be implemented in Gutenberg?

@jasmussen
Copy link
Contributor Author

It feels like bad UX to me to make it impossible to move a floated block.

I don't necessarily disagree. But I also strongly subscribe to the idea of iteration. In that vein, this feels like a step forward compared to what's in 3.9, and also a step that doesn't preclude further improvements later on.

Drag and drop is, on principle, someting we consider an additive enhancement on top of other explicit mover controls. That is to say — it's not that we can't do it, it just has to be in addition to other features.

I do really like the idea of shortcuts for moving up or down, haven't we a separate ticket for this?

@ZebulanStanphill
Copy link
Member

@jasmussen Fair enough.

I do really like the idea of shortcuts for moving up or down, haven't we a separate ticket for this?

If it exists, I can't find it.

@jasmussen
Copy link
Contributor Author

Here it is: #71

If we can think up a good keyboard shortcut for "move up" an "move down" we can create a new specific ticket for that. Should be easy.

@chrisvanpatten
Copy link
Contributor

Because the block outline is hidden on floated UI anyway (it has to be, because it doesn't know how tall the floated content is due to the nature of floats)

I'm pretty curious about this. I was playing around with this recently and didn't see any notable issues with having a block outline for floated content:

edit_page_ tomodomo _wordpress

Is there any context on this in a previous ticket?

@jasmussen
Copy link
Contributor Author

Is there any context on this in a previous ticket?

First off, I'm not against floats having outlines. If we can make it work, PRs will be fast-tracked ;)

Although I can't find the PR now (looked in my closed PRs because I'm pretty sure I removed them), I THINK it's related to the overall float refactors, which now use this method: https://codepen.io/joen/pen/YOZRWP

The overall idea is: the float container is not floated, but the figure inside is floated. Because by keeping the float container the same width as the main column. we can ensure that the figure floated inside aligns itself to this very main column, and allowing the main column to be constrained only by a max-width. The float container then collapses to zero pixels height, so that it's invisible. But it's still there to constrain the float to match the main column width.

By doing all that we can trivially add wide and fullwide images by simply removing the max-width on those blocks, and we don't have to resort to crazy vw units or calc statements.

Put it differently: if you can make it work with boundaries also on the frontend in the gutenberg starter theme or https://github.com/jasmussen/navi, then 👍 👍 ✊

@chrisvanpatten
Copy link
Contributor

@jasmussen happy to take this into slack but with the block outlines it shouldn’t really matter on the front-end, right? Or do you mean because of a potential collision with editor styles?

@jasmussen
Copy link
Contributor Author

happy to take this into slack but with the block outlines it shouldn’t really matter on the front-end, right? Or do you mean because of a potential collision with editor styles?

That's right, but the way that we paint the block outlines right now, I can't think of a way to paint them around the floats, the way we do them.

But that doesn't mean it's not possible, and to be clear I'm not against them being there at all!

This PR tries to improve the block UI on floated elements. It does a few things:

- It hides the side UI entirely. Because this is now just the ellipsis and drag handle, this is not the end of the world. The argument being, that when you need to move an image up or down, you do it before you float. And the side UI overlapped with parents anyway, so the only alternative was to use the mobile UI (buttons below the block), for floats. This was not as compelling as initially thought.
- Because the block outline is hidden on floated UI anyway (it has to be, because it doesn't know how tall the floated content is due to the nature of floats), the toolbar looked offset to the side. This PR positions the block toolbar to better align with the float.
- Improves the mobile UI for floats, it was quite broken.
- It adds a min-width to embeds, which after the most recent responsive feature would collapse completely when floated.
@jasmussen jasmussen force-pushed the try/better-floats-ui branch from 9199dd4 to 8a780fc Compare October 1, 2018 21:19
@jasmussen
Copy link
Contributor Author

Rebased & Squashed.

Copy link
Contributor

@mcsf mcsf left a comment

Choose a reason for hiding this comment

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

I agree we should keep the momentum. Let's get this in and iterate!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants