Files
leon_pharmacy/blocks/contact-block/contact-block.js
Prospect Ogujiuba 7464e10f35 first commit
2024-07-02 11:00:03 -04:00

66 lines
2.4 KiB
JavaScript

( 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
);