Skip to content

Commit

Permalink
Fix: Button Replace remaining 40px default size violations [Block Edi…
Browse files Browse the repository at this point in the history
…tor 5] (WordPress#65361)

* Fix: inspector control tabs to use 40px default button size

* Fix: inspector popover header to use 40px default button size

* Fix: link control  to use 40px default button size

* Fix: list view to use 40px default button size

* Fix: media placeholder to use 40px default button size

* Add size attribute to inspector popover header and list view

* Revert the changes for submit button

* Replace button component

* Remove override CSS

* Remove __next40pxDefaultSize prop

Co-authored-by: Marco Ciampini <[email protected]>

* Remove __next40pxDefaultSize prop

Co-authored-by: Marco Ciampini <[email protected]>

---------

Co-authored-by: PARTHVATALIYA <[email protected]>
Co-authored-by: getdave <[email protected]>
Co-authored-by: mirka <[email protected]>
Co-authored-by: ciampo <[email protected]>
Co-authored-by: tyxla <[email protected]>
  • Loading branch information
6 people authored Sep 25, 2024
1 parent 79a8904 commit e321b5a
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,6 @@

.block-editor-block-inspector__tab-item {
flex: 1 1 0px;
display: flex;
justify-content: center;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
* WordPress dependencies
*/
import {
Button,
Icon,
Tooltip,
privateApis as componentsPrivateApis,
} from '@wordpress/components';
import { store as preferencesStore } from '@wordpress/preferences';
Expand Down Expand Up @@ -43,27 +44,27 @@ export default function InspectorControlsTabs( {
<div className="block-editor-block-inspector__tabs">
<Tabs defaultTabId={ initialTabName } key={ clientId }>
<Tabs.TabList>
{ tabs.map( ( tab ) => (
<Tabs.Tab
key={ tab.name }
tabId={ tab.name }
render={
<Button
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
icon={
! showIconLabels ? tab.icon : undefined
}
label={
! showIconLabels ? tab.title : undefined
}
{ tabs.map( ( tab ) =>
showIconLabels ? (
<Tabs.Tab
key={ tab.name }
tabId={ tab.name }
className={ tab.className }
>
{ tab.title }
</Tabs.Tab>
) : (
<Tooltip text={ tab.title } key={ tab.name }>
<Tabs.Tab
tabId={ tab.name }
className={ tab.className }
aria-label={ tab.title }
>
{ showIconLabels && tab.title }
</Button>
}
/>
) ) }
<Icon icon={ tab.icon } />
</Tabs.Tab>
</Tooltip>
)
) }
</Tabs.TabList>
<Tabs.TabPanel tabId={ TAB_SETTINGS.name } focusable={ false }>
<SettingsTab showAdvancedControls={ !! blockName } />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ export default function InspectorPopoverHeader( {
<Spacer />
{ actions.map( ( { label, icon, onClick } ) => (
<Button
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
size="small"
key={ label }
className="block-editor-inspector-popover-header__action"
label={ label }
Expand All @@ -45,8 +44,7 @@ export default function InspectorPopoverHeader( {
) ) }
{ onClose && (
<Button
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
size="small"
className="block-editor-inspector-popover-header__action"
label={ __( 'Close' ) }
icon={ closeSmall }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
.block-editor-inspector-popover-header {
margin-bottom: $grid-unit-20;
}

[class].block-editor-inspector-popover-header__action {
height: $icon-size;

&.has-icon {
min-width: $icon-size;
padding: 0;
}

&:not(.has-icon) {
text-decoration: underline;
}
}
6 changes: 2 additions & 4 deletions packages/block-editor/src/components/link-control/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -474,16 +474,14 @@ function LinkControl( {
className="block-editor-link-control__search-actions"
>
<Button
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
variant="tertiary"
onClick={ handleCancel }
>
{ __( 'Cancel' ) }
</Button>
<Button
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
variant="primary"
onClick={ isDisabled ? noop : handleSubmit }
className="block-editor-link-control__search-submit"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ function LinkSettingsDrawer( { children, settingsOpen, setSettingsOpen } ) {
return (
<>
<Button
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
className="block-editor-link-control__drawer-toggle"
aria-expanded={ settingsOpen }
onClick={ () => setSettingsOpen( ! settingsOpen ) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import clsx from 'clsx';
* WordPress dependencies
*/
import {
Button,
__experimentalHStack as HStack,
__experimentalTruncate as Truncate,
} from '@wordpress/components';
Expand Down Expand Up @@ -82,9 +81,7 @@ function ListViewBlockSelectButton(
}

return (
<Button
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
<a
className={ clsx(
'block-editor-list-view-block-select-button',
className
Expand Down Expand Up @@ -156,7 +153,7 @@ function ListViewBlockSelectButton(
</span>
) }
</HStack>
</Button>
</a>
);
}

Expand Down
9 changes: 9 additions & 0 deletions packages/block-editor/src/components/list-view/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,15 @@
text-align: left;
position: relative;
white-space: nowrap;
border-radius: 2px;
box-sizing: border-box;
color: inherit;
font-family: inherit;
font-size: 13px;
font-weight: 400;
margin: 0;
text-decoration: none;
transition: box-shadow 0.1s linear;

.components-modal__content & {
padding-left: 0;
Expand Down
18 changes: 6 additions & 12 deletions packages/block-editor/src/components/media-placeholder/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ const URLSelectionUI = ( { src, onChangeSrc, onSelectURL } ) => {
return (
<div className="block-editor-media-placeholder__url-input-container">
<Button
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
className="block-editor-media-placeholder__button"
onClick={ openURLInput }
isPressed={ isURLInputVisible }
Expand Down Expand Up @@ -389,8 +388,7 @@ export function MediaPlaceholder( {
return (
onCancel && (
<Button
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
className="block-editor-media-placeholder__cancel-button"
title={ __( 'Cancel' ) }
variant="link"
Expand Down Expand Up @@ -419,8 +417,7 @@ export function MediaPlaceholder( {
onToggleFeaturedImage && (
<div className="block-editor-media-placeholder__url-input-container">
<Button
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
className="block-editor-media-placeholder__button"
onClick={ onToggleFeaturedImage }
variant="secondary"
Expand All @@ -436,8 +433,7 @@ export function MediaPlaceholder( {
const defaultButton = ( { open } ) => {
return (
<Button
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
variant="secondary"
onClick={ () => {
open();
Expand Down Expand Up @@ -477,8 +473,7 @@ export function MediaPlaceholder( {
const content = (
<>
<Button
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
variant="primary"
className={ clsx(
'block-editor-media-placeholder__button',
Expand Down Expand Up @@ -508,8 +503,7 @@ export function MediaPlaceholder( {
<FormFileUpload
render={ ( { openFileDialog } ) => (
<Button
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
onClick={ openFileDialog }
variant="primary"
className={ clsx(
Expand Down

0 comments on commit e321b5a

Please sign in to comment.