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

Show movers next to block switcher #22673

Merged
merged 15 commits into from
Jun 9, 2020
Merged

Show movers next to block switcher #22673

merged 15 commits into from
Jun 9, 2020

Conversation

jasmussen
Copy link
Contributor

@jasmussen jasmussen commented May 27, 2020

Fixes #21935.

One of the most important things the new UI (as detailed in #18667) did, was to unify on a single toolbar, meaning the mover control was included. This afforded a number of benefits:

  • A single control to tab into
  • A single place to look for every basic block manipulation
  • Vastly simplified block CSS and editor styles
  • Unified UI across every block, including floats, wide, and full-wide.
  • A unified location for moving blocks, regardless of direction.

The downside was a wider block toolbar, which we compensated for by hiding the mover control until you hover the block switcher. However the feedback was clear, that the basic mover control was used often enough that it should not be hidden.

This PR unhides it:

movers

The PR takes the most simple approach discussed to unhiding it. This approach does not preclude tweaking the design further — but it can serve as a good baseline, because it is so trivial to implement. And instead of discussing what the best appraoch is ad nauseum, a PR is an excellent way to try this out, and please do try it out, don't just look at the GIFs. As I was working on this, it struck me as feeling intuitive and natural, and not in need of any more visual affordances.

Still todo:

  • Horizontal mover polish
  • Focus polish
  • Drag and drop polish
  • Retire unused functions

@jasmussen jasmussen added the [Type] Enhancement A suggestion for improvement. label May 27, 2020
@jasmussen jasmussen self-assigned this May 27, 2020
@github-actions
Copy link

github-actions bot commented May 27, 2020

Size Change: +497 B (0%)

Total Size: 1.13 MB

Filename Size Change
build/a11y/index.js 1.14 kB -1 B
build/block-editor/index.js 106 kB -279 B (0%)
build/block-editor/style-rtl.css 11.8 kB +374 B (3%)
build/block-editor/style.css 11.8 kB +369 B (3%)
build/block-library/index.js 127 kB -3 B (0%)
build/block-serialization-default-parser/index.js 1.88 kB +1 B
build/blocks/index.js 48.1 kB +1 B
build/components/index.js 194 kB +25 B (0%)
build/components/style-rtl.css 19.5 kB +9 B (0%)
build/components/style.css 19.5 kB +7 B (0%)
build/compose/index.js 9.31 kB +1 B
build/core-data/index.js 11.4 kB -3 B (0%)
build/data-controls/index.js 1.29 kB -2 B (0%)
build/data/index.js 8.45 kB -2 B (0%)
build/date/index.js 5.47 kB -3 B (0%)
build/deprecated/index.js 772 B +1 B
build/dom/index.js 3.17 kB -1 B
build/edit-post/index.js 303 kB -1 B
build/edit-site/index.js 15.5 kB +1 B
build/editor/index.js 44.7 kB +1 B
build/is-shallow-equal/index.js 710 B -1 B
build/keyboard-shortcuts/index.js 2.52 kB +2 B (0%)
build/media-utils/index.js 5.3 kB -2 B (0%)
build/plugins/index.js 2.56 kB -1 B
build/primitives/index.js 1.5 kB +1 B
build/token-list/index.js 1.28 kB +1 B
build/url/index.js 4.06 kB +2 B (0%)
ℹ️ View Unchanged
Filename Size Change
build/annotations/index.js 3.62 kB 0 B
build/api-fetch/index.js 3.4 kB 0 B
build/autop/index.js 2.83 kB 0 B
build/blob/index.js 620 B 0 B
build/block-directory/index.js 6.77 kB 0 B
build/block-directory/style-rtl.css 892 B 0 B
build/block-directory/style.css 892 B 0 B
build/block-library/editor-rtl.css 7.87 kB 0 B
build/block-library/editor.css 7.87 kB 0 B
build/block-library/style-rtl.css 7.72 kB 0 B
build/block-library/style.css 7.72 kB 0 B
build/block-library/theme-rtl.css 684 B 0 B
build/block-library/theme.css 686 B 0 B
build/block-serialization-spec-parser/index.js 3.1 kB 0 B
build/dom-ready/index.js 569 B 0 B
build/edit-navigation/index.js 8.25 kB 0 B
build/edit-navigation/style-rtl.css 918 B 0 B
build/edit-navigation/style.css 919 B 0 B
build/edit-post/style-rtl.css 5.43 kB 0 B
build/edit-post/style.css 5.43 kB 0 B
build/edit-site/style-rtl.css 2.96 kB 0 B
build/edit-site/style.css 2.96 kB 0 B
build/edit-widgets/index.js 9.34 kB 0 B
build/edit-widgets/style-rtl.css 2.4 kB 0 B
build/edit-widgets/style.css 2.4 kB 0 B
build/editor/editor-styles-rtl.css 425 B 0 B
build/editor/editor-styles.css 428 B 0 B
build/editor/style-rtl.css 4.26 kB 0 B
build/editor/style.css 4.27 kB 0 B
build/element/index.js 4.64 kB 0 B
build/escape-html/index.js 733 B 0 B
build/format-library/index.js 7.72 kB 0 B
build/format-library/style-rtl.css 502 B 0 B
build/format-library/style.css 502 B 0 B
build/hooks/index.js 2.13 kB 0 B
build/html-entities/index.js 621 B 0 B
build/i18n/index.js 3.56 kB 0 B
build/keycodes/index.js 1.94 kB 0 B
build/list-reusable-blocks/index.js 3.12 kB 0 B
build/list-reusable-blocks/style-rtl.css 226 B 0 B
build/list-reusable-blocks/style.css 226 B 0 B
build/notices/index.js 1.79 kB 0 B
build/nux/index.js 3.41 kB 0 B
build/nux/style-rtl.css 616 B 0 B
build/nux/style.css 613 B 0 B
build/priority-queue/index.js 789 B 0 B
build/redux-routine/index.js 2.85 kB 0 B
build/rich-text/index.js 14.8 kB 0 B
build/server-side-render/index.js 2.68 kB 0 B
build/shortcode/index.js 1.7 kB 0 B
build/viewport/index.js 1.85 kB 0 B
build/warning/index.js 1.14 kB 0 B
build/wordcount/index.js 1.17 kB 0 B

compressed-size-action

@ZebulanStanphill
Copy link
Member

The recently-introduced parent-selector button now feels a bit more awkward since the switcher + movers are a different shape. It also feels a bit weirder since the movers are no longer sticking out on the left. That could be just a matter of needing to get used to it, though.

image

The arrows appear off-center when focused, which feels just a bit weird. Either the arrows need to be moved a bit to the right, or the buttons need to become a bit wider; I'd prefer the latter.
image

It's now really odd that you can drag the block from either of the mover buttons, but not the block switcher/icon. I think the drag area needs to be extended to include that button.

Overall, I like how the movers are more clearly surfaced, and the button order makes more sense. I think there needs to be a bit more space between the block icon and the movers, though.

@jasmussen
Copy link
Contributor Author

The recently-introduced parent-selector button now feels a bit more awkward since the switcher + movers are a different shape

I didn't have that thought until you mentioned it, and even now I don't think too much of it, because just like popovers extending from the toolbar it's made of the same material.

I did notice it's 50x50 instead of 48x48 though, which I'll probably patch right up :)

