- Updates button/spacer rendering and unit tests

This commit is contained in:
Vlad
2016-02-26 09:05:43 -05:00
parent 73ed070a34
commit bd593b1ad4
3 changed files with 31 additions and 8 deletions

View File

@@ -6,12 +6,7 @@ use MailPoet\Newsletter\Renderer\StylesHelper;
class Button {
static function render($element, $column_count) {
$column_width = ColumnsHelper::columnWidth($column_count);
$column_width = $column_width - (StylesHelper::$padding_width * 2);
$element['styles']['block']['width'] =
((int) $element['styles']['block']['width'] > $column_width) ?
$column_width . 'px' :
$element['styles']['block']['width'];
$element['styles']['block']['width'] = self::calculateWidth($element, $column_count);
$template = '
<tr>
<td class="mailpoet_padded" valign="top">
@@ -44,4 +39,13 @@ class Button {
</tr>';
return $template;
}
static function calculateWidth($element, $column_count) {
$column_width = ColumnsHelper::columnWidth($column_count);
$column_width = $column_width - (StylesHelper::$padding_width * 2);
$column_width = ((int) $element['styles']['block']['width'] > $column_width) ?
$column_width . 'px' :
$element['styles']['block']['width'];
return $column_width;
}
}