Add support for heading and paragraph padding to form renderer
[MAILPOET-5714]
This commit is contained in:
committed by
Aschepikov
parent
7a5241d3d3
commit
93de29b379
@@ -104,6 +104,13 @@ class Heading {
|
|||||||
if (!empty($block['params']['gradient'])) {
|
if (!empty($block['params']['gradient'])) {
|
||||||
$styles[] = "background: {$block['params']['gradient']};";
|
$styles[] = "background: {$block['params']['gradient']};";
|
||||||
}
|
}
|
||||||
|
if (!empty($block['params']['padding']) && is_array($block['params']['padding'])) {
|
||||||
|
$top = $block['params']['padding']['top'] ?? 0;
|
||||||
|
$right = $block['params']['padding']['right'] ?? 0;
|
||||||
|
$bottom = $block['params']['padding']['bottom'] ?? 0;
|
||||||
|
$left = $block['params']['padding']['left'] ?? 0;
|
||||||
|
$styles[] = "padding:{$top} {$right} {$bottom} {$left};";
|
||||||
|
}
|
||||||
if (empty($styles)) {
|
if (empty($styles)) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
@@ -86,6 +86,13 @@ class Paragraph {
|
|||||||
if (!empty($block['params']['line_height'])) {
|
if (!empty($block['params']['line_height'])) {
|
||||||
$styles[] = 'line-height: ' . $block['params']['line_height'];
|
$styles[] = 'line-height: ' . $block['params']['line_height'];
|
||||||
}
|
}
|
||||||
|
if (!empty($block['params']['padding']) && is_array($block['params']['padding'])) {
|
||||||
|
$top = $block['params']['padding']['top'] ?? 0;
|
||||||
|
$right = $block['params']['padding']['right'] ?? 0;
|
||||||
|
$bottom = $block['params']['padding']['bottom'] ?? 0;
|
||||||
|
$left = $block['params']['padding']['left'] ?? 0;
|
||||||
|
$styles[] = "padding:{$top} {$right} {$bottom} {$left};";
|
||||||
|
}
|
||||||
if (empty($styles)) {
|
if (empty($styles)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@@ -116,6 +116,16 @@ class HeadingTest extends \MailPoetUnitTest {
|
|||||||
verify($html)->equals('<h2 class="mailpoet-heading mailpoet-has-font-size" style="font-size: 33px">Header</h2>');
|
verify($html)->equals('<h2 class="mailpoet-heading mailpoet-has-font-size" style="font-size: 33px">Header</h2>');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testItShouldRenderPadding() {
|
||||||
|
$html = $this->heading->render([
|
||||||
|
'params' => [
|
||||||
|
'content' => 'Paragraph',
|
||||||
|
'padding' => ['top' => '10px', 'right' => '20px', 'bottom' => '30px', 'left' => '40px'],
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
verify($html)->stringContainsString('padding:10px 20px 30px 40px;');
|
||||||
|
}
|
||||||
|
|
||||||
public function testItShouldRenderFontSizeWithUnit() {
|
public function testItShouldRenderFontSizeWithUnit() {
|
||||||
$html = $this->heading->render([
|
$html = $this->heading->render([
|
||||||
'params' => [
|
'params' => [
|
||||||
|
@@ -91,6 +91,16 @@ class ParagraphTest extends \MailPoetUnitTest {
|
|||||||
verify($html)->equals('<p class="mailpoet_form_paragraph mailpoet-has-font-size" style="font-size: 33px">Paragraph</p>');
|
verify($html)->equals('<p class="mailpoet_form_paragraph mailpoet-has-font-size" style="font-size: 33px">Paragraph</p>');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testItShouldRenderPadding() {
|
||||||
|
$html = $this->paragraph->render([
|
||||||
|
'params' => [
|
||||||
|
'content' => 'Paragraph',
|
||||||
|
'padding' => ['top' => '10px', 'right' => '20px', 'bottom' => '30px', 'left' => '40px'],
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
verify($html)->stringContainsString('padding:10px 20px 30px 40px;');
|
||||||
|
}
|
||||||
|
|
||||||
public function testItShouldRenderFontSizeWithUnit() {
|
public function testItShouldRenderFontSizeWithUnit() {
|
||||||
$html = $this->paragraph->render([
|
$html = $this->paragraph->render([
|
||||||
'params' => [
|
'params' => [
|
||||||
|
Reference in New Issue
Block a user