Render paragraph and heading typography styles on front end

[MAILPOET-3007]
This commit is contained in:
Rostislav Wolny
2020-06-29 16:17:00 +02:00
committed by Veljko V
parent 6d59143453
commit 2c33cbfa24
4 changed files with 39 additions and 0 deletions

View File

@ -80,6 +80,12 @@ class Heading {
if (isset($block['params']['text_color'])) {
$styles[] = 'color: ' . $block['params']['text_color'];
}
if (!empty($block['params']['font_size'])) {
$styles[] = 'font-size: ' . $block['params']['font_size'] . 'px';
}
if (!empty($block['params']['line_height'])) {
$styles[] = 'line-height: ' . $block['params']['line_height'];
}
if (!empty($block['params']['background_color'])) {
$styles[] = 'background-color: ' . $block['params']['background_color'];
}

View File

@ -66,6 +66,9 @@ class Paragraph {
if (!empty($block['params']['font_size'])) {
$styles[] = 'font-size: ' . $block['params']['font_size'] . 'px';
}
if (!empty($block['params']['line_height'])) {
$styles[] = 'line-height: ' . $block['params']['line_height'];
}
if (empty($styles)) {
return null;
}

View File

@ -91,4 +91,24 @@ class HeadingTest extends \MailPoetUnitTest {
expect($html)->contains('style="background-color: red');
expect($html)->contains('class="mailpoet-has-background-color"');
}
public function testItShouldRenderFontSize() {
$html = $this->heading->render([
'params' => [
'content' => 'Header',
'font_size' => '33',
],
]);
expect($html)->equals('<h2 style="font-size: 33px">Header</h2>');
}
public function testItShouldRenderLineHeight() {
$html = $this->heading->render([
'params' => [
'content' => 'Header',
'line_height' => '2.3',
],
]);
expect($html)->equals('<h2 style="line-height: 2.3">Header</h2>');
}
}

View File

@ -77,6 +77,16 @@ class ParagraphTest extends \MailPoetUnitTest {
expect($html)->equals('<p class="mailpoet_form_paragraph" style="font-size: 33px">Paragraph</p>');
}
public function testItShouldRenderLineHeight() {
$html = $this->paragraph->render([
'params' => [
'content' => 'Paragraph',
'line_height' => '2.3',
],
]);
expect($html)->equals('<p class="mailpoet_form_paragraph" style="line-height: 2.3">Paragraph</p>');
}
public function testItShouldRenderDropCap() {
$html = $this->paragraph->render([
'params' => [