first commit
This commit is contained in:
65
blocks/contact-block/contact-block.js
Normal file
65
blocks/contact-block/contact-block.js
Normal file
@@ -0,0 +1,65 @@
|
||||
|
||||
( function ( blocks, element, blockEditor ) {
|
||||
const el = element.createElement,
|
||||
registerBlockType = blocks.registerBlockType,
|
||||
ServerSideRender = PgServerSideRender2,
|
||||
InspectorControls = blockEditor.InspectorControls,
|
||||
useBlockProps = blockEditor.useBlockProps;
|
||||
|
||||
const {__} = wp.i18n;
|
||||
const {ColorPicker, TextControl, ToggleControl, SelectControl, Panel, PanelBody, Disabled, TextareaControl, BaseControl} = wp.components;
|
||||
const {useSelect} = wp.data;
|
||||
const {RawHTML, Fragment} = element;
|
||||
|
||||
const {InnerBlocks, URLInputButton, RichText} = wp.blockEditor;
|
||||
const useInnerBlocksProps = blockEditor.useInnerBlocksProps || blockEditor.__experimentalUseInnerBlocksProps;
|
||||
|
||||
const propOrDefault = function(val, prop, field) {
|
||||
if(block.attributes[prop] && (val === null || val === '')) {
|
||||
return field ? block.attributes[prop].default[field] : block.attributes[prop].default;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
const block = registerBlockType( 'leonpharmacy/contact-block', {
|
||||
apiVersion: 2,
|
||||
title: 'Contact Page',
|
||||
description: '',
|
||||
icon: 'block-default',
|
||||
category: 'Leon Pharmacy Blocks',
|
||||
keywords: [],
|
||||
supports: {color: {background: false,text: false,gradients: false,link: false,},typography: {fontSize: false,},anchor: false,align: false,},
|
||||
attributes: {
|
||||
},
|
||||
example: { attributes: { } },
|
||||
edit: function ( props ) {
|
||||
const blockProps = useBlockProps({ className: 'bg-blue-500' });
|
||||
const setAttributes = props.setAttributes;
|
||||
|
||||
|
||||
const innerBlocksProps = null;
|
||||
|
||||
|
||||
return el(Fragment, {}, [
|
||||
|
||||
el( ServerSideRender, {
|
||||
block: 'leonpharmacy/contact-block',
|
||||
httpMethod: 'POST',
|
||||
attributes: props.attributes,
|
||||
innerBlocksProps: innerBlocksProps,
|
||||
blockProps: blockProps
|
||||
} ),
|
||||
|
||||
]);
|
||||
},
|
||||
|
||||
save: function(props) {
|
||||
return null;
|
||||
}
|
||||
|
||||
} );
|
||||
} )(
|
||||
window.wp.blocks,
|
||||
window.wp.element,
|
||||
window.wp.blockEditor
|
||||
);
|
Reference in New Issue
Block a user