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

View File

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

View File

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