Skip to content

Commit

Permalink
List View: Use badge component for block anchors (#68566)
Browse files Browse the repository at this point in the history
Co-authored-by: juanfra <juanfra@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: jameskoster <jameskoster@git.wordpress.org>
  • Loading branch information
4 people authored Jan 10, 2025
1 parent 79234bd commit 14d10ea
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import clsx from 'clsx';
import {
__experimentalHStack as HStack,
__experimentalTruncate as Truncate,
privateApis as componentsPrivateApis,
} from '@wordpress/components';
import { forwardRef } from '@wordpress/element';
import { Icon, lockSmall as lock, pinSmall } from '@wordpress/icons';
Expand All @@ -25,6 +26,8 @@ import ListViewExpander from './expander';
import { useBlockLock } from '../block-lock';
import useListViewImages from './use-list-view-images';
import { store as blockEditorStore } from '../../store';
import { unlock } from '../../lock-unlock';
const { Badge } = unlock( componentsPrivateApis );

function ListViewBlockSelectButton(
{
Expand Down Expand Up @@ -117,12 +120,9 @@ function ListViewBlockSelectButton(
</span>
{ blockInformation?.anchor && (
<span className="block-editor-list-view-block-select-button__anchor-wrapper">
<Truncate
className="block-editor-list-view-block-select-button__anchor"
ellipsizeMode="auto"
>
<Badge className="block-editor-list-view-block-select-button__anchor">
{ blockInformation.anchor }
</Truncate>
</Badge>
</span>
) }
{ isSticky && (
Expand Down
6 changes: 1 addition & 5 deletions packages/block-editor/src/components/list-view/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -408,15 +408,11 @@
position: absolute;
right: 0;
transform: translateY(-50%);
background: rgba($black, 0.1);
border-radius: $radius-x-small;
padding: 2px 6px;
max-width: 100%;
box-sizing: border-box;
}

&.is-selected .block-editor-list-view-block-select-button__anchor {
background: rgba($black, 0.3);
color: $white;
}

.block-editor-list-view-block-select-button__lock,
Expand Down

0 comments on commit 14d10ea

Please sign in to comment.