Render paragraph and heading typography styles on front end
[MAILPOET-3007]
This commit is contained in:
committed by
Veljko V
parent
6d59143453
commit
2c33cbfa24
@ -80,6 +80,12 @@ class Heading {
|
|||||||
if (isset($block['params']['text_color'])) {
|
if (isset($block['params']['text_color'])) {
|
||||||
$styles[] = 'color: ' . $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'])) {
|
if (!empty($block['params']['background_color'])) {
|
||||||
$styles[] = 'background-color: ' . $block['params']['background_color'];
|
$styles[] = 'background-color: ' . $block['params']['background_color'];
|
||||||
}
|
}
|
||||||
|
@ -66,6 +66,9 @@ class Paragraph {
|
|||||||
if (!empty($block['params']['font_size'])) {
|
if (!empty($block['params']['font_size'])) {
|
||||||
$styles[] = 'font-size: ' . $block['params']['font_size'] . 'px';
|
$styles[] = 'font-size: ' . $block['params']['font_size'] . 'px';
|
||||||
}
|
}
|
||||||
|
if (!empty($block['params']['line_height'])) {
|
||||||
|
$styles[] = 'line-height: ' . $block['params']['line_height'];
|
||||||
|
}
|
||||||
if (empty($styles)) {
|
if (empty($styles)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -91,4 +91,24 @@ class HeadingTest extends \MailPoetUnitTest {
|
|||||||
expect($html)->contains('style="background-color: red');
|
expect($html)->contains('style="background-color: red');
|
||||||
expect($html)->contains('class="mailpoet-has-background-color"');
|
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>');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,6 +77,16 @@ class ParagraphTest extends \MailPoetUnitTest {
|
|||||||
expect($html)->equals('<p class="mailpoet_form_paragraph" style="font-size: 33px">Paragraph</p>');
|
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() {
|
public function testItShouldRenderDropCap() {
|
||||||
$html = $this->paragraph->render([
|
$html = $this->paragraph->render([
|
||||||
'params' => [
|
'params' => [
|
||||||
|
Reference in New Issue
Block a user