Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NumberControl: Deprecate 36px default size #66730

Merged
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ const LineHeightControl = ( {
<div className="block-editor-line-height-control">
<NumberControl
{ ...otherProps }
__shouldNotWarnDeprecated36pxSize
hbhalodia marked this conversation as resolved.
Show resolved Hide resolved
__next40pxDefaultSize={ __next40pxDefaultSize }
__unstableInputWidth={ __unstableInputWidth }
__unstableStateReducer={ stateReducer }
Expand Down
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

- `BoxControl`: Passive deprecate `onMouseOver`/`onMouseOut`. Pass to the `inputProps` prop instead ([#67332](https://github.com/WordPress/gutenberg/pull/67332)).
- `BoxControl`: Deprecate 36px default size ([#66704](https://github.com/WordPress/gutenberg/pull/66704)).
- `NumberControl`: Deprecate 36px default size ([#66730](https://github.com/WordPress/gutenberg/pull/66730)).
- `UnitControl`: Deprecate 36px default size ([#66791](https://github.com/WordPress/gutenberg/pull/66791)).

### Enhancements
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/angle-picker-control/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ function UnforwardedAnglePickerControl(
<Flex { ...restProps } ref={ ref } className={ classes } gap={ 2 }>
<FlexBlock>
<NumberControl
__next40pxDefaultSize
hbhalodia marked this conversation as resolved.
Show resolved Hide resolved
label={ label }
className="components-angle-picker-control__input-field"
max={ 360 }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const InputWithSlider = ( {
return (
<HStack spacing={ 4 }>
<NumberControlWrapper
__next40pxDefaultSize
hbhalodia marked this conversation as resolved.
Show resolved Hide resolved
min={ min }
max={ max }
label={ label }
Expand Down
3 changes: 2 additions & 1 deletion packages/components/src/number-control/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const Example = () => {

return (
<NumberControl
__next40pxDefaultSize
isShiftStepEnabled={ true }
onChange={ setValue }
shiftStep={ 10 }
Expand Down Expand Up @@ -146,4 +147,4 @@ Start opting into the larger default height that will become the default size in

- Type: `Boolean`
- Required: No
- Default: `false`
- Default: `false`
10 changes: 10 additions & 0 deletions packages/components/src/number-control/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { HStack } from '../h-stack';
import { Spacer } from '../spacer';
import { useCx } from '../utils';
import { useDeprecated36pxDefaultSizeProp } from '../utils/use-deprecated-props';
import { maybeWarnDeprecated36pxSize } from '../utils/deprecated-36px-size';

const noop = () => {};

Expand All @@ -34,6 +35,7 @@ function UnforwardedNumberControl(
forwardedRef: ForwardedRef< any >
) {
const {
__next40pxDefaultSize,
hbhalodia marked this conversation as resolved.
Show resolved Hide resolved
__unstableStateReducer: stateReducerProp,
className,
dragDirection = 'n',
Expand All @@ -53,9 +55,17 @@ function UnforwardedNumberControl(
size = 'default',
suffix,
onChange = noop,
__shouldNotWarnDeprecated36pxSize,
...restProps
} = useDeprecated36pxDefaultSizeProp< NumberControlProps >( props );

maybeWarnDeprecated36pxSize( {
componentName: 'NumberControl',
size,
__next40pxDefaultSize,
__shouldNotWarnDeprecated36pxSize,
} );

if ( hideHTMLArrows ) {
deprecated( 'wp.components.NumberControl hideHTMLArrows prop ', {
alternative: 'spinControls="none"',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,5 @@ const Template: StoryFn< typeof NumberControl > = ( {
export const Default = Template.bind( {} );
Default.args = {
label: 'Value',
__next40pxDefaultSize: true,
};
6 changes: 5 additions & 1 deletion packages/components/src/number-control/test/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@ import { useState } from '@wordpress/element';
/**
* Internal dependencies
*/
import NumberControl from '..';
import _NumberControl from '..';
import type { NumberControlProps } from '../types';

const NumberControl = (
props: React.ComponentProps< typeof _NumberControl >
) => <_NumberControl __next40pxDefaultSize { ...props } />;

function StatefulNumberControl( props: NumberControlProps ) {
const [ value, setValue ] = useState( props.value );
const handleOnChange = ( v: string | undefined ) => setValue( v );
Expand Down
7 changes: 7 additions & 0 deletions packages/components/src/number-control/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,11 @@ export type NumberControlProps = Omit<
* The value of the input.
*/
value?: number | string;
/**
* Do not throw a warning for the deprecated 36px default size.
* For internal components of other components that already throw the warning.
*
* @ignore
*/
__shouldNotWarnDeprecated36pxSize?: boolean;
};
1 change: 1 addition & 0 deletions packages/components/src/range-control/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ function UnforwardedRangeControl(
step={ step }
// @ts-expect-error TODO: Investigate if the `null` value is necessary
value={ inputSliderValue }
__shouldNotWarnDeprecated36pxSize
/>
) }
{ allowReset && (
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/unit-control/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ function UnforwardedUnitControl(
return (
<ValueInput
{ ...props }
__shouldNotWarnDeprecated36pxSize
autoComplete={ autoComplete }
className={ classes }
disabled={ disabled }
Expand Down
Loading