Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
Comment thread
hbhalodia marked this conversation as resolved.
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
2 changes: 1 addition & 1 deletion packages/components/src/angle-picker-control/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ function UnforwardedAnglePickerControl(
<Flex { ...restProps } ref={ ref } className={ classes } gap={ 2 }>
<FlexBlock>
<NumberControl
__next40pxDefaultSize
Comment thread
hbhalodia marked this conversation as resolved.
Resolved
label={ label }
className="components-angle-picker-control__input-field"
max={ 360 }
min={ 0 }
onChange={ handleOnNumberChange }
size="__unstable-large"
step="1"
value={ value }
spinControls="none"
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
Comment thread
hbhalodia marked this conversation as resolved.
Resolved
min={ min }
max={ max }
label={ label }
Expand All @@ -45,7 +46,6 @@ export const InputWithSlider = ( {
</InputControlPrefixWrapper>
}
spinControls="none"
size="__unstable-large"
/>
<RangeControl
__nextHasNoMarginBottom
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`
9 changes: 9 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 Down Expand Up @@ -53,9 +54,17 @@ function UnforwardedNumberControl(
size = 'default',
suffix,
onChange = noop,
__shouldNotWarnDeprecated36pxSize,
...restProps
} = useDeprecated36pxDefaultSizeProp< NumberControlProps >( props );

maybeWarnDeprecated36pxSize( {
componentName: 'NumberControl',
size,
__next40pxDefaultSize: restProps.__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