From 667c0c00fc0512be3cc551383a95daea1322887f Mon Sep 17 00:00:00 2001 From: Jorge Date: Mon, 3 May 2021 22:26:09 +0100 Subject: [PATCH] Update: stabilises GradientPicker and CustomGradientPicker components. Remove some experimental gradient abstractions form the block editor. --- .../components/colors-gradients/control.js | 2 +- .../src/components/gradient-picker/control.js | 49 ------------------- .../src/components/gradient-picker/index.js | 39 --------------- .../src/components/gradient-picker/panel.js | 28 ----------- packages/block-editor/src/components/index.js | 3 -- packages/components/src/index.js | 4 +- 6 files changed, 3 insertions(+), 122 deletions(-) delete mode 100644 packages/block-editor/src/components/gradient-picker/control.js delete mode 100644 packages/block-editor/src/components/gradient-picker/index.js delete mode 100644 packages/block-editor/src/components/gradient-picker/panel.js diff --git a/packages/block-editor/src/components/colors-gradients/control.js b/packages/block-editor/src/components/colors-gradients/control.js index 1fca410bc121f..b69ab19d1aedd 100644 --- a/packages/block-editor/src/components/colors-gradients/control.js +++ b/packages/block-editor/src/components/colors-gradients/control.js @@ -14,7 +14,7 @@ import { ButtonGroup, ColorIndicator, ColorPalette, - __experimentalGradientPicker as GradientPicker, + GradientPicker, } from '@wordpress/components'; import { sprintf, __ } from '@wordpress/i18n'; diff --git a/packages/block-editor/src/components/gradient-picker/control.js b/packages/block-editor/src/components/gradient-picker/control.js deleted file mode 100644 index dcbf3ec090a70..0000000000000 --- a/packages/block-editor/src/components/gradient-picker/control.js +++ /dev/null @@ -1,49 +0,0 @@ -/** - * External dependencies - */ -import classnames from 'classnames'; -import { isEmpty } from 'lodash'; - -/** - * WordPress dependencies - */ -import { BaseControl } from '@wordpress/components'; -import { __ } from '@wordpress/i18n'; - -/** - * Internal dependencies - */ -import GradientPicker from './'; -import useSetting from '../use-setting'; - -export default function GradientPickerControl( { - className, - value, - onChange, - label = __( 'Gradient Presets' ), - ...props -} ) { - const gradients = useSetting( 'color.gradients' ); - const disableCustomGradients = ! useSetting( 'color.customGradient' ); - if ( isEmpty( gradients ) && disableCustomGradients ) { - return null; - } - return ( - - { label } - - - ); -} diff --git a/packages/block-editor/src/components/gradient-picker/index.js b/packages/block-editor/src/components/gradient-picker/index.js deleted file mode 100644 index 6a18fb516b9a1..0000000000000 --- a/packages/block-editor/src/components/gradient-picker/index.js +++ /dev/null @@ -1,39 +0,0 @@ -/** - * WordPress dependencies - */ -import { __experimentalGradientPicker as GradientPicker } from '@wordpress/components'; - -/** - * Internal dependencies - */ -import useSetting from '../use-setting'; - -const EMPTY_ARRAY = []; - -function GradientPickerWithGradients( props ) { - const gradients = useSetting( 'color.gradients' ) || EMPTY_ARRAY; - const disableCustomGradients = ! useSetting( 'color.customGradient' ); - - return ( - - ); -} - -export default function ( props ) { - const ComponentToUse = - props.gradients !== undefined && - props.disableCustomGradients !== undefined - ? GradientPicker - : GradientPickerWithGradients; - return ; -} diff --git a/packages/block-editor/src/components/gradient-picker/panel.js b/packages/block-editor/src/components/gradient-picker/panel.js deleted file mode 100644 index 57e93273a5d2b..0000000000000 --- a/packages/block-editor/src/components/gradient-picker/panel.js +++ /dev/null @@ -1,28 +0,0 @@ -/** - * External dependencies - */ -import { isEmpty } from 'lodash'; - -/** - * WordPress dependencies - */ -import { PanelBody } from '@wordpress/components'; -import { __ } from '@wordpress/i18n'; - -/** - * Internal dependencies - */ -import GradientPicker from './control'; -import useSetting from '../use-setting'; - -export default function GradientPanel( props ) { - const gradients = useSetting( 'color.gradients' ); - if ( isEmpty( gradients ) ) { - return null; - } - return ( - - - - ); -} diff --git a/packages/block-editor/src/components/index.js b/packages/block-editor/src/components/index.js index 6daa8ddd4df35..76d13b6222158 100644 --- a/packages/block-editor/src/components/index.js +++ b/packages/block-editor/src/components/index.js @@ -45,9 +45,6 @@ export { default as ColorPalette } from './color-palette'; export { default as ColorPaletteControl } from './color-palette/control'; export { default as ContrastChecker } from './contrast-checker'; export { default as __experimentalDuotoneControl } from './duotone-control'; -export { default as __experimentalGradientPicker } from './gradient-picker'; -export { default as __experimentalGradientPickerControl } from './gradient-picker/control'; -export { default as __experimentalGradientPickerPanel } from './gradient-picker/panel'; export { default as __experimentalFontAppearanceControl } from './font-appearance-control'; export { default as __experimentalFontFamilyControl } from './font-family'; export { default as __experimentalLetterSpacingControl } from './letter-spacing-control'; diff --git a/packages/components/src/index.js b/packages/components/src/index.js index 5d41c2c7c66e9..a97f0743c58d2 100644 --- a/packages/components/src/index.js +++ b/packages/components/src/index.js @@ -69,8 +69,8 @@ export { default as FontSizePicker } from './font-size-picker'; export { default as FormFileUpload } from './form-file-upload'; export { default as FormToggle } from './form-toggle'; export { default as FormTokenField } from './form-token-field'; -export { default as __experimentalGradientPicker } from './gradient-picker'; -export { default as __experimentalCustomGradientPicker } from './custom-gradient-picker'; +export { default as GradientPicker } from './gradient-picker'; +export { default as CustomGradientPicker } from './custom-gradient-picker'; export { Grid as __experimentalGrid } from './grid'; export { default as Guide } from './guide'; export { default as GuidePage } from './guide/page';