Add submit block definition
[MAILPOET-2451]
This commit is contained in:
committed by
Jack Kitterhing
parent
c1b17d756b
commit
1ec371e24d
41
assets/js/src/form_editor/blocks/submit/edit.jsx
Normal file
41
assets/js/src/form_editor/blocks/submit/edit.jsx
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
import { InspectorControls } from '@wordpress/block-editor';
|
||||||
|
import { TextControl, Panel, PanelBody } from '@wordpress/components';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import MailPoet from 'mailpoet';
|
||||||
|
|
||||||
|
const SubmitEdit = ({ attributes, setAttributes }) => {
|
||||||
|
const inspectorControls = (
|
||||||
|
<InspectorControls>
|
||||||
|
<Panel>
|
||||||
|
<PanelBody title={MailPoet.I18n.t('formSettings')} initialOpen>
|
||||||
|
<TextControl
|
||||||
|
label={MailPoet.I18n.t('label')}
|
||||||
|
value={attributes.label}
|
||||||
|
onChange={(label) => (setAttributes({ label }))}
|
||||||
|
/>
|
||||||
|
</PanelBody>
|
||||||
|
</Panel>
|
||||||
|
|
||||||
|
</InspectorControls>
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{ inspectorControls }
|
||||||
|
<div className="mailpoet_submit">
|
||||||
|
<input className="button" type="submit" value={attributes.label} />
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
SubmitEdit.propTypes = {
|
||||||
|
attributes: PropTypes.shape({
|
||||||
|
label: PropTypes.string.isRequired,
|
||||||
|
}).isRequired,
|
||||||
|
setAttributes: PropTypes.func.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default SubmitEdit;
|
11
assets/js/src/form_editor/blocks/submit/icon.jsx
Normal file
11
assets/js/src/form_editor/blocks/submit/icon.jsx
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { G, Path, SVG } from '@wordpress/components';
|
||||||
|
|
||||||
|
export default (
|
||||||
|
<SVG viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<Path fill="none" d="M0 0h24v24H0V0z" />
|
||||||
|
<G>
|
||||||
|
<Path d="M19 6H5c-1.1 0-2 .9-2 2v8c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm0 10H5V8h14v8z" />
|
||||||
|
</G>
|
||||||
|
</SVG>
|
||||||
|
);
|
27
assets/js/src/form_editor/blocks/submit/submit.jsx
Normal file
27
assets/js/src/form_editor/blocks/submit/submit.jsx
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
import MailPoet from 'mailpoet';
|
||||||
|
import edit from './edit.jsx';
|
||||||
|
import icon from './icon.jsx';
|
||||||
|
|
||||||
|
export const name = 'mailpoet-form/submit-button';
|
||||||
|
|
||||||
|
export const settings = {
|
||||||
|
title: MailPoet.I18n.t('blockSubmit'),
|
||||||
|
description: MailPoet.I18n.t('blockSubmitDescription'),
|
||||||
|
icon,
|
||||||
|
attributes: {
|
||||||
|
label: {
|
||||||
|
type: 'string',
|
||||||
|
default: MailPoet.I18n.t('blockSubmitLabel'),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
category: 'obligatory',
|
||||||
|
supports: {
|
||||||
|
html: false,
|
||||||
|
customClassName: false,
|
||||||
|
inserter: false,
|
||||||
|
},
|
||||||
|
edit,
|
||||||
|
save() {
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
};
|
Reference in New Issue
Block a user