Set default style values

[MAILPOET-2886]
This commit is contained in:
Pavel Dohnal
2020-05-05 12:46:04 +02:00
committed by Veljko V
parent e086323451
commit b32504c9fc
2 changed files with 33 additions and 2 deletions

View File

@@ -28,6 +28,22 @@ const InputStylesSettings = ({
onChange(updated);
localStylesRef.current = updated;
};
const updateInheritFromTheme = (newValue) => {
if (newValue) {
updateStyles('inheritFromTheme', newValue);
return;
}
const updated = { ...localStylesRef.current };
updated.bold = false;
updated.borderRadius = 1;
updated.borderSize = 1;
updated.borderColor = 'black';
updated.inheritFromTheme = newValue;
onChange(updated);
localStylesRef.current = updated;
};
return (
<Panel className="mailpoet-automation-input-styles-panel">
<PanelBody title={MailPoet.I18n.t('formSettingsStyles')} initialOpen={false}>
@@ -40,7 +56,7 @@ const InputStylesSettings = ({
<ToggleControl
label={MailPoet.I18n.t('formSettingsInheritStyleFromTheme')}
checked={localStyles.inheritFromTheme}
onChange={partial(updateStyles, 'inheritFromTheme')}
onChange={updateInheritFromTheme}
className="mailpoet-automation-inherit-theme-toggle"
/>
{!localStyles.inheritFromTheme ? (

View File

@@ -42,6 +42,21 @@ const StylesSettings = ({
localStylesRef.current = updated;
};
const updateInheritFromTheme = (newValue: boolean) => {
if (newValue) {
updateStyles('inheritFromTheme', newValue);
return;
}
const updated = { ...localStylesRef.current };
updated.bold = false;
updated.borderRadius = 1;
updated.borderSize = 1;
updated.borderColor = 'black';
updated.inheritFromTheme = newValue;
onChange(updated);
localStylesRef.current = updated;
};
return (
<Panel className="mailpoet-automation-input-styles-panel">
<PanelBody title={MailPoet.I18n.t('formSettingsStyles')} initialOpen={false}>
@@ -54,7 +69,7 @@ const StylesSettings = ({
<ToggleControl
label={MailPoet.I18n.t('formSettingsInheritStyleFromTheme')}
checked={localStyles.inheritFromTheme}
onChange={partial(updateStyles, 'inheritFromTheme')}
onChange={updateInheritFromTheme}
className="mailpoet-automation-inherit-theme-toggle"
/>
{!localStyles.inheritFromTheme ? (