// Import block dependencies and components import classnames from 'classnames'; import Inspector from './inspector'; const { __ } = wp.i18n; const { registerBlockType } = wp.blocks; const { compose } = wp.compose; const { Component, Fragment } = wp.element; const { RichText, withFontSizes, withColors, } = wp.editor; class Edit extends Component { constructor() { super( ...arguments ); } render() { // Setup the attributes const { attributes: { price, currency, term, showTerm, showCurrency, paddingTop, paddingRight, paddingBottom, paddingLeft, }, isSelected, className, setAttributes, fallbackFontSize, fontSize, backgroundColor, textColor, } = this.props; // Setup wrapper class names const editClassWrapperName = classnames( { 'ab-pricing-table-price-wrap': true, 'has-text-color': textColor.color, 'has-background': backgroundColor.color, [ backgroundColor.class ]: backgroundColor.class, [ textColor.class ]: textColor.class, 'ab-pricing-has-currency': showCurrency, } ); // Setup price class names const editClassName = classnames( { 'ab-pricing-table-price': true, [ fontSize.class ]: fontSize.class, } ); // Setup wrapper styles const editWrapStyles = { backgroundColor: backgroundColor.color, color: textColor.color, paddingTop: paddingTop ? paddingTop + 'px' : undefined, paddingRight: paddingRight ? paddingRight + 'px' : undefined, paddingBottom: paddingBottom ? paddingBottom + 'px' : undefined, paddingLeft: paddingLeft ? paddingLeft + 'px' : undefined, }; // Setup price styles const editStyles = { fontSize: fontSize.size ? fontSize.size + 'px' : undefined, }; // Setup currency styles var currencySize = Math.floor(fontSize.size / 2.5); const currencyStyles = { fontSize: fontSize.size ? currencySize + 'px' : undefined, }; // Setup term styles var termSize = Math.floor(fontSize.size / 2.5); const termStyles = { fontSize: fontSize.size ? termSize + 'px' : undefined, }; return [
{ showCurrency && ( setAttributes( { currency: value } ) } className="ab-pricing-table-currency" style={ currencyStyles } /> ) } setAttributes( { price: value } ) } style={ editStyles } className={ editClassName ? editClassName : undefined } /> { showTerm && ( setAttributes( { term: value } ) } className="ab-pricing-table-term" style={ termStyles } /> ) }
]; } } export default compose( [ withFontSizes( 'fontSize' ), withColors( 'backgroundColor', { textColor: 'color' } ), ] )( Edit );