Skip to content

Commit

Permalink
LineHeightControl: Deprecate 36px default size
Browse files Browse the repository at this point in the history
  • Loading branch information
mirka committed Dec 11, 2024
1 parent 8a10c75 commit 5db3d50
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const MyLineHeightControl = () => (
<LineHeightControl
value={ lineHeight }
onChange={ onChange }
__next40pxDefaultSize
/>
);
```
Expand Down
12 changes: 12 additions & 0 deletions packages/block-editor/src/components/line-height-control/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/
import { __ } from '@wordpress/i18n';
import { __experimentalNumberControl as NumberControl } from '@wordpress/components';
import deprecated from '@wordpress/deprecated';

/**
* Internal dependencies
Expand Down Expand Up @@ -89,6 +90,17 @@ const LineHeightControl = ( {
onChange( `${ nextValue }` );
};

if (
! __next40pxDefaultSize &&
( otherProps.size === undefined || otherProps.size === 'default' )
) {
deprecated( `36px default size for wp.blockEditor.LineHeightControl`, {
since: '6.8',
version: '7.1',
hint: 'Set the `__next40pxDefaultSize` prop to true to start opting into the new default size, which will become the default in a future version.',
} );
}

return (
<div className="block-editor-line-height-control">
<NumberControl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const Template = ( props ) => {

export const Default = Template.bind( {} );
Default.args = {
__next40pxDefaultSize: true,
__unstableInputWidth: '100px',
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ const SPIN = STEP * SPIN_FACTOR;

const ControlledLineHeightControl = () => {
const [ value, setValue ] = useState();
return <LineHeightControl value={ value } onChange={ setValue } />;
return (
<LineHeightControl
value={ value }
onChange={ setValue }
__next40pxDefaultSize
/>
);
};

describe( 'LineHeightControl', () => {
Expand Down

0 comments on commit 5db3d50

Please sign in to comment.