Make renderer render different widths columns

[MAILPOET-1568]
This commit is contained in:
Pavel Dohnal
2018-10-25 11:04:05 +02:00
parent 6028027d47
commit 2ae39c9255
7 changed files with 177 additions and 124 deletions

View File

@@ -5,8 +5,8 @@ use MailPoet\Newsletter\Renderer\Columns\ColumnsHelper;
use MailPoet\Newsletter\Renderer\StylesHelper;
class Button {
static function render($element, $column_count) {
$element['styles']['block']['width'] = self::calculateWidth($element, $column_count);
static function render($element, $column_base_width) {
$element['styles']['block']['width'] = self::calculateWidth($element, $column_base_width);
$template = '
<tr>
<td class="mailpoet_padded_bottom mailpoet_padded_side" valign="top">
@@ -40,9 +40,8 @@ class Button {
return $template;
}
static function calculateWidth($element, $column_count) {
$column_width = ColumnsHelper::columnWidth($column_count);
$column_width = $column_width - (StylesHelper::$padding_width * 2);
static function calculateWidth($element, $column_base_width) {
$column_width = $column_base_width - (StylesHelper::$padding_width * 2);
$border_width = (int)$element['styles']['block']['borderWidth'];
$button_width = (int)$element['styles']['block']['width'];
$button_width = ($button_width > $column_width) ?
@@ -51,4 +50,4 @@ class Button {
$button_width = $button_width - (2 * $border_width) . 'px';
return $button_width;
}
}
}