Skip to content

Commit

Permalink
AnglePickerControl: Deprecate margin bottom (#43867)
Browse files Browse the repository at this point in the history
* AnglePickerControl: Deprecate margin bottom

* Add changelog

* Fix typo
  • Loading branch information
mirka authored Sep 5, 2022
1 parent 97f102c commit f4a2ad1
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 4 deletions.
4 changes: 4 additions & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Breaking Changes

- `AnglePickerControl`: Deprecate bottom margin style. Add a `__nextHasNoMarginBottom` prop to start opting into the margin-free styles that will become the default in a future version, currently scheduled to be WordPress 6.4 ([#43867](https://github.com/WordPress/gutenberg/pull/43867)).

### Bug Fix

- `Button`, `Icon`: Fix `iconSize` prop doesn't work with some icons ([#43821](https://github.com/WordPress/gutenberg/pull/43821)).
Expand Down
10 changes: 9 additions & 1 deletion packages/components/src/angle-picker-control/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { AnglePickerControl } from '@wordpress/components';

const MyAnglePicker = () => {
const [ angle, setAngle ] = useState();
return <AnglePickerControl value={ angle } onChange={ setAngle } />;
return <AnglePickerControl value={ angle } onChange={ setAngle } __nextHasNoMarginBottom />;
};
```

Expand Down Expand Up @@ -39,3 +39,11 @@ A function that receives the new value of the input.

- Type: `function`
- Required: Yes

### __nextHasNoMarginBottom

Start opting into the new margin-free styles that will become the default in a future version, currently scheduled to be WordPress 6.4. (The prop can be safely removed once this happens.)

- Type: `boolean`
- Required: No
- Default: `false`
12 changes: 12 additions & 0 deletions packages/components/src/angle-picker-control/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import classnames from 'classnames';
/**
* WordPress dependencies
*/
import deprecated from '@wordpress/deprecated';
import { __ } from '@wordpress/i18n';

/**
Expand All @@ -27,6 +28,17 @@ export default function AnglePickerControl( {
onChange,
value,
} ) {
if ( ! __nextHasNoMarginBottom ) {
deprecated(
'Bottom margin styles for wp.components.AnglePickerControl',
{
since: '6.1',
version: '6.4',
hint: 'Set the `__nextHasNoMarginBottom` prop to true to start opting into the new styles, which will become the default in a future version.',
}
);
}

const handleOnNumberChange = ( unprocessedValue ) => {
const inputValue =
unprocessedValue !== '' ? parseInt( unprocessedValue, 10 ) : 0;
Expand Down
6 changes: 3 additions & 3 deletions packages/components/src/angle-picker-control/stories/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ import AnglePickerControl from '../';
export default {
title: 'Components/AnglePickerControl',
component: AnglePickerControl,
argTypes: {
__nextHasNoMarginBottom: { control: { type: 'boolean' } },
},
};

const AnglePickerWithState = ( args ) => {
Expand All @@ -24,3 +21,6 @@ const AnglePickerWithState = ( args ) => {
};

export const Default = AnglePickerWithState.bind( {} );
Default.args = {
__nextHasNoMarginBottom: true,
};

0 comments on commit f4a2ad1

Please sign in to comment.