Apply input styles styles for custom textareas in editor

[MAILPOET-2599]
This commit is contained in:
Rostislav Wolny
2020-03-05 11:06:42 +01:00
committed by Veljko V
parent ab3267bb6d
commit 52bddd763f

View File

@@ -107,15 +107,34 @@ const CustomTextAreaEdit = ({ attributes, setAttributes, clientId }) => {
</InspectorControls> </InspectorControls>
); );
const labelStyles = {
fontWeight: attributes.styles.bold ? 'bold' : 'inherit',
};
const inputStyles = {
borderRadius: attributes.styles.borderRadius ? `${attributes.styles.borderRadius}px` : 0,
borderWidth: attributes.styles.borderSize ? `${attributes.styles.borderSize}px` : '1px',
borderColor: attributes.styles.borderColor || 'initial',
};
if (attributes.styles.fullWidth) {
inputStyles.width = '100%';
}
if (attributes.styles.backgroundColor) {
inputStyles.backgroundColor = attributes.styles.backgroundColor;
}
const getTextArea = (placeholder) => ( const getTextArea = (placeholder) => (
<textarea <textarea
id="custom_text" id={clientId}
className="mailpoet_textarea" className="mailpoet_textarea"
name="custom_text" name="custom_text"
disabled disabled
data-automation-id="editor_custom_text_input" data-automation-id="editor_custom_textarea_input"
value={placeholder} value={placeholder}
rows={attributes.lines} rows={attributes.lines}
style={inputStyles}
/> />
); );
@@ -125,7 +144,7 @@ const CustomTextAreaEdit = ({ attributes, setAttributes, clientId }) => {
{attributes.labelWithinInput ? (getTextArea(formatLabel(attributes)) {attributes.labelWithinInput ? (getTextArea(formatLabel(attributes))
) : ( ) : (
<> <>
<label className="mailpoet_textarea_label" data-automation-id="editor_custom_text_label" htmlFor="custom_text"> <label className="mailpoet_textarea_label" data-automation-id="editor_custom_text_label" htmlFor={clientId} style={labelStyles}>
{formatLabel(attributes.label, attributes.mandatory)} {formatLabel(attributes.label, attributes.mandatory)}
</label> </label>
{getTextArea('')} {getTextArea('')}