diff --git a/blocks/conditional-panel-color/index.js b/blocks/conditional-panel-color/index.js new file mode 100644 index 00000000000000..a9828547387840 --- /dev/null +++ b/blocks/conditional-panel-color/index.js @@ -0,0 +1,24 @@ +/** + * External dependencies + */ +import { isEmpty } from 'lodash'; + +/** + * WordPress dependencies + */ +import { ifCondition, PanelColor, withContext } from '@wordpress/components'; +import { compose } from '@wordpress/element'; + +export default compose( + withContext( 'editor' )( + ( settings, props ) => ( { + colors: props.colors || settings.colors, + disableCustomColors: props.disableCustomColors !== undefined ? + props.disableCustomColors : + settings.disableCustomColors, + } ) + ), + ifCondition( + ( { colors, disableCustomColors } ) => ! ( isEmpty( colors ) && disableCustomColors ) + ) +)( PanelColor ); diff --git a/blocks/library/button/index.js b/blocks/library/button/index.js index fdcf21f6f38442..6abe851538b710 100644 --- a/blocks/library/button/index.js +++ b/blocks/library/button/index.js @@ -3,7 +3,7 @@ */ import { __ } from '@wordpress/i18n'; import { Component } from '@wordpress/element'; -import { Dashicon, IconButton, PanelColor, ToggleControl, withFallbackStyles } from '@wordpress/components'; +import { Dashicon, IconButton, ToggleControl, withFallbackStyles } from '@wordpress/components'; /** * Internal dependencies @@ -15,6 +15,7 @@ import UrlInput from '../../url-input'; import BlockControls from '../../block-controls'; import BlockAlignmentToolbar from '../../block-alignment-toolbar'; import ColorPalette from '../../color-palette'; +import ConditionalPanelColor from '../../conditional-panel-color'; import ContrastChecker from '../../contrast-checker'; import InspectorControls from '../../inspector-controls'; @@ -101,18 +102,18 @@ class ButtonBlock extends Component { checked={ !! clear } onChange={ this.toggleClear } /> - + setAttributes( { color: colorValue } ) } /> - - + + setAttributes( { textColor: colorValue } ) } /> - + { this.nodeRef && - + setAttributes( { backgroundColor: colorValue } ) } /> - - + + setAttributes( { textColor: colorValue } ) } /> - + { this.nodeRef &&