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

(Custom)GradientPicker: Remove and deprecate outer margins #43436

Merged
merged 3 commits into from
Aug 24, 2022
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 @@ -92,6 +92,7 @@ function ColorGradientControlInner( {
),
[ TAB_GRADIENT.value ]: (
<GradientPicker
__nextHasNoMargin
value={ gradientValue }
onChange={
canChooseAColor
Expand Down
12 changes: 12 additions & 0 deletions packages/components/src/custom-gradient-picker/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 Down Expand Up @@ -125,6 +126,17 @@ export default function CustomGradientPicker( {
position: parseInt( colorStop.length.value ),
} ) );

if ( ! __nextHasNoMargin ) {
deprecated(
'Outer margin styles for wp.components.CustomGradientPicker',
{
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',
}
);
}

return (
<VStack
spacing={ 5 }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ const CustomGradientPickerWithState = ( props ) => {
};

export const Default = CustomGradientPickerWithState.bind( {} );
Default.args = {
__nextHasNoMargin: true,
};
9 changes: 9 additions & 0 deletions packages/components/src/gradient-picker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const myGradientPicker = () => {

return (
<GradientPicker
__nextHasNoMargin
value={ gradient }
onChange={ ( currentGradient ) => setGradient( currentGradient ) }
gradients={ [
Expand Down Expand Up @@ -92,3 +93,11 @@ If true, the gradient picker will not be displayed and only defined gradients fr
- Type: `Boolean`
- Required: No
- Default: false

### __nextHasNoMargin

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`
9 changes: 9 additions & 0 deletions packages/components/src/gradient-picker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { map } from 'lodash';
*/
import { __, sprintf } from '@wordpress/i18n';
import { useCallback, useMemo } from '@wordpress/element';
import deprecated from '@wordpress/deprecated';

/**
* Internal dependencies
Expand Down Expand Up @@ -120,6 +121,14 @@ export default function GradientPicker( {
? MultipleOrigin
: SingleOrigin;

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',
} );
}

// Can be removed when deprecation period is over
const deprecatedMarginSpacerProps = ! __nextHasNoMargin
? { marginTop: 3 }
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/gradient-picker/stories/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ const Template = ( { onChange, ...props } ) => {

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

Expand Down
24 changes: 14 additions & 10 deletions packages/components/src/palette-edit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,16 +173,19 @@ function Option( {
/>
) }
{ isGradient && (
<CustomGradientPicker
__experimentalIsRenderedInSidebar
value={ value }
onChange={ ( newGradient ) =>
onChange( {
...element,
gradient: newGradient,
} )
}
/>
<div className="components-palette-edit__popover-gradient-picker">
<CustomGradientPicker
__nextHasNoMargin
__experimentalIsRenderedInSidebar
value={ value }
onChange={ ( newGradient ) =>
onChange( {
...element,
gradient: newGradient,
} )
}
/>
</div>
) }
</Popover>
) }
Expand Down Expand Up @@ -451,6 +454,7 @@ export default function PaletteEdit( {
{ ! isEditing &&
( isGradient ? (
<GradientPicker
__nextHasNoMargin
gradients={ gradients }
onChange={ () => {} }
clearable={ false }
Expand Down
14 changes: 3 additions & 11 deletions packages/components/src/palette-edit/style.scss
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
.components-palette-edit__popover {
.components-custom-gradient-picker__gradient-bar {
margin-top: 0;
}
.components-custom-gradient-picker__ui-line {
margin-bottom: 0;
}
.components-custom-gradient-picker {
width: 280px;
padding: 8px;
}
Comment on lines -1 to -11
Copy link
Contributor

Choose a reason for hiding this comment

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

🌟

.components-palette-edit__popover-gradient-picker {
width: 280px;
padding: 8px;
}
.components-dropdown-menu__menu {
.components-palette-edit__menu-button {
Expand Down