Screenshot 2020-05-28 at 11 13 36

Good thoughts, I'll try and push some polish today.

@jasmussen
Copy link
Contributor Author

Pushed polish to the parent selector, and to focus, and re-balanced the icons a little bit:

polish

@jasmussen
Copy link
Contributor Author

Pushed a bunch of polish. It's feeling good:

movers

I still need to polish drag and drop, and to retire unused functions. But I'm marking this as ready for review to get some feedback.

@jasmussen jasmussen marked this pull request as ready for review May 28, 2020 10:48
@jasmussen
Copy link
Contributor Author

In 571e077 I polished drag and drop:

drag and drop

I think it works well, but I expect you'll have thoughts on this. Lay them on me.

@ZebulanStanphill
Copy link
Member

The size of the block switcher in the DOM is a bit weird:
image

(Since the movers partially overlap it, the actual clickable area is smaller like you would expect.)

Also, I still think you should also be able to drag from the switcher. It's still weird that you can drag from only the right half of the rectangle that makes up the switcher + mover area.

Additionally, I'm not sure how I feel about the black drag handle thing. I don't dislike it, but I wonder if maybe it's a bit too heavy? Anyway, I don't think it should be a blocker for this PR.

The spacing adjustments really helped a lot, and I'm already used to how it feels with the parent-selector. Functionality-wise, I think this is very close to ready!

