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

[List View]: Improve icon alignments and added scroll when blocks are deeply nested. #46990

Closed
wants to merge 9 commits into from
5 changes: 1 addition & 4 deletions packages/base-styles/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -489,12 +489,9 @@
/* stylelint-enable function-comma-space-after */
}

@mixin custom-scrollbars-on-hover() {
@mixin custom-scrollbars-on-hover($track-color: #1e1e1e, $handle-color: #757575) {
MaggieCabrera marked this conversation as resolved.
Show resolved Hide resolved
visibility: hidden;

$handle-color: #757575;
$track-color: #1e1e1e;

// WebKit
&::-webkit-scrollbar {
width: 12px;
Expand Down
35 changes: 27 additions & 8 deletions packages/block-editor/src/components/list-view/style.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
.block-editor-list-view-tree {
width: 100%;
max-width: 100%;
overflow-x: auto;
@include custom-scrollbars-on-hover(#ffffff);
display: block;
border-collapse: collapse;
padding: 0;
margin: 0;
Expand All @@ -9,11 +13,17 @@
margin: (-$grid-unit-15) (-$grid-unit-15 * 0.5) 0;
width: calc(100% + #{ $grid-unit-15 });
}

tbody {
display: flex;
flex-direction: column;
}
}

.block-editor-list-view-leaf {
// Use position relative for row animation.
position: relative;
display: flex;

// The background has to be applied to the td, not tr, or border-radius won't work.
&.is-selected td {
Expand Down Expand Up @@ -190,6 +200,10 @@
flex: 0 0 $icon-size;
}

.block-editor-list-view-block__contents-cell {
flex-basis: 100%;
}

.block-editor-list-view-block__menu-cell,
.block-editor-list-view-block__mover-cell,
.block-editor-list-view-block__contents-cell {
Expand Down Expand Up @@ -278,6 +292,12 @@
}
}

.block-editor-block-settings-menu {
height: 100%;
display: flex;
align-items: center;
}

.block-editor-inserter__toggle {
background: $gray-900;
color: $white;
Expand All @@ -290,18 +310,17 @@
}
}

.block-editor-list-view-block-select-button__label-wrapper {
min-width: 120px;
}

.block-editor-list-view-block-select-button__title {
flex: 1;
position: relative;
margin-right: auto;
display: inline-flex;
align-items: center;

.components-truncate {
position: absolute;
width: 100%;
transform: translateY(-50%);
display: inline-block;
max-width: 120px;
text-overflow: ellipsis;
overflow: hidden;
}
}

Expand Down
88 changes: 43 additions & 45 deletions packages/block-editor/src/components/off-canvas-editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,52 +208,50 @@ function __ExperimentalOffCanvasEditor(
listViewRef={ elementRef }
blockDropTarget={ blockDropTarget }
/>
<div className="offcanvas-editor-list-view-tree-wrapper">
<TreeGrid
id={ id }
className="block-editor-list-view-tree"
aria-label={ __( 'Block navigation structure' ) }
ref={ treeGridRef }
onCollapseRow={ collapseRow }
onExpandRow={ expandRow }
onFocusRow={ focusRow }
applicationAriaLabel={ __( 'Block navigation structure' ) }
>
<ListViewContext.Provider value={ contextValue }>
<ListViewBranch
blocks={ clientIdsTree }
selectBlock={ selectEditorBlock }
showBlockMovers={ showBlockMovers }
fixedListWindow={ fixedListWindow }
selectedClientIds={ selectedClientIds }
isExpanded={ isExpanded }
shouldShowInnerBlocks={ shouldShowInnerBlocks }
selectBlockInCanvas={ selectBlockInCanvas }
/>
<TreeGridRow
level={ 1 }
setSize={ 1 }
positionInSet={ 1 }
isExpanded={ true }
>
<TreeGridCell>
{ ( treeGridCellProps ) => (
<Appender { ...treeGridCellProps } />
) }
</TreeGridCell>
{ ! clientIdsTree.length && (
<TreeGridCell withoutGridItem>
<div className="offcanvas-editor-list-view-is-empty">
{ __(
'Your menu is currently empty. Add your first menu item to get started.'
) }
</div>
</TreeGridCell>
<TreeGrid
id={ id }
className="block-editor-list-view-tree"
aria-label={ __( 'Block navigation structure' ) }
ref={ treeGridRef }
onCollapseRow={ collapseRow }
onExpandRow={ expandRow }
onFocusRow={ focusRow }
applicationAriaLabel={ __( 'Block navigation structure' ) }
>
<ListViewContext.Provider value={ contextValue }>
<ListViewBranch
blocks={ clientIdsTree }
selectBlock={ selectEditorBlock }
showBlockMovers={ showBlockMovers }
fixedListWindow={ fixedListWindow }
selectedClientIds={ selectedClientIds }
isExpanded={ isExpanded }
shouldShowInnerBlocks={ shouldShowInnerBlocks }
selectBlockInCanvas={ selectBlockInCanvas }
/>
<TreeGridRow
level={ 1 }
setSize={ 1 }
positionInSet={ 1 }
isExpanded={ true }
>
<TreeGridCell>
{ ( treeGridCellProps ) => (
<Appender { ...treeGridCellProps } />
) }
</TreeGridRow>
</ListViewContext.Provider>
</TreeGrid>
</div>
</TreeGridCell>
{ ! clientIdsTree.length && (
<TreeGridCell withoutGridItem>
<div className="offcanvas-editor-list-view-is-empty">
{ __(
'Your menu is currently empty. Add your first menu item to get started.'
) }
</div>
</TreeGridCell>
) }
</TreeGridRow>
</ListViewContext.Provider>
</TreeGrid>
</AsyncModeProvider>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,7 @@
}
}

.offcanvas-editor-list-view-tree-wrapper {
max-width: 100%;
overflow-x: auto;
}

.offcanvas-editor-list-view-leaf {
display: block;
// sidebar width - tab panel padding
max-width: $sidebar-width - (2 * $grid-unit-20);
}
Expand Down