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 @@ -602,7 +602,6 @@ export default function DimensionsPanel( {
>
{ ! showSpacingPresetsControl && (
<BoxControl
__next40pxDefaultSize
values={ paddingValues }
onChange={ setPaddingValues }
label={ __( 'Padding' ) }
Expand Down Expand Up @@ -645,7 +644,6 @@ export default function DimensionsPanel( {
>
{ ! showSpacingPresetsControl && (
<BoxControl
__next40pxDefaultSize
values={ marginValues }
onChange={ setMarginValues }
inputProps={ {
Expand Down Expand Up @@ -701,7 +699,6 @@ export default function DimensionsPanel( {
{ ! showSpacingPresetsControl &&
( isAxialGap ? (
<BoxControl
__next40pxDefaultSize
label={ __( 'Block spacing' ) }
min={ 0 }
onChange={ setGapValues }
Expand Down
4 changes: 3 additions & 1 deletion packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

### Breaking Changes

- `TextControl`: The `__next40pxDefaultSize` prop is now true by default. The prop can be safely removed ([#79386](https://github.com/WordPress/gutenberg/pull/79386)).
- The `__next40pxDefaultSize` prop is now true by default. The prop can be safely removed ([#79386](https://github.com/WordPress/gutenberg/pull/79386), [#79419](https://github.com/WordPress/gutenberg/pull/79419)):
- `BoxControl`
- `TextControl`

### Enhancements

Expand Down
14 changes: 1 addition & 13 deletions packages/components/src/box-control/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,13 @@ function Example() {
} );

return (
<BoxControl
__next40pxDefaultSize
values={ values }
onChange={ setValues }
/>
<BoxControl values={ values } onChange={ setValues } />
);
};
```

## Props

### `__next40pxDefaultSize`

- Type: `boolean`
- Required: No
- Default: `false`

Start opting into the larger default height that will become the default size in a future version.

### `allowReset`

- Type: `boolean`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ function getSidesToModify(
}

export default function BoxInputControl( {
__next40pxDefaultSize,
onChange = noop,
onFocus = noop,
values,
Expand Down Expand Up @@ -208,7 +207,7 @@ export default function BoxInputControl( {
{ ...props }
min={ min }
__shouldNotWarnDeprecated36pxSize
__next40pxDefaultSize={ __next40pxDefaultSize }
__next40pxDefaultSize
className="component-box-control__unit-control"
id={ inputId }
isPressEnterToChange
Expand All @@ -224,7 +223,7 @@ export default function BoxInputControl( {
</Tooltip>

<FlexedRangeControl
__next40pxDefaultSize={ __next40pxDefaultSize }
__next40pxDefaultSize
__shouldNotWarnDeprecated36pxSize
aria-controls={ inputId }
label={ LABELS[ side ] }
Expand Down
28 changes: 5 additions & 23 deletions packages/components/src/box-control/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import warning from '@wordpress/warning';
* Internal dependencies
*/
import { BaseControl } from '../base-control';
import InputControl from './input-control';
import BoxInputControl from './box-input-control';

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed to make it clearer that it's just an internal input control component. This also avoids the need for an eslint disable.

import LinkedButton from './linked-button';
import { Grid } from '../grid';
import {
Expand All @@ -27,7 +27,6 @@ import {
} from './utils';
import { useControlledState } from '../utils/hooks';
import type { BoxControlProps, BoxControlValue } from './types';
import { maybeWarnDeprecated36pxSize } from '../utils/deprecated-36px-size';

const defaultInputProps = {
min: 0,
Expand Down Expand Up @@ -58,17 +57,12 @@ function useUniqueId( idProp?: string ) {
* } );
*
* return (
* <BoxControl
* __next40pxDefaultSize
* values={ values }
* onChange={ setValues }
* />
* <BoxControl values={ values } onChange={ setValues } />
* );
* };
* ```
*/
function BoxControl( {
__next40pxDefaultSize = false,
id: idProp,
inputProps = defaultInputProps,
onChange = noop,
Expand Down Expand Up @@ -137,16 +131,10 @@ function BoxControl( {
setSelectedUnits,
sides,
values: inputValues,
__next40pxDefaultSize,
presets,
presetKey,
};

maybeWarnDeprecated36pxSize( {
componentName: 'BoxControl',
__next40pxDefaultSize,
size: undefined,
} );
const sidesToRender = getAllowedSides( sides );

if ( ( presets && ! presetKey ) || ( ! presets && presetKey ) ) {
Expand All @@ -170,9 +158,7 @@ function BoxControl( {
</BaseControl.VisualLabel>
{ isLinked && (
<InputWrapper>
{ /* Disable reason: the parent component is handling the __next40pxDefaultSize prop */ }
{ /* eslint-disable-next-line @wordpress/components-no-missing-40px-size-prop */ }
<InputControl side="all" { ...inputControlProps } />
<BoxInputControl side="all" { ...inputControlProps } />
</InputWrapper>
) }
{ ! hasOneSide && (
Expand All @@ -187,9 +173,7 @@ function BoxControl( {
{ ! isLinked &&
splitOnAxis &&
[ 'vertical', 'horizontal' ].map( ( axis ) => (
// Disable reason: the parent component is handling the __next40pxDefaultSize prop
// eslint-disable-next-line @wordpress/components-no-missing-40px-size-prop
<InputControl
<BoxInputControl
key={ axis }
side={ axis as 'horizontal' | 'vertical' }
{ ...inputControlProps }
Expand All @@ -198,9 +182,7 @@ function BoxControl( {
{ ! isLinked &&
! splitOnAxis &&
Array.from( sidesToRender ).map( ( axis ) => (
// Disable reason: the parent component is handling the __next40pxDefaultSize prop
// eslint-disable-next-line @wordpress/components-no-missing-40px-size-prop
<InputControl
<BoxInputControl
key={ axis }
side={ axis }
{ ...inputControlProps }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,14 @@ const meta: Meta< typeof BoxControl > = {
export default meta;

const TemplateUncontrolled: StoryFn< typeof BoxControl > = ( props ) => {
return <BoxControl __next40pxDefaultSize { ...props } />;
return <BoxControl { ...props } />;
};

const TemplateControlled: StoryFn< typeof BoxControl > = ( props ) => {
const [ values, setValues ] = useState< ( typeof props )[ 'values' ] >();

return (
<BoxControl
__next40pxDefaultSize
values={ values }
{ ...props }
onChange={ ( nextValue ) => {
Expand All @@ -58,7 +57,6 @@ const TemplateControlled: StoryFn< typeof BoxControl > = ( props ) => {
export const Default = TemplateUncontrolled.bind( {} );
Default.args = {
label: 'Label',
__next40pxDefaultSize: true,
};

export const Controlled = TemplateControlled.bind( {} );
Expand Down
3 changes: 1 addition & 2 deletions packages/components/src/box-control/test/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const ControlledBoxControl = (

return (
<BoxControl
__next40pxDefaultSize
values={ state }
onChange={ ( next ) => setState( next ) }
{ ...extraProps }
Expand All @@ -42,7 +41,7 @@ const UncontrolledBoxControl = ( {
...props
}: DistributiveOmit< BoxControlProps, 'onChange' > & {
onChange?: BoxControlProps[ 'onChange' ];
} ) => <BoxControl __next40pxDefaultSize onChange={ onChange } { ...props } />;
} ) => <BoxControl onChange={ onChange } { ...props } />;

describe( 'BoxControl', () => {
describe( 'Basic rendering', () => {
Expand Down
13 changes: 7 additions & 6 deletions packages/components/src/box-control/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ type UnitControlPassthroughProps = Omit<
>;

type DeprecatedBoxControlProps = {
/**
* Start opting into the larger default height that will become the default size in a future version.
*
* @deprecated Default behavior since WordPress 7.1. Prop can be safely removed.
* @ignore
*/
__next40pxDefaultSize?: boolean;
/**
* @deprecated Pass to the `inputProps` prop instead.
* @ignore
Expand Down Expand Up @@ -94,12 +101,6 @@ export type BoxControlProps = Pick< UnitControlProps, 'units' > &
* The current values of the control, expressed as an object of `top`, `right`, `bottom`, and `left` values.
*/
values?: BoxControlValue;
/**
* Start opting into the larger default height that will become the default size in a future version.
*
* @default false
*/
__next40pxDefaultSize?: boolean;
} & (
| {
/**
Expand Down
2 changes: 0 additions & 2 deletions packages/components/src/tools-panel/tools-panel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ export function DimensionPanel() {
onDeselect={ () => setPadding( undefined ) }
>
<BoxControl
__next40pxDefaultSize
label={ __( 'Padding' ) }
onChange={ setPadding }
values={ padding }
Expand All @@ -139,7 +138,6 @@ export function DimensionPanel() {
onDeselect={ () => setMargin( undefined ) }
>
<BoxControl
__next40pxDefaultSize
label={ __( 'Margin' ) }
onChange={ setMargin }
values={ margin }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ The following components are checked by this rule:

- BorderBoxControl
- BorderControl
- BoxControl
- Button
- ComboboxControl
- CustomSelectControl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ ruleTester.run( 'components-no-missing-40px-size-prop', rule, {
import {
BorderBoxControl,
BorderControl,
BoxControl,
ComboboxControl,
CustomSelectControl,
FontAppearanceControl,
Expand All @@ -131,7 +130,6 @@ ruleTester.run( 'components-no-missing-40px-size-prop', rule, {
<>
<BorderBoxControl __next40pxDefaultSize />
<BorderControl __next40pxDefaultSize />
<BoxControl __next40pxDefaultSize />
<ComboboxControl __next40pxDefaultSize />
<CustomSelectControl __next40pxDefaultSize />
<FontAppearanceControl __next40pxDefaultSize />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const { hasTruthyJsxAttribute } = require( '../utils' );
const COMPONENTS_REQUIRING_40PX = new Set( [
'BorderBoxControl',
'BorderControl',
'BoxControl',
'Button',
'ClipboardButton',
'ComboboxControl',
Expand Down
10 changes: 4 additions & 6 deletions tools/eslint/config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,10 @@ const restrictedSyntax = [
selector: 'JSXAttribute[name.name="__nextHasNoMarginBottom"]',
message: 'The `__nextHasNoMarginBottom` prop is no longer needed.',
},
{
selector:
'JSXElement[openingElement.name.name="TextControl"] JSXAttribute[name.name="__next40pxDefaultSize"]',
message:
'The `__next40pxDefaultSize` prop is no longer needed on `TextControl`.',
},
...[ 'BoxControl', 'TextControl' ].map( ( componentName ) => ( {
selector: `JSXElement[openingElement.name.name="${ componentName }"] JSXAttribute[name.name="__next40pxDefaultSize"]`,
message: `The \`__next40pxDefaultSize\` prop is no longer needed on \`${ componentName }\`.`,
} ) ),
{
selector:
'CallExpression[callee.name="withDispatch"] > :function > BlockStatement > :not(VariableDeclaration,ReturnStatement)',
Expand Down
Loading