diff --git a/packages/block-editor/src/components/colors-gradients/control.js b/packages/block-editor/src/components/colors-gradients/control.js index 51912e0a74e9d..0cb2fcdda4487 100644 --- a/packages/block-editor/src/components/colors-gradients/control.js +++ b/packages/block-editor/src/components/colors-gradients/control.js @@ -10,15 +10,16 @@ import { __ } from '@wordpress/i18n'; import { BaseControl, __experimentalVStack as VStack, - TabPanel, ColorPalette, GradientPicker, + privateApis as componentsPrivateApis, } from '@wordpress/components'; /** * Internal dependencies */ import { useSettings } from '../use-settings'; +import { unlock } from '../../lock-unlock'; const colorsAndGradientKeys = [ 'colors', @@ -27,18 +28,7 @@ const colorsAndGradientKeys = [ 'disableCustomGradients', ]; -const TAB_COLOR = { - name: 'color', - title: __( 'Solid' ), - value: 'color', -}; -const TAB_GRADIENT = { - name: 'gradient', - title: __( 'Gradient' ), - value: 'gradient', -}; - -const TABS_SETTINGS = [ TAB_COLOR, TAB_GRADIENT ]; +const TAB_IDS = { color: 'color', gradient: 'gradient' }; function ColorGradientControlInner( { colors, @@ -69,7 +59,7 @@ function ColorGradientControlInner( { } const tabPanels = { - [ TAB_COLOR.value ]: ( + [ TAB_IDS.color ]: ( ), - [ TAB_GRADIENT.value ]: ( + [ TAB_IDS.gradient ]: ( ); + // Unlocking `Tabs` too early causes the `unlock` method to receive an empty + // object, due to circular dependencies. + // See https://github.com/WordPress/gutenberg/issues/52692 + const { Tabs } = unlock( componentsPrivateApis ); + return ( ) } { canChooseAColor && canChooseAGradient && ( - - { ( tab ) => renderPanelType( tab.value ) } - +
+ + + + { __( 'Solid' ) } + + + { __( 'Gradient' ) } + + + + { tabPanels.color } + + + { tabPanels.gradient } + + +
) } - { ! canChooseAGradient && - renderPanelType( TAB_COLOR.value ) } - { ! canChooseAColor && - renderPanelType( TAB_GRADIENT.value ) } + + { ! canChooseAGradient && renderPanelType( TAB_IDS.color ) } + { ! canChooseAColor && renderPanelType( TAB_IDS.gradient ) }
diff --git a/packages/block-editor/src/components/colors-gradients/style.scss b/packages/block-editor/src/components/colors-gradients/style.scss index 6cade124b7fe4..fcae4a99189ee 100644 --- a/packages/block-editor/src/components/colors-gradients/style.scss +++ b/packages/block-editor/src/components/colors-gradients/style.scss @@ -15,12 +15,6 @@ $swatch-gap: 12px; min-width: 0; } -.block-editor-color-gradient-control__tabs { - .block-editor-color-gradient-control__panel { - padding: $grid-unit-20; - } -} - .block-editor-panel-color-gradient-settings.block-editor-panel-color-gradient-settings { &, & > div:not(:first-of-type) {