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

Display block anchor in List View when set. #31992

Merged
merged 3 commits into from
May 20, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -65,6 +65,11 @@ function BlockNavigationBlockSelectButton(
<Indentation level={ level } />
<BlockIcon icon={ blockInformation?.icon } showColors />
<BlockTitle clientId={ clientId } />
{ blockInformation?.anchor && (
<span className="block-editor-block-navigation-block-select-button__anchor">
{ blockInformation.anchor }
</span>
) }
{ isSelected && (
<VisuallyHidden>
{ __( '(selected block)' ) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,18 @@
color: $white;
}
}

.block-editor-block-navigation-block-select-button__anchor {
background: rgba(30, 30, 30, 0.1);
Copy link
Contributor

Choose a reason for hiding this comment

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

I hate to bug you again, but this could also be rgba( $black, 0.1 ) 🙈

Copy link
Contributor

Choose a reason for hiding this comment

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

I went ahead and pushed a fix.

border-radius: 2px;
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be $radius-block-ui

display: inline-block;
padding: 2px 6px;
margin: 0 8px;
Copy link
Contributor

Choose a reason for hiding this comment

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

8px can be $grid-unit-10

}

&.is-selected .block-editor-block-navigation-block-select-button__anchor {
background: rgba(30, 30, 30, 0.3);
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be rgba( $black, 0.3 )

}
}

.block-editor-block-navigation-block-slot__description,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,16 @@ export default function useBlockDisplayInformation( clientId ) {
const blockName = getBlockName( clientId );
const blockType = getBlockType( blockName );
if ( ! blockType ) return null;
const attributes = getBlockAttributes( clientId );
const match = getActiveBlockVariation( blockName, attributes );
const blockTypeInfo = {
title: blockType.title,
icon: blockType.icon,
description: blockType.description,
anchor: attributes?.anchor,
};
const attributes = getBlockAttributes( clientId );
const match = getActiveBlockVariation( blockName, attributes );
if ( ! match ) return blockTypeInfo;

return {
title: match.title || blockType.title,
icon: match.icon || blockType.icon,
Expand Down