Skip to content

Commit

Permalink
Deprecate PanelColor components (#10391)
Browse files Browse the repository at this point in the history
* Deprecate PanelColor components

* Update deprecation version numbers

* Fix a test broken during the rebase
  • Loading branch information
chrisvanpatten authored Oct 18, 2018
1 parent c86502b commit f9efc9f
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 0 deletions.
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`.

## 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', {
version: '4.3',
alternative: 'wp.editor.PanelColorSettings',
plugin: 'Gutenberg',
} );

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

0 comments on commit f9efc9f

Please sign in to comment.