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

Visual improvements to the block navigator #22796

Merged
merged 15 commits into from
Jun 10, 2020
Merged
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
57 changes: 33 additions & 24 deletions packages/block-editor/src/components/block-navigation/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ import classnames from 'classnames';
/**
* WordPress dependencies
*/
import { __experimentalTreeGridCell as TreeGridCell } from '@wordpress/components';
import {
__experimentalTreeGridCell as TreeGridCell,
__experimentalTreeGridItem as TreeGridItem,
} from '@wordpress/components';

import { moreVertical } from '@wordpress/icons';
import { useState } from '@wordpress/element';

Expand Down Expand Up @@ -71,7 +75,7 @@ export default function BlockNavigationBlock( {
>
<TreeGridCell
className="block-editor-block-navigation-block__contents-cell"
colSpan={ hasRenderedMovers ? undefined : 3 }
colSpan={ hasRenderedMovers ? undefined : 2 }
>
{ ( { ref, tabIndex, onFocus } ) => (
<div className="block-editor-block-navigation-block__contents-container">
Expand All @@ -96,32 +100,37 @@ export default function BlockNavigationBlock( {
</TreeGridCell>
{ hasRenderedMovers && (
<>
<TreeGridCell className={ moverCellClassName }>
{ ( { ref, tabIndex, onFocus } ) => (
<BlockMoverUpButton
__experimentalOrientation="vertical"
clientIds={ [ clientId ] }
ref={ ref }
tabIndex={ tabIndex }
onFocus={ onFocus }
/>
) }
</TreeGridCell>
<TreeGridCell className={ moverCellClassName }>
{ ( { ref, tabIndex, onFocus } ) => (
<BlockMoverDownButton
__experimentalOrientation="vertical"
clientIds={ [ clientId ] }
ref={ ref }
tabIndex={ tabIndex }
onFocus={ onFocus }
/>
) }
<TreeGridCell
className={ moverCellClassName }
withoutGridItem
>
<TreeGridItem>
{ ( { ref, tabIndex, onFocus } ) => (
<BlockMoverUpButton
__experimentalOrientation="vertical"
clientIds={ [ clientId ] }
ref={ ref }
tabIndex={ tabIndex }
onFocus={ onFocus }
/>
) }
</TreeGridItem>
<TreeGridItem>
{ ( { ref, tabIndex, onFocus } ) => (
<BlockMoverDownButton
__experimentalOrientation="vertical"
clientIds={ [ clientId ] }
ref={ ref }
tabIndex={ tabIndex }
onFocus={ onFocus }
/>
) }
</TreeGridItem>
</TreeGridCell>
</>
) }

{ withBlockNavigationBlockSettings && level > 1 && (
{ withBlockNavigationBlockSettings && (
<TreeGridCell
className={ blockNavigationBlockSettingsClassName }
>
Expand Down
110 changes: 103 additions & 7 deletions packages/block-editor/src/components/block-navigation/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,17 @@ $tree-item-height: 36px;
align-items: center;
width: calc(100% - 0.8em);
height: auto;
padding: 6px;
padding: $grid-unit-15 6px;
margin-top: auto;
margin-bottom: auto;
text-align: left;
color: $dark-gray-600;
border-radius: 2px;

.components-modal__content & {
padding-left: 0;
padding-right: 0;
}
}

&.is-visible .block-editor-block-navigation-block-contents {
Expand All @@ -54,6 +61,13 @@ $tree-item-height: 36px;
border-radius: $border-width;
}

.block-editor-block-navigation-block__menu-cell,
.block-editor-block-navigation-block__mover-cell,
.block-editor-block-navigation-block__contents-cell {
padding-top: 0;
padding-bottom: 0;
}

.block-editor-block-navigation-block__menu-cell,
.block-editor-block-navigation-block__mover-cell {
width: $button-size;
Expand All @@ -74,16 +88,84 @@ $tree-item-height: 36px;
}
}

.block-editor-block-navigation-block__menu-cell {
padding-top: $grid-unit-10;
}

.block-editor-block-navigation-block__mover-cell-alignment-wrapper {
display: flex;
height: 100%;
flex-direction: column;
align-items: center;
}

// Keep the tap target large but the focus target small
.block-editor-block-mover-button {
position: relative;
width: $button-size;
height: $button-size;
height: $button-size-small;

// Position the icon
svg {
position: relative;
height: $button-size-small;
}

&.is-up-button {
align-items: flex-end;
svg {
bottom: -4px;
}
}

&.is-down-button {
align-items: flex-start;
svg {
top: -4px;
}
}

// Don't show the focus inherited by the Button component.
&:focus:enabled {
box-shadow: none;
outline: none;
}

// Focus style.
&:focus {
box-shadow: none;
outline: none;
}

&:focus::before {
@include block-toolbar-button-style__focus();
}

// Focus and toggle pseudo elements.
&::before {
content: "";
position: absolute;
display: block;
border-radius: $radius-block-ui;
height: 16px;
min-width: 100%;

// Position the focus rectangle.
left: 0;
right: 0;

// Animate in.
animation: components-button__appear-animation 0.1s ease;
animation-fill-mode: forwards;
@include reduce-motion("animation");
}
}

.block-editor-inserter__toggle {
background: $dark-gray-primary;
color: $white;
height: $grid-unit-30;
margin: 6px 6px 6px 0.8em;
margin: 6px 6px 6px 1px;
min-width: $grid-unit-30;

&:active {
Expand All @@ -105,6 +187,10 @@ $tree-item-height: 36px;
display: flex;
}

.block-editor-block-navigation-block__contents-container {
min-height: 56px;
}

.block-editor-block-navigator-descender-line {
position: relative;
flex-shrink: 0;
Expand All @@ -123,9 +209,9 @@ $tree-item-height: 36px;
content: "";
display: block;
position: absolute;
top: -1px;
top: 1px;
bottom: -2px;
right: 0;
right: -1px;
border-right: 2px solid $light-gray-900;
}

Expand All @@ -136,18 +222,28 @@ $tree-item-height: 36px;

// Make the last vertical line half-height.
&.has-item.is-last-row {
height: $grid-unit-20;
height: 26px;
}

// Draw a horizontal line using border-bottom.
&.has-item::after {
content: "";
display: block;
position: absolute;
top: $grid-unit-20;
top: 26px;
left: 100%;
width: 5px;
border-bottom: 2px solid $light-gray-900;
}
}
}

// Position the horizontal line in the middle of appender's height
.block-editor-block-navigation-appender__cell .block-editor-block-navigator-descender-line {
&.has-item.is-last-row {
height: $grid-unit-20;
&::after {
top: 100%;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default function BlockNavigationList( {

return (
<__experimentalBlockNavigationTree
blocks={ [ block ] }
blocks={ block.innerBlocks }
selectedBlockClientId={ selectedBlockClientId }
selectBlock={ selectBlock }
__experimentalFeatures={ __experimentalFeatures }
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export {
default as __experimentalTreeGrid,
TreeGridRow as __experimentalTreeGridRow,
TreeGridCell as __experimentalTreeGridCell,
TreeGridItem as __experimentalTreeGridItem,
} from './tree-grid';
export { default as TreeSelect } from './tree-select';
export { default as __experimentalUnitControl } from './unit-control';
Expand Down
14 changes: 11 additions & 3 deletions packages/components/src/tree-grid/cell.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
/**
* Internal dependencies
*/
import RovingTabIndexItem from './roving-tab-index-item';
import TreeGridItem from './item';

export default function TreeGridCell( { children, ...props } ) {
export default function TreeGridCell( {
children,
withoutGridItem = false,
...props
} ) {
return (
<td { ...props } role="gridcell">
<RovingTabIndexItem>{ children }</RovingTabIndexItem>
{ withoutGridItem ? (
children
) : (
<TreeGridItem>{ children }</TreeGridItem>
) }
</td>
);
}
1 change: 1 addition & 0 deletions packages/components/src/tree-grid/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,4 @@ export default function TreeGrid( { children, ...props } ) {

export { default as TreeGridRow } from './row';
export { default as TreeGridCell } from './cell';
export { default as TreeGridItem } from './item';
8 changes: 8 additions & 0 deletions packages/components/src/tree-grid/item.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Internal dependencies
*/
import RovingTabIndexItem from './roving-tab-index-item';

export default function TreeGridItem( { children, ...props } ) {
return <RovingTabIndexItem { ...props }>{ children }</RovingTabIndexItem>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default function MenuEditor( {
<BlockEditorKeyboardShortcuts />
<MenuEditorShortcuts saveBlocks={ saveMenuItems } />
<NavigationStructureArea
blocks={ blocks }
blocks={ blocks[ 0 ]?.innerBlocks || [] }
initialOpen={ isLargeViewport }
/>
<BlockEditorArea
Expand Down
17 changes: 16 additions & 1 deletion packages/edit-navigation/src/components/menu-editor/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,28 @@
}
}

.edit-navigation-menu-editor__navigation-structure-card,
.block-editor-block-navigation-leaf {
> :first-child {
padding-left: 0;
}
> :first-child button {
padding-left: 0;
}
}

.edit-navigation-menu-editor__navigation-structure-panel {
// IE11 requires the column to be explicitly declared.
grid-column: 1;

// Make panels collapsible in IE. The IE analogue of align-items: self-start;.
-ms-grid-row-align: start;

.components-card__header {
font-weight: bold;
border-bottom: 0;
padding-top: $grid-unit-30 !important;
padding-bottom: $grid-unit-30 !important;
Comment on lines +71 to +72
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's get rid of these !important before merging

}
}

.edit-navigation-menu-editor__navigation-structure-header {
Expand Down