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

Deprecate PanelColor components #10391

Merged
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
2 changes: 2 additions & 0 deletions docs/reference/deprecated.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Gutenberg's deprecation policy is intended to support backwards-compatibility fo

- `isEditorSidebarPanelOpened` selector (`core/edit-post`) has been removed. Please use `isEditorPanelEnabled` instead.
- `toggleGeneralSidebarEditorPanel` action (`core/edit-post`) has been removed. Please use `toggleEditorPanelOpened` instead.
- `wp.components.PanelColor` component has been removed. Please use `wp.editor.PanelColorSettings` instead.
- `wp.editor.PanelColor` component has been removed. Please use `wp.editor.PanelColorSettings` instead.

## 4.2.0

Expand Down
6 changes: 6 additions & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 4.2.0 (Unreleased)

### Deprecation

- `wp.components.PanelColor` has been deprecated in favor of `wp.editor.PanelColorSettings`.
chrisvanpatten marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

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

In the context of packages, we should avoid references to WordPress-specific globals when possible (at least for changelog). Console messaging is trickier since we can't yet customize for the WordPress context, but it's a hope there we could.

See: #9753


## 4.1.0 (2018-10-10)

### New Feature
Expand Down
7 changes: 7 additions & 0 deletions packages/components/src/panel/color.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
* WordPress dependencies
*/
import deprecated from '@wordpress/deprecated';
import { __, sprintf } from '@wordpress/i18n';

/**
Expand All @@ -10,6 +11,12 @@ import PanelBody from './body';
import ColorIndicator from '../color-indicator';

function PanelColor( { colorValue, colorName, title, ...props } ) {
deprecated( 'wp.components.PanelColor', {
version: '4.3',
alternative: 'wp.editor.PanelColorSettings',
plugin: 'Gutenberg',
} );

// translators: %s: The name of the color e.g: "vivid red" or color hex code if name is not available e.g: "#f00".
const currentColorLabel = sprintf( __( '(current color: %s)' ), colorName || colorValue );
return (
Expand Down
4 changes: 4 additions & 0 deletions packages/components/src/panel/test/color.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,9 @@ describe( 'PanelColor', () => {
const wrapper = shallow( <PanelColor title="sample title" /> );

expect( wrapper ).toMatchSnapshot();

expect( console ).toHaveWarnedWith(
'wp.components.PanelColor is deprecated and will be removed from Gutenberg in 4.3. Please use wp.editor.PanelColorSettings instead.'
);
} );
} );
6 changes: 6 additions & 0 deletions packages/editor/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 4.1.0 (Unreleased)

### Deprecations

- `wp.editor.PanelColor` has been deprecated in favor of `wp.editor.PanelColorSettings`.

## 4.0.0 (2018-09-30)

### Breaking Changes
Expand Down
7 changes: 7 additions & 0 deletions packages/editor/src/components/panel-color/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { omit } from 'lodash';
*/
import { PanelColor as PanelColorComponent } from '@wordpress/components';
import { ifCondition, compose } from '@wordpress/compose';
import deprecated from '@wordpress/deprecated';

/**
* Internal dependencies
Expand All @@ -17,6 +18,12 @@ import withColorContext from '../color-palette/with-color-context';
import { getColorObjectByColorValue } from '../colors';

function PanelColor( { colors, title, colorValue, initialOpen, ...props } ) {
deprecated( 'wp.editor.PanelColor', {
chrisvanpatten marked this conversation as resolved.
Show resolved Hide resolved
version: '4.3',
alternative: 'wp.editor.PanelColorSettings',
chrisvanpatten marked this conversation as resolved.
Show resolved Hide resolved
plugin: 'Gutenberg',
} );

const colorObject = getColorObjectByColorValue( colors, colorValue );
const colorName = colorObject && colorObject.name;
return (
Expand Down