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

Block: side inserter in Popover #19406

Merged
merged 1 commit into from
Jan 9, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Block: side inserter in Popover
  • Loading branch information
ellatrix committed Jan 9, 2020
commit 04f63450414fd490e375a03e0fca94aef671254d
41 changes: 25 additions & 16 deletions packages/block-editor/src/components/block-list/block.js
Original file line number Diff line number Diff line change
@@ -396,6 +396,13 @@ function BlockListBlock( {
/>
);

// Position above the anchor, pop out towards the right, and position in the
// left corner. For the side inserter, pop out towards the left, and
// position in the right corner.
// To do: refactor `Popover` to make this prop clearer.
const popoverPosition = showEmptyBlockSideInserter ? 'top left right' : 'top right left';
const popoverIsSticky = isPartOfMultiSelection ? '.wp-block.is-multi-selected' : true;

return (
<animated.div
id={ blockElementId }
@@ -427,18 +434,20 @@ function BlockListBlock( {
// of the appropriate parent.
<ChildToolbarSlot />
) }
{ ( shouldShowBreadcrumb || shouldShowContextualToolbar || isForcingContextualToolbar.current ) && (
{ (
shouldShowBreadcrumb ||
shouldShowContextualToolbar ||
isForcingContextualToolbar.current ||
showEmptyBlockSideInserter
) && (
<Popover
noArrow
animate={ false }
// Position above the anchor, pop out towards the right,
// and position in the left corner.
// To do: refactor `Popover` to make this prop clearer.
position="top right left"
position={ popoverPosition }
focusOnMount={ false }
anchorRef={ blockNodeRef.current }
className="block-editor-block-list__block-popover"
__unstableSticky={ isPartOfMultiSelection ? '.wp-block.is-multi-selected' : true }
__unstableSticky={ showEmptyBlockSideInserter ? false : popoverIsSticky }
__unstableSlotName="block-toolbar"
// Allow subpixel positioning for the block movement animation.
__unstableAllowVerticalSubpixelPosition={ moverDirection !== 'horizontal' && wrapper.current }
@@ -460,6 +469,16 @@ function BlockListBlock( {
data-align={ wrapperProps ? wrapperProps[ 'data-align' ] : undefined }
/>
) }
{ showEmptyBlockSideInserter && (
<div className="block-editor-block-list__empty-block-inserter">
<Inserter
position="top right"
onToggle={ selectOnOpen }
rootClientId={ rootClientId }
clientId={ clientId }
/>
</div>
) }
</Popover>
) }
<div
@@ -485,16 +504,6 @@ function BlockListBlock( {
</BlockCrashBoundary>
{ !! hasError && <BlockCrashWarning /> }
</div>
{ showEmptyBlockSideInserter && (
<div className="block-editor-block-list__empty-block-inserter">
<Inserter
position="top right"
onToggle={ selectOnOpen }
rootClientId={ rootClientId }
clientId={ clientId }
/>
</div>
) }
</animated.div>
);
}
3 changes: 1 addition & 2 deletions packages/block-editor/src/components/block-list/style.scss
Original file line number Diff line number Diff line change
@@ -361,7 +361,6 @@
// This essentially duplicates the mobile styles for the appender component.
// It would be nice to be able to use element queries in that component instead https://github.com/tomhodgins/element-queries-spec
.block-editor-block-list__layout {
.block-editor-block-list__empty-block-inserter,
.block-editor-default-block-appender .block-editor-inserter {
left: auto;
right: $grid-size;
@@ -535,7 +534,7 @@
z-index: z-index(".block-editor-block-list__block-popover");

.components-popover__content {
margin-left: 0 !important;
margin: 0 !important;
min-width: auto;
background: none;
border: none;
Original file line number Diff line number Diff line change
@@ -62,7 +62,6 @@
.components-button.has-icon {
width: $block-side-ui-width;
height: $block-side-ui-width;
margin-right: 12px;
padding: 0;
}

@@ -89,10 +88,7 @@

@include break-small {
display: flex;
align-items: center;
height: 100%;
left: -$block-side-ui-width - $block-padding - $block-side-ui-clearance;
right: auto;
}

&:disabled {
@@ -114,3 +110,9 @@
}
}
}

.block-editor-default-block-appender .block-editor-inserter {
@include break-small {
align-items: center;
}
}