/** * Newsletter block inspector. */ /** * WordPress dependencies. */ const { __ } = wp.i18n; const { Component } = wp.element; const { compose } = wp.compose; const { InspectorControls, withColors, ContrastChecker, PanelColorSettings, } = wp.editor; const { PanelBody, SelectControl, TextControl, withFallbackStyles, } = wp.components; /** * Internal dependencies. */ import Padding from './../../../utils/inspector/padding'; import Margin from './../../../utils/inspector/margin'; import ButtonSettings from './../../../utils/inspector/button'; /* Apply fallback styles. */ const applyFallbackStyles = withFallbackStyles( ( node, ownProps ) => { const { backgroundColor, textColor, buttonBackgroundColor, buttonTextColor } = ownProps.attributes; const editableNode = node.querySelector( '[contenteditable="true"]' ); const computedStyles = editableNode ? getComputedStyle( editableNode ) : null; return { fallbackBackgroundColor: backgroundColor || ! computedStyles ? undefined : computedStyles.backgroundColor, fallbackTextColor: textColor || ! computedStyles ? undefined : computedStyles.color, fallbackButtonBackgroundColor: buttonBackgroundColor || ! computedStyles ? undefined : computedStyles.buttonBackgroundColor, fallbackButtonTextColor: buttonTextColor || ! computedStyles ? undefined : computedStyles.buttonTextColor, }; } ); class Inspector extends Component { render() { const { attributes, setAttributes, backgroundColor, setBackgroundColor, fallbackBackgroundColor, textColor, fallbackTextColor, setTextColor, buttonBackgroundColor, fallbackButtonBackgroundColor, buttonTextColor, fallbackButtonTextColor, setButtonBackgroundColor, setButtonTextColor, } = this.props; let mailingListProviders = { 'mailchimp': { label: 'Mailchimp', value: 'mailchimp', lists: [ { label: __( 'Select a list', 'atomic-blocks' ), value: '', } ], }, }; atomic_blocks_newsletter_block_vars.mailingListProviders.mailchimp.lists.map( ( item ) => mailingListProviders.mailchimp.lists.push( { label: item.name, value: item.id } ) ); return ( setAttributes( { mailingList: value } ) } /> setAttributes( { successMessage: value } ) } /> setAttributes( { containerPadding } ) } /> setAttributes( { containerMarginTop } ) } // Enable margin bottom setting marginEnableBottom={ true } marginBottomLabel={ __( 'Block Margin Bottom', 'atomic-blocks' ) } marginBottom={ attributes.containerMarginBottom } marginBottomMin="0" marginBottomMax="200" onChangeMarginBottom={ containerMarginBottom => setAttributes( { containerMarginBottom } ) } /> setAttributes( { buttonSize } ) } buttonShape={ attributes.buttonShape } onChangeButtonShape={ buttonShape => setAttributes( { buttonShape } ) } enableButtonBackgroundColor={ false } enableButtonTextColor={ false } /> { /* Compare block background and block text color */ } { /* Compare button background and button text color */ } { /* Compare block background button background color */ } ) } } export default compose( [ applyFallbackStyles, withColors( 'backgroundColor', { textColor: 'color' }, { buttonBackgroundColor: 'background-color' }, { buttonTextColor: 'color' }, ), ] )( Inspector );