/**
* BLOCK: number-box
*
* Registering a basic block with Gutenberg.
* Simple block, renders and saves the same content without any interactivity.
*/
//Import Icon
import icon from './icons/icon';
// Import CSS.
import './style.scss';
import './editor.scss';
import { version_1_1_2 } from './oldVersions';
const { __ } = wp.i18n;
const { registerBlockType } = wp.blocks;
const {
InspectorControls,
AlignmentToolbar,
PanelColorSettings,
BlockControls,
RichText
} = wp.editor;
const { PanelBody, Toolbar, RangeControl, SelectControl } = wp.components;
const { withState } = wp.compose;
const attributes = {
column: {
type: 'select',
default: '2'
},
columnOneNumber: {
type: 'array',
source: 'children',
selector: '.ub_number_one_number'
},
columnTwoNumber: {
type: 'array',
source: 'children',
selector: '.ub_number_two_number'
},
columnThreeNumber: {
type: 'array',
source: 'children',
selector: '.ub_number_three_number'
},
columnOneTitle: {
type: 'array',
source: 'children',
selector: '.ub_number_one_title'
},
columnTwoTitle: {
type: 'array',
source: 'children',
selector: '.ub_number_two_title'
},
columnThreeTitle: {
type: 'array',
source: 'children',
selector: '.ub_number_three_title'
},
columnOneBody: {
type: 'array',
source: 'children',
selector: '.ub_number_one_body'
},
columnTwoBody: {
type: 'array',
source: 'children',
selector: '.ub_number_two_body'
},
columnThreeBody: {
type: 'array',
source: 'children',
selector: '.ub_number_three_body'
},
numberBackground: {
type: 'string',
default: '#CCCCCC'
},
numberColor: {
type: 'string',
default: '#000000'
},
borderColor: {
type: 'string',
default: '#CCCCCC'
}
};
/**
* Register: aa Gutenberg Block.
*
* Registers a new block provided a unique name and an object defining its
* behavior. Once registered, the block is made editor as an option to any
* editor interface where blocks are implemented.
*
* @link https://wordpress.org/gutenberg/handbook/block-api/
* @param {string} name Block name.
* @param {Object} settings Block settings.
* @return {?WPBlock} The block, if it has been successfully
* registered; otherwise `undefined`.
*/
registerBlockType('advanced-blocks/number-box', {
title: __('Number Box'),
icon: 'sos',
category: 'advanced-blocks',
keywords: [__('Number box'), __('Feature'), __('Ultimate Blocks')],
attributes,
/**
* The edit function describes the structure of your block in the context of the editor.
* This represents what the editor will render when the block is used.
*
* The "edit" property must be a valid function.
*
* @link https://wordpress.org/gutenberg/handbook/block-api/block-edit-save/
*/
edit: withState({ editable: 'content' })(function(props) {
const { isSelected, editable, setState } = props;
const {
column,
columnOneNumber,
columnTwoNumber,
columnThreeNumber,
columnOneTitle,
columnTwoTitle,
columnThreeTitle,
columnOneBody,
columnTwoBody,
columnThreeBody,
numberBackground,
numberColor,
borderColor
} = props.attributes;
const columns = [
{ value: '1', label: __('One Column') },
{ value: '2', label: __('Two Column') },
{ value: '3', label: __('Three Column') }
];
const onSetActiveEditable = newEditable => () => {
setState({ editable: newEditable });
};
return [
isSelected &&
{columnOneNumber}
{columnOneTitle}
{columnOneBody}
{columnTwoNumber}
{columnTwoTitle}
{columnTwoBody}
{columnThreeNumber}
{columnThreeTitle}
{columnThreeBody}