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

BlockCard: Fix title alignment #68115

Merged
merged 1 commit into from
Dec 19, 2024
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
26 changes: 5 additions & 21 deletions packages/block-editor/src/components/block-card/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ import {
privateApis as componentsPrivateApis,
} from '@wordpress/components';
import { chevronLeft, chevronRight } from '@wordpress/icons';
import { __, _x, isRTL, sprintf } from '@wordpress/i18n';
import { __, isRTL } from '@wordpress/i18n';
import { useSelect, useDispatch } from '@wordpress/data';
import { createInterpolateElement } from '@wordpress/element';

/**
* Internal dependencies
Expand Down Expand Up @@ -71,25 +70,10 @@ function BlockCard( { title, icon, description, blockType, className, name } ) {
<BlockIcon icon={ icon } showColors />
<VStack spacing={ 1 }>
<h2 className="block-editor-block-card__title">
{ name?.length
? createInterpolateElement(
sprintf(
// translators: 1: Custom block name. 2: Block title.
_x(
'<span>%1$s</span> <badge>%2$s</badge>',
'block label'
),
name,
title
),
{
span: (
<span className="block-editor-block-card__name" />
),
badge: <Badge />,
}
)
: title }
<span className="block-editor-block-card__name">
{ !! name?.length ? name : title }
</span>
{ !! name?.length && <Badge>{ title }</Badge> }
</h2>
{ description && (
<Text className="block-editor-block-card__description">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@
font-size: $default-font-size;
line-height: $default-line-height;
margin: 0;
padding: 3px 0; // This makes the title as high as the icon.
}
}

.block-editor-block-card__name {
padding: 3px 0; // This makes the title as high as the icon.
}

.block-editor-block-card .block-editor-block-icon {
flex: 0 0 $button-size-small;
margin-left: 0;
Expand Down
Loading