Skip to content

Commit

Permalink
Button : deprecate isSmall prop (WordPress#59734)
Browse files Browse the repository at this point in the history
* Button : deprecate `isSmall` prop

* Update changelog

* Update types

* revert unit test changes

* Remove version prop from deprecated function

* Remove `deprecated()` functon

Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: tyxla <tyxla@git.wordpress.org>
  • Loading branch information
4 people authored and carstingaxion committed Mar 27, 2024
1 parent 7ff88d9 commit 4b28ddf
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
4 changes: 4 additions & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

- `TextControl`: Add typings for `date`, `time` and `datetime-local` ([#59666](https://github.com/WordPress/gutenberg/pull/59666)).

### Deprecation

- `isSmall` prop in `Button` component has been deprecated. Use `size="small"` prop instead ([#59734](https://github.com/WordPress/gutenberg/pull/59734)).

### Internal

- `Button`: Keep deprecated props in type definitions ([#59913](https://github.com/WordPress/gutenberg/pull/59913)).
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/button/test/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe( 'Button', () => {
} );

it( 'should render a button element with is-secondary and is-small class', () => {
render( <Button variant="secondary" isSmall /> );
render( <Button variant="secondary" size="small" /> );
const button = screen.getByRole( 'button' );

expect( button ).toHaveClass( 'is-secondary' );
Expand Down
16 changes: 7 additions & 9 deletions packages/components/src/button/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,6 @@ type BaseButtonProps = {
* Renders a pressed button style.
*/
isPressed?: boolean;
// TODO: Deprecate officially (add console warning and move to DeprecatedButtonProps).
/**
* Decreases the size of the button.
*
* Deprecated in favor of the `size` prop. If both props are defined, the `size` prop will take precedence.
*
* @deprecated Use the `'small'` value on the `size` prop instead.
*/
isSmall?: boolean;
/**
* Sets the `aria-label` of the component, if none is provided.
* Sets the Tooltip content if `showTooltip` is provided.
Expand Down Expand Up @@ -184,6 +175,13 @@ export type DeprecatedButtonProps = {
* @ignore
*/
isTertiary?: boolean;
/**
* Decreases the size of the button.
*
* @deprecated Use the `'small'` value on the `size` prop instead.
* @ignore
*/
isSmall?: boolean;
};

export type DeprecatedIconButtonProps = {
Expand Down

0 comments on commit 4b28ddf

Please sign in to comment.