@jasmussen
Copy link
Contributor Author

Thank you Zeb, good feedback. The changes to the button size and such I agree need to happen but they require a little tinkering that I thought I'd postpone until there's some agreement on a path forward (which appears to be forming!) Also agree on the draggable area.

The new dark handle, I know it's a big change, but if you're able to compare this with master or even 5.4, I'm actually liking it a fair bit. It helps indicate where you need to drop the block in order to actually move it. It's also not "muddy" in that it has a solid background, whereas the block you're moving does not (because we can't know which color to apply there).

I'm definitely open to more thoughts on that feeling, so I hear you, and it's why I opened the PR even while not totally baked yet.

@ZebulanStanphill ZebulanStanphill added the General Interface Parts of the UI which don't fall neatly under other labels. label May 28, 2020
@paaljoachim
Copy link
Contributor

When there is only one block on the page the arrow icons are missing leaving only an empty gap.
Screen Shot 2020-05-28 at 18 06 56

@jasmussen
Copy link
Contributor Author

Good catch, Paal. I'll show the movers as disabled when they can't be moved, that feels appropriate.

@jasmussen
Copy link
Contributor Author

Pushed a fix for the "just one block" case. As it turns out, there are a few heuristics for when the block mover should not be shown, including when blocks can't be moved. So instead of unhiding, I just restored the border in that case:

Screenshot 2020-05-29 at 09 48 28

@jasmussen jasmussen force-pushed the update/movers-to-toolbar branch 2 times, most recently from f859ff1 to 6924547 Compare May 29, 2020 07:53
@jasmussen jasmussen force-pushed the update/movers-to-toolbar branch from ac74d0b to 27e548a Compare June 8, 2020 07:49
@@ -12,7 +12,7 @@ import { withSafeTimeout } from '@wordpress/compose';
const dragImageClass = 'components-draggable__invisible-drag-image';
const cloneWrapperClass = 'components-draggable__clone';
const cloneHeightTransformationBreakpoint = 700;
const clonePadding = 20;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These 20 appear to have been picked at random, back in the day, and almost certainly due to there being side UI and margins. Because there is neither anymore, I've now set this to zero, instead of cmopensating for it.

background: transparent;
pointer-events: none;
z-index: z-index(".components-draggable__clone");

> * {
opacity: 0.8;
// This needs specificity as a theme is meant to define these by default.
margin-top: 0 !important;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I know that you must never use !important. Except in this case. Themes can define block margins, and when they do, the draggable clone will be as offset from the mouse cursor position as the theme margin decides. By explicitly and with high specificity setting these, this is unlikely to break.

@jasmussen
Copy link
Contributor Author

In ffe28be I simplifid the on-drag handle positioning math. There was some old stuff we don't need anymore that I was able to reduce and convert to variables.

Shaun I believe this fixes the discrepancies you saw. 2019:

2019

2020:

2020

@jasmussen
Copy link
Contributor Author

jasmussen commented Jun 9, 2020

Uh. I commented on the wrong post..

@jasmussen
Copy link
Contributor Author

Let's get this in and I will address any followups.

@jasmussen jasmussen merged commit 1f4645f into master Jun 9, 2020
@jasmussen jasmussen deleted the update/movers-to-toolbar branch June 9, 2020 08:44
@github-actions github-actions bot added this to the Gutenberg 8.4 milestone Jun 9, 2020
@paaljoachim
Copy link
Contributor

Like perhaps drag & drop hot zones...:)

@jasmussen
Copy link
Contributor Author

Like perhaps drag & drop hot zones...:)

Can you clarify?

@paaljoachim
Copy link
Contributor

paaljoachim commented Jun 9, 2020

Thinking this:
#20762 (comment)
and
#21391 (comment)

There are multiple issues intertwined into each other.
Drag & Drop as one begins to move the block one sees the space it occupied and during the drag sees the new space it can occupy. An outline/marked space that is the same size as the item dragged.

@jasmussen
Copy link
Contributor Author

Ah. There's lots to explore for drag and drop still, yes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
General Interface Parts of the UI which don't fall neatly under other labels. [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Evolving Movers
6 participants