-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Grid Interactivity: Fix block mover layout and styles #64021
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,28 +55,29 @@ export function GridItemMovers( { | |
return ( | ||
<BlockControls group="parent"> | ||
<ToolbarGroup className="block-editor-grid-item-mover__move-button-container"> | ||
<GridItemMover | ||
className="is-left-button" | ||
icon={ chevronLeft } | ||
label={ __( 'Move left' ) } | ||
description={ __( 'Move left' ) } | ||
isDisabled={ columnStart <= 1 } | ||
onClick={ () => { | ||
onChange( { | ||
columnStart: columnStart - 1, | ||
} ); | ||
__unstableMarkNextChangeAsNotPersistent(); | ||
moveBlocksToPosition( | ||
[ blockClientId ], | ||
gridClientId, | ||
gridClientId, | ||
getNumberOfBlocksBeforeCell( | ||
columnStart - 1, | ||
rowStart | ||
) | ||
); | ||
} } | ||
/> | ||
<div className="block-editor-grid-item-mover__move-horizontal-button-container is-left"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the toolbar button, the I wrapped the button in a |
||
<GridItemMover | ||
icon={ chevronLeft } | ||
label={ __( 'Move left' ) } | ||
description={ __( 'Move left' ) } | ||
isDisabled={ columnStart <= 1 } | ||
onClick={ () => { | ||
onChange( { | ||
columnStart: columnStart - 1, | ||
} ); | ||
__unstableMarkNextChangeAsNotPersistent(); | ||
moveBlocksToPosition( | ||
[ blockClientId ], | ||
gridClientId, | ||
gridClientId, | ||
getNumberOfBlocksBeforeCell( | ||
columnStart - 1, | ||
rowStart | ||
) | ||
); | ||
} } | ||
/> | ||
</div> | ||
<div className="block-editor-grid-item-mover__move-vertical-button-container"> | ||
<GridItemMover | ||
className="is-up-button" | ||
|
@@ -123,28 +124,29 @@ export function GridItemMovers( { | |
} } | ||
/> | ||
</div> | ||
<GridItemMover | ||
className="is-right-button" | ||
icon={ chevronRight } | ||
label={ __( 'Move right' ) } | ||
description={ __( 'Move right' ) } | ||
isDisabled={ columnCount && columnEnd >= columnCount } | ||
onClick={ () => { | ||
onChange( { | ||
columnStart: columnStart + 1, | ||
} ); | ||
__unstableMarkNextChangeAsNotPersistent(); | ||
moveBlocksToPosition( | ||
[ blockClientId ], | ||
gridClientId, | ||
gridClientId, | ||
getNumberOfBlocksBeforeCell( | ||
columnStart + 1, | ||
rowStart | ||
) | ||
); | ||
} } | ||
/> | ||
<div className="block-editor-grid-item-mover__move-horizontal-button-container is-right"> | ||
<GridItemMover | ||
icon={ chevronRight } | ||
label={ __( 'Move right' ) } | ||
description={ __( 'Move right' ) } | ||
isDisabled={ columnCount && columnEnd >= columnCount } | ||
onClick={ () => { | ||
onChange( { | ||
columnStart: columnStart + 1, | ||
} ); | ||
__unstableMarkNextChangeAsNotPersistent(); | ||
moveBlocksToPosition( | ||
[ blockClientId ], | ||
gridClientId, | ||
gridClientId, | ||
getNumberOfBlocksBeforeCell( | ||
columnStart + 1, | ||
rowStart | ||
) | ||
); | ||
} } | ||
/> | ||
</div> | ||
</ToolbarGroup> | ||
</BlockControls> | ||
); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,7 +105,6 @@ | |
.block-editor-grid-item-mover-button { | ||
width: $block-toolbar-height * 0.5; | ||
min-width: 0 !important; // overrides default button width. | ||
overflow: hidden; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
padding-left: 0; | ||
padding-right: 0; | ||
|
||
|
@@ -155,7 +154,7 @@ | |
justify-content: space-around; | ||
|
||
> .block-editor-grid-item-mover-button.block-editor-grid-item-mover-button { | ||
height: $block-toolbar-height * 0.5 - $grid-unit-05; | ||
height: $block-toolbar-height * 0.5 - $grid-unit-05 !important; // overrides toolbar button height. | ||
width: 100%; | ||
min-width: 0 !important; // overrides default button width. | ||
|
||
|
@@ -173,18 +172,53 @@ | |
} | ||
} | ||
|
||
.editor-collapsible-block-toolbar { | ||
.block-editor-grid-item-mover__move-vertical-button-container { | ||
// Move up a little to prevent the toolbar shift when focus is on the vertical movers. | ||
@include break-small() { | ||
height: $grid-unit-50; | ||
position: relative; | ||
top: -5px; // Should be -4px, but that causes scrolling when focus lands on the movers, in a 60px header. | ||
} | ||
} | ||
} | ||
Comment on lines
+175
to
+184
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to this approach for the default block mover. the |
||
|
||
.show-icon-labels { | ||
|
||
.block-editor-grid-item-mover-button.block-editor-grid-item-mover-button.is-left-button { | ||
border-right: 1px solid $gray-700; | ||
padding-right: 12px; | ||
} | ||
.block-editor-grid-item-mover__move-horizontal-button-container { | ||
position: relative; | ||
|
||
.block-editor-grid-item-mover-button.block-editor-grid-item-mover-button.is-right-button { | ||
border-left: 1px solid $gray-700; | ||
padding-left: 12px; | ||
} | ||
&::before { | ||
@include break-small() { | ||
content: ""; | ||
height: 100%; | ||
width: $border-width; | ||
background: $gray-200; | ||
position: absolute; | ||
top: 0; | ||
} | ||
|
||
@include break-medium() { | ||
background: $gray-900; | ||
} | ||
} | ||
|
||
&.is-left { | ||
padding-right: 6px; | ||
|
||
&::before { | ||
right: 0; | ||
} | ||
} | ||
|
||
&.is-right { | ||
padding-left: 6px; | ||
|
||
&::before { | ||
left: 0; | ||
} | ||
} | ||
} | ||
|
||
.block-editor-grid-item-mover__move-vertical-button-container { | ||
&::before { | ||
|
@@ -208,5 +242,21 @@ | |
} | ||
} | ||
|
||
.block-editor-grid-item-mover-button { | ||
white-space: nowrap; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
} | ||
|
||
.editor-collapsible-block-toolbar { | ||
.block-editor-grid-item-mover__move-horizontal-button-container::before { | ||
height: $grid-unit-30; | ||
background: $gray-300; | ||
top: $grid-unit-05; | ||
} | ||
|
||
.block-editor-grid-item-mover__move-vertical-button-container::before { | ||
background: $gray-300; | ||
width: calc(100% - #{$grid-unit-30}); | ||
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prevents a
ToolbarGroup
component that has no children from being rendered.