Add display component
[MAILPOET-2880]
This commit is contained in:
@@ -44,8 +44,10 @@ const BasicSettingsPanel = ({ onToggle, isOpened }) => {
|
||||
/>
|
||||
<ImageSettings
|
||||
name={MailPoet.I18n.t('formSettingsStylesBackgroundImage')}
|
||||
value={settings.backgroundImageUrl}
|
||||
onChange={partial(updateStyles, 'backgroundImageUrl')}
|
||||
imageUrl={settings.backgroundImageUrl}
|
||||
onImageUrlChange={partial(updateStyles, 'backgroundImageUrl')}
|
||||
imageDisplay={settings.backgroundImageDisplay}
|
||||
onImageDisplayChange={partial(updateStyles, 'backgroundImageDisplay')}
|
||||
/>
|
||||
<ColorSettings
|
||||
name={MailPoet.I18n.t('formSettingsStylesFontColor')}
|
||||
|
@@ -1,28 +1,33 @@
|
||||
import React from 'react';
|
||||
import { MediaUpload } from '@wordpress/block-editor';
|
||||
import MailPoet from 'mailpoet';
|
||||
import { Button } from '@wordpress/components';
|
||||
import { Button, SelectControl } from '@wordpress/components';
|
||||
import { customFieldTypes } from '../blocks/add_custom_field/add_custom_field_form';
|
||||
|
||||
type Props = {
|
||||
name: string,
|
||||
value?: string,
|
||||
onChange: (value: string) => any,
|
||||
imageUrl?: string,
|
||||
onImageUrlChange: (value: string) => any,
|
||||
imageDisplay?: string,
|
||||
onImageDisplayChange: (value: string) => any,
|
||||
}
|
||||
|
||||
const ImageSettings = ({
|
||||
name,
|
||||
value,
|
||||
onChange,
|
||||
imageUrl,
|
||||
onImageUrlChange,
|
||||
imageDisplay,
|
||||
onImageDisplayChange,
|
||||
}: 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)} />
|
||||
<input type="text" value={imageUrl ?? ''} onChange={(event) => onImageUrlChange(event.target.value)} />
|
||||
<MediaUpload
|
||||
value={value}
|
||||
onSelect={(image) => onChange(image.url)}
|
||||
value={imageUrl}
|
||||
onSelect={(image) => onImageUrlChange(image.url)}
|
||||
allowedTypes={['image']}
|
||||
render={({ open }) => (
|
||||
<Button
|
||||
@@ -35,6 +40,26 @@ const ImageSettings = ({
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
<div className="mailpoet-styles-settings-image-url-display">
|
||||
<SelectControl
|
||||
value={imageDisplay}
|
||||
options={[
|
||||
{
|
||||
label: MailPoet.I18n.t('imagePlacementScale'),
|
||||
value: 'scale',
|
||||
},
|
||||
{
|
||||
label: MailPoet.I18n.t('imagePlacementFit'),
|
||||
value: 'fit',
|
||||
},
|
||||
{
|
||||
label: MailPoet.I18n.t('imagePlacementTile'),
|
||||
value: 'tile',
|
||||
},
|
||||
]}
|
||||
onChange={onImageDisplayChange}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
|
Reference in New Issue
Block a user