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 Navigation: try using CSS for indentation with known max indent instead of spacer divs #32063

Merged
merged 2 commits into from
May 21, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { useSelect } from '@wordpress/data';
* Internal dependencies
*/
import BlockNavigationLeaf from './leaf';
import Indentation from './indentation';
import Inserter from '../inserter';
import { store as blockEditorStore } from '../../store';

Expand Down Expand Up @@ -63,7 +62,6 @@ export default function BlockNavigationAppender( {
>
{ ( { ref, tabIndex, onFocus } ) => (
<div className="block-editor-block-navigation-appender__container">
<Indentation level={ level } />
<Inserter
rootClientId={ parentBlockClientId }
__experimentalIsQuick
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { __ } from '@wordpress/i18n';
* Internal dependencies
*/
import BlockIcon from '../block-icon';
import Indentation from './indentation';
import useBlockDisplayInformation from '../use-block-display-information';
import { getBlockPositionDescription } from './utils';
import BlockTitle from '../block-title';
Expand Down Expand Up @@ -62,7 +61,6 @@ function BlockNavigationBlockSelectButton(
onDragEnd={ onDragEnd }
draggable={ draggable }
>
<Indentation level={ level } />
<BlockIcon icon={ blockInformation?.icon } showColors />
<BlockTitle clientId={ clientId } />
{ blockInformation?.anchor && (
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,15 @@
}
}

.block-editor-block-navigator-indentation {
flex-shrink: 0;
width: $grid-unit-30 + $grid-unit-05; // Indent a full icon size, plus 4px which optically aligns child icons to the text label above.
// First level of indentation is aria-level 2, max indent is 8.
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we use a SCSS for loop for this one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call I added this in e5c2be3

Generated final CSS looks like:
Screen Shot 2021-05-21 at 8 57 24 AM

// Indent is a full icon size, plus 4px which optically aligns child icons to the text label above.
$block-navigation-max-indent: 8;
.block-editor-block-navigation-leaf[aria-level] .block-editor-block-icon {
margin-left: ( $grid-unit-30 + $grid-unit-05 ) * $block-navigation-max-indent;
}
@for $i from 0 through $block-navigation-max-indent {
.block-editor-block-navigation-leaf[aria-level="#{ $i + 1 }"] .block-editor-block-icon {
margin-left: ( $grid-unit-30 + $grid-unit-05 ) * $i;
}
}