Use gap size as email layout padding

[MAILPOET-5816]
This commit is contained in:
Jan Lysý
2024-01-16 20:20:39 +01:00
committed by Rostislav Wolný
parent 7ab562bdd2
commit 6ccbf84cdf
3 changed files with 11 additions and 16 deletions

View File

@@ -32,12 +32,6 @@ class SettingsController {
*/ */
const EMAIL_LAYOUT_BACKGROUND = '#cccccc'; const EMAIL_LAYOUT_BACKGROUND = '#cccccc';
/**
* Padding of the email in pixels.
* @var string
*/
const EMAIL_PADDING = '10px';
/** /**
* Gap between blocks in flex layouts * Gap between blocks in flex layouts
* @var string * @var string
@@ -105,10 +99,10 @@ class SettingsController {
'width' => self::EMAIL_WIDTH, 'width' => self::EMAIL_WIDTH,
'background' => self::EMAIL_LAYOUT_BACKGROUND, 'background' => self::EMAIL_LAYOUT_BACKGROUND,
'padding' => [ 'padding' => [
'bottom' => self::EMAIL_PADDING, 'bottom' => self::FLEX_GAP,
'left' => self::EMAIL_PADDING, 'left' => self::FLEX_GAP,
'right' => self::EMAIL_PADDING, 'right' => self::FLEX_GAP,
'top' => self::EMAIL_PADDING, 'top' => self::FLEX_GAP,
], ],
]; ];
} }

View File

@@ -149,10 +149,10 @@
"spacing": { "spacing": {
"blockGap": "var(--wp--style--block-gap)", "blockGap": "var(--wp--style--block-gap)",
"padding": { "padding": {
"bottom": "10px", "bottom": "var(--wp--style--block-gap)",
"left": "10px", "left": "var(--wp--style--block-gap)",
"right": "10px", "right": "var(--wp--style--block-gap)",
"top": "10px" "top": "var(--wp--style--block-gap)"
} }
}, },
"color": { "color": {

View File

@@ -16,8 +16,9 @@ class SettingsControllerTest extends \MailPoetUnitTest {
public function testItGetsCorrectLayoutWidthWithoutPadding(): void { public function testItGetsCorrectLayoutWidthWithoutPadding(): void {
$settingsController = new SettingsController(); $settingsController = new SettingsController();
$layoutWidth = $settingsController->getLayoutWidthWithoutPadding(); $layoutWidth = $settingsController->getLayoutWidthWithoutPadding();
// default width is 660px and padding for left and right is 10px // default width is 660px and if we subtract padding from left and right we must get the correct value
verify($layoutWidth)->equals('640px'); $expectedWidth = (int)SettingsController::EMAIL_WIDTH - (int)SettingsController::FLEX_GAP * 2;
verify($layoutWidth)->equals($expectedWidth . 'px');
} }
public function testItConvertsStylesToString(): void { public function testItConvertsStylesToString(): void {