/** * External dependencies */ import classnames from 'classnames'; /** * Internal dependencies */ import Inspector from './inspector'; import NewsletterContainer from './newsletter'; import CustomButton from './../../block-button/components/button'; /** * WordPress dependencies */ const { __ } = wp.i18n; const { compose, withInstanceId } = wp.compose; const { getColorClassName, RichText, withColors } = wp.editor; const { Fragment, Component } = wp.element; const { TextControl, withFallbackStyles } = wp.components; /* Apply fallback styles. */ const applyFallbackStyles = withFallbackStyles( ( node, ownProps ) => { const { backgroundColor, textColor, buttonBackgroundColor } = 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, }; } ); class Edit extends Component { constructor() { super( ...arguments ); this.props.setAttributes( { instanceId: this.props.instanceId } ); } render() { const { attributes, isSelected, setAttributes, buttonBackgroundColor, buttonTextColor, } = this.props; const apiKeyDefined = atomic_blocks_newsletter_block_vars.mailingListProviders.mailchimp.api_key_defined; /* Setup button background color class */ let buttonBackgroundColorClass; if (attributes.customButtonBackgroundColor) { buttonBackgroundColorClass = 'ab-has-custom-background-color'; } else { buttonBackgroundColorClass = attributes.buttonBackgroundColor ? 'has-' + attributes.buttonBackgroundColor + '-background-color' : null; } /* Setup button text color class */ let buttonTextColorClass; if (attributes.customButtonTextColor) { buttonTextColorClass = 'ab-has-custom-text-color'; } else { buttonTextColorClass = attributes.buttonTextColor ? 'has-' + attributes.buttonTextColor + '-color' : null; } return [ , { ! apiKeyDefined && (
{ __( 'You must define your newsletter provider API keys to use this block.', 'atomic-blocks' ) }

{ __( 'Configure your settings', 'atomic-blocks' ) }

) } { apiKeyDefined && ( this.props.setAttributes( { emailInputLabel: value } ) } />
this.props.setAttributes( { buttonText: value } ) } /> { isSelected && (
event.preventDefault() } style={ { textAlign: attributes.buttonAlignment, } } >
) }
) }
]; } } export default compose( [ applyFallbackStyles, withColors( 'backgroundColor', { textColor: 'color' }, { buttonBackgroundColor: 'background-color' }, { buttonTextColor: 'color' }, ), ] )( withInstanceId( Edit ) );