diff --git a/packages/components/src/button/README.md b/packages/components/src/button/README.md index c67c795addbf4d..089790bedfc118 100644 --- a/packages/components/src/button/README.md +++ b/packages/components/src/button/README.md @@ -8,10 +8,11 @@ Lets users take actions and make choices with a single click or tap. ```jsx import { Button } from '@wordpress/components'; -const Mybutton = () => ( +const MyButton = () => ( 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 ( -