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

Fix: Button Replace remaining 40px default size violations [Block Editor 1]. #65034

Merged
merged 10 commits into from
Sep 6, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ function BlockBreadcrumb( { rootLabelText } ) {
>
{ hasSelection && (
<Button
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
size="small"
className="block-editor-block-breadcrumb__button"
variant="tertiary"
onClick={ () => {
Expand Down Expand Up @@ -96,8 +95,7 @@ function BlockBreadcrumb( { rootLabelText } ) {
{ parents.map( ( parentClientId ) => (
<li key={ parentClientId }>
<Button
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
size="small"
className="block-editor-block-breadcrumb__button"
variant="tertiary"
onClick={ () => selectBlock( parentClientId ) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
}

.block-editor-block-breadcrumb__button.components-button {
height: $button-size-small;
Copy link
Contributor

@ciampo ciampo Sep 5, 2024

Choose a reason for hiding this comment

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

We can potentially remove a lot more style overrides (and the .components-button classname, which should not be used at all). It also looks like the tertiary variant is not really needed.

Something like this (click to show diff)
diff --git a/packages/block-editor/src/components/block-breadcrumb/index.js b/packages/block-editor/src/components/block-breadcrumb/index.js
index 865d8d0600..be0ab9fc45 100644
--- a/packages/block-editor/src/components/block-breadcrumb/index.js
+++ b/packages/block-editor/src/components/block-breadcrumb/index.js
@@ -68,7 +68,6 @@ function BlockBreadcrumb( { rootLabelText } ) {
 					<Button
 						size="small"
 						className="block-editor-block-breadcrumb__button"
-						variant="tertiary"
 						onClick={ () => {
 							// Find the block editor wrapper for the selected block
 							const blockEditor = blockRef.current?.closest(
diff --git a/packages/block-editor/src/components/block-breadcrumb/style.scss b/packages/block-editor/src/components/block-breadcrumb/style.scss
index a1ae3bf2f1..af56971fe4 100644
--- a/packages/block-editor/src/components/block-breadcrumb/style.scss
+++ b/packages/block-editor/src/components/block-breadcrumb/style.scss
@@ -22,39 +22,11 @@
 	}
 }
 
-.block-editor-block-breadcrumb__button.components-button {
-	line-height: $button-size-small;
-	padding: 0;
-	position: relative;
-
-	&:hover:not(:disabled) {
-		text-decoration: underline;
-		box-shadow: none;
-	}
-
-	&:focus {
-		box-shadow: none;
-	}
-
-	&:focus::before {
-		content: "";
-		display: block;
-		position: absolute;
-		border-radius: $radius-block-ui;
-		top: $border-width;
-		right: $border-width;
-		bottom: $border-width;
-		left: $border-width;
-
-		@include button-style__focus();
-	}
-}
-
 .block-editor-block-breadcrumb__current {
 	cursor: default;
 }
 
-.block-editor-block-breadcrumb__button.components-button,
+.block-editor-block-breadcrumb__button.block-editor-block-breadcrumb__button,
 .block-editor-block-breadcrumb__current {
 	color: $gray-900;
 	padding: 0 $grid-unit-10;
Kapture.2024-09-05.at.16.45.51.mp4

What do you folks think? cc @WordPress/gutenberg-design

Copy link
Contributor

Choose a reason for hiding this comment

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

LGTM.

line-height: $button-size-small;
padding: 0;
position: relative;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ export default function BlockView( {

<div className="block-editor-block-compare__action">
<Button
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This can be seen when any block as a validation error and you click on resolve.

Before After
block compare 36 block compare 40px

variant="secondary"
tabIndex="0"
onClick={ action }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,15 @@ export function MultipleUsageWarning( {
<Warning
actions={ [
<Button
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This occurs when a block has multiple supports set to false in block.json and you add that block multiple times in the editor.

Before After
multiple usage warning 36 multiple usage warning 40px

key="find-original"
variant="secondary"
onClick={ () => selectBlock( originalBlockClientId ) }
>
{ __( 'Find original' ) }
</Button>,
<Button
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
key="remove"
variant="secondary"
onClick={ () => onReplace( [] ) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ export default function BlockInvalidWarning( { clientId } ) {
<Warning
actions={ [
<Button
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The invalid warning can be seen when a block's content is invalid after saving the page and then returning to it.

Before After
block validation 36 block invalidation 40px

key="recover"
onClick={ convert.toRecoveredBlock }
variant="primary"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@ const BlockMoverButton = forwardRef(
return (
<>
<Button
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
ref={ ref }
className={ clsx(
'block-editor-block-mover-button',
Expand Down
3 changes: 1 addition & 2 deletions packages/block-editor/src/components/block-mover/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ function BlockMover( {
<BlockDraggable clientIds={ clientIds } fadeWhenDisabled>
{ ( draggableProps ) => (
<Button
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
icon={ dragHandle }
className="block-editor-block-mover__drag-handle"
label={ __( 'Drag' ) }
Expand Down
Loading