Skip to content

Commit 7ec834b

Browse files
jasmussenmcsf
authored andcommitted
Try: Improve floats UI. (#10085)
* Try: Improve floats UI. 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. * chore: Tidy up docs
1 parent 1e72714 commit 7ec834b

File tree

2 files changed

+56
-33
lines changed

2 files changed

+56
-33
lines changed

packages/block-library/src/embed/editor.scss

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
.wp-block-embed {
22
margin: 0;
3-
clear: both; // necessary because we use responsive trickery to set width/height, and therefore the video doesn't intrinsically clear floats like an img does
3+
// Necessary because we use responsive trickery to set width/height,
4+
// therefore the video doesn't intrinsically clear floats like an image does.
5+
clear: both;
6+
// Apply a min-width, or the embed can collapse when floated.
7+
min-width: $break-mobile / 2;
48

59
&.is-loading {
610
display: flex;

packages/editor/src/components/block-list/style.scss

Lines changed: 51 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -287,28 +287,62 @@
287287
.editor-block-contextual-toolbar {
288288
margin-bottom: $border-width;
289289
}
290-
}
291290

292-
// Left: This is in the editor only; the image should be floated on the frontend.
293-
&[data-align="left"] > .editor-block-list__block-edit {
294-
/*!rtl:begin:ignore*/
295-
float: left;
296-
margin-right: 2em;
297-
/*!rtl:end:ignore*/
291+
// Hide all additional UI on floats.
292+
.editor-block-mover,
293+
.editor-block-list__block-mobile-toolbar {
294+
display: none;
295+
}
296+
297+
// Position toolbar better on mobile.
298+
.editor-block-contextual-toolbar {
299+
border-bottom: 1px solid $light-gray-500;
300+
bottom: $block-padding;
301+
left: auto;
302+
right: auto;
303+
}
298304
}
299305

300-
// Right: This is in the editor only; the image should be floated on the frontend.
301-
&[data-align="right"] > .editor-block-list__block-edit {
302-
/*!rtl:begin:ignore*/
303-
float: right;
304-
margin-left: 2em;
305-
/*!rtl:end:ignore*/
306+
// Left
307+
&[data-align="left"] {
308+
// This is in the editor only; the image should be floated on the frontend.
309+
.editor-block-list__block-edit {
310+
/*!rtl:begin:ignore*/
311+
float: left;
312+
margin-right: 2em;
313+
/*!rtl:end:ignore*/
314+
}
315+
316+
// Align block toolbar to floated content.
317+
@include break-small() {
318+
.editor-block-toolbar {
319+
/*!rtl:begin:ignore*/
320+
left: $block-padding;
321+
right: auto;
322+
/*!rtl:end:ignore*/
323+
}
324+
}
306325
}
307326

308-
&[data-align="right"] > .editor-block-contextual-toolbar > .editor-block-toolbar {
309-
/*!rtl:begin:ignore*/
310-
float: right;
311-
/*!rtl:end:ignore*/
327+
// Right
328+
&[data-align="right"] {
329+
// Right: This is in the editor only; the image should be floated on the frontend.
330+
> .editor-block-list__block-edit {
331+
/*!rtl:begin:ignore*/
332+
float: right;
333+
margin-left: 2em;
334+
/*!rtl:end:ignore*/
335+
}
336+
337+
// Align block toolbar to floated content.
338+
@include break-small() {
339+
.editor-block-toolbar {
340+
/*!rtl:begin:ignore*/
341+
right: $block-padding;
342+
left: auto;
343+
/*!rtl:end:ignore*/
344+
}
345+
}
312346
}
313347

314348
// Wide and full-wide
@@ -802,21 +836,6 @@
802836
left: 0;
803837
}
804838

805-
.editor-block-list__block[data-align="right"] & {
806-
/*!rtl:begin:ignore*/
807-
left: auto;
808-
right: 0;
809-
/*!rtl:end:ignore*/
810-
}
811-
812-
.editor-block-list__block[data-align="left"] & {
813-
/*!rtl:begin:ignore*/
814-
right: auto;
815-
left: 0;
816-
/*!rtl:end:ignore*/
817-
}
818-
819-
820839
@include break-small() {
821840
width: auto;
822841
}

0 commit comments

Comments
 (0)