Add component for image upload
[MAILPOET-2880]
This commit is contained in:
@@ -15,3 +15,24 @@
|
|||||||
vertical-align: text-bottom;
|
vertical-align: text-bottom;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.mailpoet-styles-settings-image-url {
|
||||||
|
overflow: auto;
|
||||||
|
|
||||||
|
.mailpoet-styles-settings-image-url-body {
|
||||||
|
align-items: center;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
|
||||||
|
input {
|
||||||
|
flex-grow: 1;
|
||||||
|
flex-shrink: 1;
|
||||||
|
margin-right: 4px;
|
||||||
|
min-width: 100px;
|
||||||
|
}
|
||||||
|
|
||||||
|
button {
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -101,7 +101,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.mailpoet-toggle-list {
|
.mailpoet-toggle-list {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-row-gap: 20px;
|
grid-row-gap: 20px;
|
||||||
|
@@ -13,6 +13,7 @@ import HorizontalAlignment from 'common/styles';
|
|||||||
|
|
||||||
import ColorSettings from 'form_editor/components/color_settings';
|
import ColorSettings from 'form_editor/components/color_settings';
|
||||||
import FontSizeSettings from 'form_editor/components/font_size_settings';
|
import FontSizeSettings from 'form_editor/components/font_size_settings';
|
||||||
|
import ImageSettings from 'form_editor/components/image_settings';
|
||||||
|
|
||||||
const BasicSettingsPanel = ({ onToggle, isOpened }) => {
|
const BasicSettingsPanel = ({ onToggle, isOpened }) => {
|
||||||
const { changeFormSettings } = useDispatch('mailpoet-form-editor');
|
const { changeFormSettings } = useDispatch('mailpoet-form-editor');
|
||||||
@@ -41,6 +42,11 @@ const BasicSettingsPanel = ({ onToggle, isOpened }) => {
|
|||||||
value={settings.backgroundColor}
|
value={settings.backgroundColor}
|
||||||
onChange={partial(updateStyles, 'backgroundColor')}
|
onChange={partial(updateStyles, 'backgroundColor')}
|
||||||
/>
|
/>
|
||||||
|
<ImageSettings
|
||||||
|
name={MailPoet.I18n.t('formSettingsStylesBackgroundImage')}
|
||||||
|
value={settings.backgroundImageUrl}
|
||||||
|
onChange={partial(updateStyles, 'backgroundImageUrl')}
|
||||||
|
/>
|
||||||
<ColorSettings
|
<ColorSettings
|
||||||
name={MailPoet.I18n.t('formSettingsStylesFontColor')}
|
name={MailPoet.I18n.t('formSettingsStylesFontColor')}
|
||||||
value={settings.fontColor}
|
value={settings.fontColor}
|
||||||
|
@@ -0,0 +1,41 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { MediaUpload } from '@wordpress/block-editor';
|
||||||
|
import MailPoet from 'mailpoet';
|
||||||
|
import { Button } from '@wordpress/components';
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
name: string,
|
||||||
|
value?: string,
|
||||||
|
onChange: (value: string) => any,
|
||||||
|
}
|
||||||
|
|
||||||
|
const ImageSettings = ({
|
||||||
|
name,
|
||||||
|
value,
|
||||||
|
onChange,
|
||||||
|
}: Props) => (
|
||||||
|
<div className="mailpoet-styles-settings-image-url">
|
||||||
|
<h3 className="mailpoet-styles-settings-heading">
|
||||||
|
{name}
|
||||||
|
</h3>
|
||||||
|
<div className="mailpoet-styles-settings-image-url-body">
|
||||||
|
<input type="text" value={value ?? ''} onChange={(event) => onChange(event.target.value)} />
|
||||||
|
<MediaUpload
|
||||||
|
value={value}
|
||||||
|
onSelect={(image) => onChange(image.url)}
|
||||||
|
allowedTypes={['image']}
|
||||||
|
render={({ open }) => (
|
||||||
|
<Button
|
||||||
|
isSecondary
|
||||||
|
isSmall
|
||||||
|
onClick={open}
|
||||||
|
>
|
||||||
|
{MailPoet.I18n.t('formSettingsStylesSelectImage')}
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
export default ImageSettings;
|
||||||
|
@@ -44,6 +44,8 @@
|
|||||||
'formSettings': _x('Settings', 'A settings section heading'),
|
'formSettings': _x('Settings', 'A settings section heading'),
|
||||||
'formSettingsStyles': __('Styles'),
|
'formSettingsStyles': __('Styles'),
|
||||||
'formSettingsStylesBackgroundColor': __('Background Color'),
|
'formSettingsStylesBackgroundColor': __('Background Color'),
|
||||||
|
'formSettingsStylesBackgroundImage': __('Background Image'),
|
||||||
|
'formSettingsStylesSelectImage': __('Select Image…'),
|
||||||
'formSettingsStylesFontSize': __('Font Size'),
|
'formSettingsStylesFontSize': __('Font Size'),
|
||||||
'formSettingsStylesFontColor': __('Font Color'),
|
'formSettingsStylesFontColor': __('Font Color'),
|
||||||
'formSettingsStylesFontColorInherit': __('Inherit from theme'),
|
'formSettingsStylesFontColorInherit': __('Inherit from theme'),
|
||||||
|
Reference in New Issue
Block a user