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

AnglePickerControl: Hard deprecate bottom margin #58700

Merged
merged 3 commits into from
Feb 6, 2024
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
3 changes: 3 additions & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Unreleased

### Breaking Changes

- `AnglePickerControl`: Remove deprecated `__nextHasNoMarginBottom` prop and promote to default behavior ([#58700](https://github.com/WordPress/gutenberg/pull/58700)).

### Enhancements

Expand Down
8 changes: 0 additions & 8 deletions packages/components/src/angle-picker-control/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ function Example() {
<AnglePickerControl
value={ angle }
onChange={ setAngle }
__nextHasNoMarginBottom
/>
);
};
Expand Down Expand Up @@ -43,10 +42,3 @@ The current value of the input. The value represents an angle in degrees and sho
A function that receives the new value of the input.

- Required: Yes

### `__nextHasNoMarginBottom`: `boolean`

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.)

- Required: No
- Default: `false`
27 changes: 4 additions & 23 deletions packages/components/src/angle-picker-control/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,17 @@ import classnames from 'classnames';
/**
* WordPress dependencies
*/
import deprecated from '@wordpress/deprecated';
import { forwardRef } from '@wordpress/element';
import { isRTL, __ } from '@wordpress/i18n';

/**
* Internal dependencies
*/
import { FlexBlock } from '../flex';
import { Flex, FlexBlock } from '../flex';
import { Spacer } from '../spacer';
import NumberControl from '../number-control';
import AngleCircle from './angle-circle';
import { Root, UnitText } from './styles/angle-picker-control-styles';
import { UnitText } from './styles/angle-picker-control-styles';

import type { WordPressComponentProps } from '../context';
import type { AnglePickerControlProps } from './types';
Expand All @@ -28,24 +27,13 @@ function UnforwardedAnglePickerControl(
ref: ForwardedRef< any >
) {
const {
__nextHasNoMarginBottom = false,
className,
label = __( 'Angle' ),
onChange,
value,
...restProps
} = props;

if ( ! __nextHasNoMarginBottom ) {
deprecated(
'Bottom margin styles for wp.components.AnglePickerControl',
{
since: '6.1',
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: string | undefined ) => {
if ( onChange === undefined ) {
return;
Expand All @@ -66,13 +54,7 @@ function UnforwardedAnglePickerControl(
: [ null, unitText ];

return (
<Root
{ ...restProps }
ref={ ref }
__nextHasNoMarginBottom={ __nextHasNoMarginBottom }
className={ classes }
gap={ 2 }
>
<Flex { ...restProps } ref={ ref } className={ classes } gap={ 2 }>
<FlexBlock>
<NumberControl
label={ label }
Expand All @@ -95,7 +77,7 @@ function UnforwardedAnglePickerControl(
onChange={ onChange }
/>
</Spacer>
</Root>
</Flex>
);
}

Expand All @@ -115,7 +97,6 @@ function UnforwardedAnglePickerControl(
* <AnglePickerControl
* value={ angle }
* onChange={ setAngle }
* __nextHasNoMarginBottom
* </>
* );
* }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,3 @@ const AnglePickerWithState: StoryFn< typeof AnglePickerControl > = ( {
};

export const Default = AnglePickerWithState.bind( {} );
Default.args = {
__nextHasNoMarginBottom: true,
};
Original file line number Diff line number Diff line change
@@ -1,37 +1,19 @@
/**
* External dependencies
*/
import { css } from '@emotion/react';
import styled from '@emotion/styled';

/**
* Internal dependencies
*/
import { Flex } from '../../flex';
import { COLORS } from '../../utils';
import { space } from '../../utils/space';
import { Text } from '../../text';
import CONFIG from '../../utils/config-values';

import type { AnglePickerControlProps } from '../types';

const CIRCLE_SIZE = 32;
const INNER_CIRCLE_SIZE = 6;

const deprecatedBottomMargin = ( {
__nextHasNoMarginBottom,
}: Pick< AnglePickerControlProps, '__nextHasNoMarginBottom' > ) => {
return ! __nextHasNoMarginBottom
? css`
margin-bottom: ${ space( 2 ) };
`
: '';
};

export const Root = styled( Flex )`
${ deprecatedBottomMargin }
`;

export const CircleRoot = styled.div`
border-radius: 50%;
border: ${ CONFIG.borderWidth } solid ${ COLORS.ui.border };
Expand Down
2 changes: 2 additions & 0 deletions packages/components/src/angle-picker-control/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ export type AnglePickerControlProps = {
* in a future version.
*
* @default false
* @deprecated Default behavior since WP 6.5. Prop can be safely removed.
* @ignore
*/
__nextHasNoMarginBottom?: boolean;
/**
Expand Down
1 change: 0 additions & 1 deletion packages/components/src/custom-gradient-picker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ const GradientAnglePicker = ( {
};
return (
<AnglePickerControl
__nextHasNoMarginBottom
onChange={ onAngleChange }
value={ hasGradient ? angle : '' }
/>
Expand Down
Loading