Map heading colours

[MAILPOET-2613]
This commit is contained in:
Pavel Dohnal
2020-03-11 13:34:12 +01:00
committed by Veljko V
parent 3c32811720
commit 52d94256da
3 changed files with 10 additions and 6 deletions

View File

@ -142,6 +142,11 @@ export const formBodyToBlocksFactory = (colorDefinitions, customFields = []) =>
if (item.params) { if (item.params) {
mapped.attributes.label = item.params.label ? item.params.label : ''; mapped.attributes.label = item.params.label ? item.params.label : '';
} }
if (item.params && has(item.params, 'text_color')) {
const textColorSlug = mapColorSlug(colorDefinitions, item.params.text_color);
mapped.attributes.textColor = textColorSlug;
mapped.attributes.customTextColor = !textColorSlug ? item.params.text_color : undefined;
}
switch (item.id) { switch (item.id) {
case 'email': case 'email':
return { return {
@ -152,10 +157,10 @@ export const formBodyToBlocksFactory = (colorDefinitions, customFields = []) =>
return { return {
...mapped, ...mapped,
attributes: { attributes: {
...mapped.attributes,
content: item.params?.content || '', content: item.params?.content || '',
level: item.params?.level || 2, level: item.params?.level || 2,
align: item.params?.align, align: item.params?.align,
textColor: item.params?.text_color,
anchor: item.params?.anchor, anchor: item.params?.anchor,
className: item.params?.class_name, className: item.params?.class_name,
}, },

View File

@ -242,7 +242,6 @@ describe('Blocks to Form Body', () => {
expect(input.params.content).to.be.equal(''); expect(input.params.content).to.be.equal('');
expect(input.params.level).to.be.equal(2); expect(input.params.level).to.be.equal(2);
expect(input.params.align).to.be.equal('left'); expect(input.params.align).to.be.equal('left');
expect(input.params.text_color).to.be.equal('#000');
expect(input.params.anchor).to.be.be.null; expect(input.params.anchor).to.be.be.null;
expect(input.params.class_name).to.be.null; expect(input.params.class_name).to.be.null;
}); });
@ -256,7 +255,7 @@ describe('Blocks to Form Body', () => {
content: 'Heading content', content: 'Heading content',
level: 3, level: 3,
align: 'center', align: 'center',
textColor: 'red', customTextColor: '#123',
anchor: 'anchor', anchor: 'anchor',
className: 'class', className: 'class',
}, },
@ -265,7 +264,7 @@ describe('Blocks to Form Body', () => {
expect(input.params.content).to.be.equal('Heading content'); expect(input.params.content).to.be.equal('Heading content');
expect(input.params.level).to.be.equal(3); expect(input.params.level).to.be.equal(3);
expect(input.params.align).to.be.equal('center'); expect(input.params.align).to.be.equal('center');
expect(input.params.text_color).to.be.equal('red'); expect(input.params.text_color).to.be.equal('#123');
expect(input.params.anchor).to.be.equal('anchor'); expect(input.params.anchor).to.be.equal('anchor');
expect(input.params.class_name).to.be.equal('class'); expect(input.params.class_name).to.be.equal('class');
}); });

View File

@ -407,7 +407,7 @@ describe('Form Body To Blocks', () => {
...headingInput, ...headingInput,
position: '1', position: '1',
params: { params: {
text_color: 'vivid-red', text_color: '#f78da7',
content: 'Content', content: 'Content',
level: 1, level: 1,
anchor: 'anchor', anchor: 'anchor',
@ -422,6 +422,6 @@ describe('Form Body To Blocks', () => {
expect(block.attributes.align).to.be.equal('right'); expect(block.attributes.align).to.be.equal('right');
expect(block.attributes.className).to.be.equal('class'); expect(block.attributes.className).to.be.equal('class');
expect(block.attributes.anchor).to.be.equal('anchor'); expect(block.attributes.anchor).to.be.equal('anchor');
expect(block.attributes.textColor).to.be.equal('vivid-red'); expect(block.attributes.customTextColor).to.be.equal('#f78da7');
}); });
}); });