Add submit block definition

[MAILPOET-2451]
This commit is contained in:
Rostislav Wolny
2019-12-02 17:10:25 +01:00
committed by Jack Kitterhing
parent c1b17d756b
commit 1ec371e24d
3 changed files with 79 additions and 0 deletions

View 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;

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

View 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;
},
};