Skip to content

Move and update ButtonBlockAppender styles into component stylesheet + improvements #70472

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

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,13 @@
}
}


// When the appender shows up in empty container blocks, such as Group and Columns, add an extra click state.
.block-list-appender:only-child {
// One level of nesting
.is-layout-constrained.block-editor-block-list__block:not(.is-selected) > &,
.is-layout-flow.block-editor-block-list__block:not(.is-selected) > &,
// Legacy groups have an inner container so need to be targeted separately
.block-editor-block-list__block:not(.is-selected) > .is-layout-constrained.wp-block-group__inner-container > &,
.block-editor-block-list__block:not(.is-selected) > .is-layout-flow.wp-block-group__inner-container > & {
// Blocks with inner containers
.block-editor-block-list__block:not(.is-selected, .block-editor-block-list__layout) > .is-layout-constrained.block-editor-block-list__layout > &,
.block-editor-block-list__block:not(.is-selected, .block-editor-block-list__layout) > .is-layout-flow.block-editor-block-list__layout > & {
pointer-events: none;

&::after {
Expand All @@ -49,7 +47,7 @@
border: $border-width dashed currentColor;
}

.block-editor-inserter {
> .block-editor-inserter {
opacity: 0;

&:focus-within {
Expand All @@ -63,17 +61,11 @@
}

.block-editor-inserter {
visibility: visible;
opacity: 1;
}
}
}

// Hide the dashed outline in 2-level nested cases, so for example the dashed
// empty column is only shown when the columns block is selected.
.block-editor-block-list__block:not(.is-selected) > .block-editor-block-list__block > &::after {
border: none;
}

// Drop zone.
&.is-drag-over .block-editor-button-block-appender {
background-color: var(--wp-admin-theme-color);
Expand All @@ -84,3 +76,58 @@
}
}
}

.block-editor-block-list__layout.is-layout-flex {
&:not(.is-vertical) > .block-list-appender:only-child {
flex: 1;
align-self: stretch;
}

&.is-vertical > .block-list-appender:only-child {
flex: 1;
width: 100%;
}

// Cap inserter button and dashed outline widths to indicate how the layout will distribute space/content. Exempt stretched vertical layouts.
&:not(.is-vertical.is-content-justification-stretch) > .block-list-appender:only-child {
> .block-editor-inserter,
&::after {
width: 200px;
}
}

&:not(.is-vertical).is-vertical-alignment-stretch > .block-list-appender:only-child
.block-editor-button-block-appender {
height: auto;
}

> .block-list-appender:only-child {
gap: inherit;
align-items: inherit;
justify-content: inherit;
flex-direction: inherit;

&,
.block-editor-inserter {
display: inherit;
}

&::after {
content: "";
display: inherit;
//flex: 1 0 $button-size-next-default-40px;
pointer-events: none;
min-height:
$button-size-next-default-40px - $border-width -
$border-width;
border: $border-width dashed currentColor;
}

// Let the parent be selectable in the placeholder area.
pointer-events: none;
.block-editor-inserter,
.block-editor-button-block-appender {
pointer-events: all;
}
}
}
8 changes: 8 additions & 0 deletions packages/block-editor/src/hooks/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,14 @@ export function useLayoutClasses( blockAttributes = {}, blockName = '' ) {
);
}

if ( usedLayout?.verticalAlignment ) {
layoutClassnames.push(
`is-vertical-alignment-${ kebabCase(
usedLayout.verticalAlignment
) }`
);
}

if ( usedLayout?.flexWrap && usedLayout.flexWrap === 'nowrap' ) {
layoutClassnames.push( 'is-nowrap' );
}
Expand Down
30 changes: 0 additions & 30 deletions packages/block-library/src/group/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,33 +23,3 @@
}
}

// Affect the appender of the Row and Stack variants.
.wp-block-group.is-layout-flex.block-editor-block-list__block > .block-list-appender:only-child {
gap: inherit;

&,
.block-editor-default-block-appender__content,
.block-editor-inserter {
display: inherit;
width: 100%;
flex-direction: inherit;
flex: 1;
}

&::after {
content: "";
display: flex;
flex: 1 0 $button-size-next-default-40px;
pointer-events: none;
min-height: $button-size-next-default-40px - $border-width - $border-width;
border: $border-width dashed currentColor;
}

// Let the parent be selectable in the placeholder area.
pointer-events: none;
.block-editor-inserter,
.block-editor-button-block-appender {
pointer-events: all;
}
}

Loading