Skip to content

Commit

Permalink
GradientPicker: Hard deprecate outer margins (WordPress#58701)
Browse files Browse the repository at this point in the history
* GradientPicker: Hard deprecate outer margins

* Remove usage in PaletteEdit

* Update changelog

Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>
  • Loading branch information
3 people authored Feb 6, 2024
1 parent 04b5a80 commit 3fb2976
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 70 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ function ColorGradientControlInner( {
),
[ TAB_IDS.gradient ]: (
<GradientPicker
__nextHasNoMargin
value={ gradientValue }
onChange={
canChooseAColor
Expand Down
6 changes: 2 additions & 4 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Breaking Changes

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

Expand All @@ -13,6 +14,7 @@
- `ConfirmDialog`: Add `__next40pxDefaultSize` to buttons ([#58421](https://github.com/WordPress/gutenberg/pull/58421)).
- `Snackbar`: Update the warning message ([#58591](https://github.com/WordPress/gutenberg/pull/58591)).
- `Composite`: Implementing `useCompositeState` with Ariakit ([#57304](https://github.com/WordPress/gutenberg/pull/57304))
- `CheckboxControl`: Remove ability for label prop to be false ([#58339](https://github.com/WordPress/gutenberg/pull/58339)).

### Bug Fix

Expand All @@ -31,10 +33,6 @@
- Expand theming support in the `COLORS` variable object ([#58097](https://github.com/WordPress/gutenberg/pull/58097)).
- `CustomSelect`: disable `virtualFocus` to fix issue for screenreaders ([#58585](https://github.com/WordPress/gutenberg/pull/58585)).

### Enhancements

- `CheckboxControl`: Remove ability for label prop to be false ([#58339](https://github.com/WordPress/gutenberg/pull/58339)).

### Internal

- `Composite`: Removing Reakit `Composite` implementation ([#58620](https://github.com/WordPress/gutenberg/pull/58620)).
Expand Down
8 changes: 0 additions & 8 deletions packages/components/src/gradient-picker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const myGradientPicker = () => {

return (
<GradientPicker
__nextHasNoMargin
value={ gradient }
onChange={ ( currentGradient ) => setGradient( currentGradient ) }
gradients={ [
Expand Down Expand Up @@ -89,13 +88,6 @@ If true, the gradient picker will not be displayed and only defined gradients fr
- Required: No
- Default: false

### `__nextHasNoMargin`: `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`

### `headingLevel`: `1 | 2 | 3 | 4 | 5 | 6 | '1' | '2' | '3' | '4' | '5' | '6'`

The heading level. Only applies in cases where gradients are provided from multiple origins (ie. when the array passed as the `gradients` prop contains two or more items).
Expand Down
87 changes: 32 additions & 55 deletions packages/components/src/gradient-picker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import { __, sprintf } from '@wordpress/i18n';
import { useInstanceId } from '@wordpress/compose';
import { useCallback, useMemo } from '@wordpress/element';
import deprecated from '@wordpress/deprecated';

/**
* Internal dependencies
Expand All @@ -13,7 +12,6 @@ import CircularOptionPicker from '../circular-option-picker';
import CustomGradientPicker from '../custom-gradient-picker';
import { VStack } from '../v-stack';
import { ColorHeading } from '../color-palette/styles';
import { Spacer } from '../spacer';
import type {
GradientPickerComponentProps,
PickerProps,
Expand Down Expand Up @@ -181,7 +179,6 @@ function Component( props: PickerProps< any > ) {
*
* return (
* <GradientPicker
* __nextHasNoMargin
* value={ gradient }
* onChange={ ( currentGradient ) => setGradient( currentGradient ) }
* gradients={ [
Expand Down Expand Up @@ -211,8 +208,6 @@ function Component( props: PickerProps< any > ) {
*
*/
export function GradientPicker( {
/** Start opting into the new margin-free styles that will become the default in a future version. */
__nextHasNoMargin = false,
className,
gradients = [],
onChange,
Expand All @@ -228,57 +223,39 @@ export function GradientPicker( {
[ onChange ]
);

if ( ! __nextHasNoMargin ) {
deprecated( 'Outer margin styles for wp.components.GradientPicker', {
since: '6.1',
version: '6.4',
hint: 'Set the `__nextHasNoMargin` prop to true to start opting into the new styles, which will become the default in a future version',
} );
}

const deprecatedMarginSpacerProps = ! __nextHasNoMargin
? {
marginTop: ! gradients.length ? 3 : undefined,
marginBottom: ! clearable ? 6 : 0,
}
: {};

return (
// Outmost Spacer wrapper can be removed when deprecation period is over
<Spacer marginBottom={ 0 } { ...deprecatedMarginSpacerProps }>
<VStack spacing={ gradients.length ? 4 : 0 }>
{ ! disableCustomGradients && (
<CustomGradientPicker
__experimentalIsRenderedInSidebar={
__experimentalIsRenderedInSidebar
}
value={ value }
onChange={ onChange }
/>
) }
{ ( gradients.length > 0 || clearable ) && (
<Component
{ ...additionalProps }
className={ className }
clearGradient={ clearGradient }
gradients={ gradients }
onChange={ onChange }
value={ value }
actions={
clearable &&
! disableCustomGradients && (
<CircularOptionPicker.ButtonAction
onClick={ clearGradient }
>
{ __( 'Clear' ) }
</CircularOptionPicker.ButtonAction>
)
}
headingLevel={ headingLevel }
/>
) }
</VStack>
</Spacer>
<VStack spacing={ gradients.length ? 4 : 0 }>
{ ! disableCustomGradients && (
<CustomGradientPicker
__experimentalIsRenderedInSidebar={
__experimentalIsRenderedInSidebar
}
value={ value }
onChange={ onChange }
/>
) }
{ ( gradients.length > 0 || clearable ) && (
<Component
{ ...additionalProps }
className={ className }
clearGradient={ clearGradient }
gradients={ gradients }
onChange={ onChange }
value={ value }
actions={
clearable &&
! disableCustomGradients && (
<CircularOptionPicker.ButtonAction
onClick={ clearGradient }
>
{ __( 'Clear' ) }
</CircularOptionPicker.ButtonAction>
)
}
headingLevel={ headingLevel }
/>
) }
</VStack>
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ const Template: StoryFn< typeof GradientPicker > = ( {

export const Default = Template.bind( {} );
Default.args = {
__nextHasNoMargin: true,
gradients: GRADIENTS,
};

Expand Down
2 changes: 2 additions & 0 deletions packages/components/src/gradient-picker/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ export type GradientPickerComponentProps = GradientPickerBaseProps & {
* can be safely removed once this happens.)
*
* @default false
* @deprecated Default behavior since WP 6.5. Prop can be safely removed.
* @ignore
*/
__nextHasNoMargin?: boolean;
/**
Expand Down
1 change: 0 additions & 1 deletion packages/components/src/palette-edit/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,6 @@ export function PaletteEdit( {
{ ! isEditing &&
( isGradient ? (
<GradientPicker
__nextHasNoMargin
gradients={ gradients }
onChange={ onSelectPaletteItem }
clearable={ false }
Expand Down

0 comments on commit 3fb2976

Please sign in to comment.