/** * Inspector Controls */ // Setup the block const { __ } = wp.i18n; const { Component } = wp.element; // Import block components const { InspectorControls, BlockDescription, ColorPalette, PanelColorSettings, MediaUpload, } = wp.editor; // Import Inspector components const { Toolbar, Button, PanelBody, PanelRow, FormToggle, RangeControl, SelectControl, ToggleControl, IconButton, } = wp.components; /** * Create an Inspector Controls wrapper Component */ export default class Inspector extends Component { constructor( props ) { super( ...arguments ); } render() { // Setup the attributes const { buttonText, buttonUrl, buttonAlignment, buttonBackgroundColor, buttonTextColor, buttonSize, buttonShape, buttonTarget, ctaTitle, ctaText, titleFontSize, ctaTextFontSize, ctaBackgroundColor, ctaTextColor, dimRatio, imgURL, imgID, imgAlt, } = this.props.attributes; const { setAttributes } = this.props; // Button size values const buttonSizeOptions = [ { value: 'ab-button-size-small', label: __( 'Small' ) }, { value: 'ab-button-size-medium', label: __( 'Medium' ) }, { value: 'ab-button-size-large', label: __( 'Large' ) }, { value: 'ab-button-size-extralarge', label: __( 'Extra Large' ) }, ]; // Button shape const buttonShapeOptions = [ { value: 'ab-button-shape-square', label: __( 'Square' ) }, { value: 'ab-button-shape-rounded', label: __( 'Rounded Square' ) }, { value: 'ab-button-shape-circular', label: __( 'Circular' ) }, ]; // Change the image const onSelectImage = img => { setAttributes( { imgID: img.id, imgURL: img.url, imgAlt: img.alt, } ); }; // Clear the image const onRemoveImage = () => { setAttributes({ imgID: null, imgURL: null, imgAlt: null, }); } // Update color values const onChangeBackgroundColor = value => setAttributes( { ctaBackgroundColor: value } ); const onChangeTextColor = value => setAttributes( { ctaTextColor: value } ); const onChangeButtonColor = value => setAttributes( { buttonBackgroundColor: value } ); const onChangeButtonTextColor = value => setAttributes( { buttonTextColor: value } ); return ( this.props.setAttributes( { titleFontSize: value } ) } min={ 24 } max={ 60 } step={ 2 } /> this.props.setAttributes( { ctaTextFontSize: value } ) } min={ 14 } max={ 24 } step={ 2 } />

{ __( 'Select a background image:', 'atomic-blocks' ) }

(
{ __( 'Select Image', 'atomic-blocks' ) } { imgURL && !! imgURL.length && ( { __( 'Remove', 'atomic-blocks' ) } ) }
) } >
{ imgURL && !! imgURL.length && ( this.props.setAttributes( { dimRatio: value } ) } min={ 0 } max={ 100 } step={ 10 } /> ) }
this.props.setAttributes( { buttonTarget: ! buttonTarget } ) } /> ( { value: value, label: label, } ) ) } onChange={ ( value ) => { this.props.setAttributes( { buttonSize: value } ) } } /> ( { value: value, label: label, } ) ) } onChange={ ( value ) => { this.props.setAttributes( { buttonShape: value } ) } } />
); } }