From ea621aaa9b6094e8b88cfa47ffc2e0c49ed2c1fe Mon Sep 17 00:00:00 2001 From: hbhalodia Date: Tue, 5 Nov 2024 09:06:56 +0530 Subject: [PATCH 1/2] Add the deprecation for 36px default size to number control --- packages/components/src/number-control/README.md | 3 ++- packages/components/src/number-control/index.tsx | 8 ++++++++ .../components/src/number-control/stories/index.story.tsx | 1 + packages/components/src/number-control/test/index.tsx | 2 +- 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/components/src/number-control/README.md b/packages/components/src/number-control/README.md index 8421691296e90a..486092790548ee 100644 --- a/packages/components/src/number-control/README.md +++ b/packages/components/src/number-control/README.md @@ -16,6 +16,7 @@ const Example = () => { return ( {}; @@ -34,6 +35,7 @@ function UnforwardedNumberControl( forwardedRef: ForwardedRef< any > ) { const { + __next40pxDefaultSize, __unstableStateReducer: stateReducerProp, className, dragDirection = 'n', @@ -56,6 +58,12 @@ function UnforwardedNumberControl( ...restProps } = useDeprecated36pxDefaultSizeProp< NumberControlProps >( props ); + maybeWarnDeprecated36pxSize( { + componentName: 'NumberControl', + size, + __next40pxDefaultSize, + } ); + if ( hideHTMLArrows ) { deprecated( 'wp.components.NumberControl hideHTMLArrows prop ', { alternative: 'spinControls="none"', diff --git a/packages/components/src/number-control/stories/index.story.tsx b/packages/components/src/number-control/stories/index.story.tsx index 3588063f0f4bb2..55eb263fa90a5a 100644 --- a/packages/components/src/number-control/stories/index.story.tsx +++ b/packages/components/src/number-control/stories/index.story.tsx @@ -61,4 +61,5 @@ const Template: StoryFn< typeof NumberControl > = ( { export const Default = Template.bind( {} ); Default.args = { label: 'Value', + __next40pxDefaultSize: true, }; diff --git a/packages/components/src/number-control/test/index.tsx b/packages/components/src/number-control/test/index.tsx index 3cf3368f1636ba..536c6b0afb854c 100644 --- a/packages/components/src/number-control/test/index.tsx +++ b/packages/components/src/number-control/test/index.tsx @@ -31,7 +31,7 @@ function StatefulNumberControl( props: NumberControlProps ) { describe( 'NumberControl', () => { describe( 'Basic rendering', () => { it( 'should render', () => { - render( ); + render( ); expect( screen.getByRole( 'spinbutton' ) ).toBeVisible(); } ); From 810bd75aa713bc09bc6f62d509e8e6b817abaf3c Mon Sep 17 00:00:00 2001 From: hbhalodia Date: Tue, 5 Nov 2024 09:10:24 +0530 Subject: [PATCH 2/2] Add the changelog for the deprecation --- packages/components/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/components/CHANGELOG.md b/packages/components/CHANGELOG.md index 93b191bff269d6..e7979b6dc00caa 100644 --- a/packages/components/CHANGELOG.md +++ b/packages/components/CHANGELOG.md @@ -5,6 +5,7 @@ ### Deprecations - `Radio`: Deprecate 36px default size ([#66572](https://github.com/WordPress/gutenberg/pull/66572)). +- `NumberControl`: Deprecate 36px default size ([#66730](https://github.com/WordPress/gutenberg/pull/66730)). ### Enhancements