From ba85b0de0cb2eaa37a43200e5cb8f31335b3ac23 Mon Sep 17 00:00:00 2001 From: Lena Morita Date: Fri, 27 Dec 2024 02:36:41 +0900 Subject: [PATCH 1/3] Button: Deprecate 36px default size --- packages/components/src/button/index.tsx | 14 +++++++++++++- .../src/button/stories/index.story.tsx | 11 ++++++++--- packages/components/src/button/types.ts | 7 +++++++ .../src/utils/deprecated-36px-size.ts | 19 ++++++++++++++----- 4 files changed, 42 insertions(+), 9 deletions(-) diff --git a/packages/components/src/button/index.tsx b/packages/components/src/button/index.tsx index 0ab6b24b4dd6aa..e572e393ac2709 100644 --- a/packages/components/src/button/index.tsx +++ b/packages/components/src/button/index.tsx @@ -25,11 +25,13 @@ import Icon from '../icon'; import { VisuallyHidden } from '../visually-hidden'; import type { ButtonProps, DeprecatedButtonProps } from './types'; import { positionToPlacement } from '../popover/utils'; +import { maybeWarnDeprecated36pxSize } from '../utils/deprecated-36px-size'; const disabledEventsOnDisabledButton = [ 'onMouseDown', 'onClick' ] as const; function useDeprecatedProps( { __experimentalIsFocusable, + __shouldNotWarnDeprecated36pxSize, isDefault, isPrimary, isSecondary, @@ -81,6 +83,15 @@ function useDeprecatedProps( { computedVariant ??= 'link'; } + if ( computedVariant !== 'link' ) { + maybeWarnDeprecated36pxSize( { + componentName: 'Button', + size: computedSize, + __next40pxDefaultSize: otherProps.__next40pxDefaultSize, + __shouldNotWarnDeprecated36pxSize, + } ); + } + return { ...newProps, ...otherProps, @@ -292,10 +303,11 @@ export function UnforwardedButton( * * ```jsx * import { Button } from '@wordpress/components'; - * const Mybutton = () => ( + * const MyButton = () => ( * diff --git a/packages/components/src/button/stories/index.story.tsx b/packages/components/src/button/stories/index.story.tsx index 605b56686c702f..fbce879e2e4d88 100644 --- a/packages/components/src/button/stories/index.story.tsx +++ b/packages/components/src/button/stories/index.story.tsx @@ -63,6 +63,7 @@ const Template: StoryFn< typeof Button > = ( props ) => { export const Default = Template.bind( {} ); Default.args = { children: 'Code is poetry', + __next40pxDefaultSize: true, }; /** @@ -113,10 +114,14 @@ IsDestructive.args = { isDestructive: true, }; +/** + * In most cases, the `"compact"` size should be used for icon buttons. + */ export const Icon = Template.bind( {} ); Icon.args = { label: 'Code is poetry', icon: 'wordpress', + size: 'compact', }; export const GroupedIcons = () => { @@ -126,9 +131,9 @@ export const GroupedIcons = () => { return ( -