Render form input and textarea styles on frontend

[MAILPOET-2599]
This commit is contained in:
Rostislav Wolny
2020-03-05 14:34:34 +01:00
committed by Veljko V
parent b70884ecaa
commit 4e8fda670c
7 changed files with 111 additions and 4 deletions

View File

@@ -0,0 +1,25 @@
<?php
namespace MailPoet\Form;
class TextInputStylesRenderer {
public function render(array $styles): string {
$rules = [];
if (isset($styles['full_width']) && intval($styles['full_width'])) {
$rules[] = 'width:100%;';
}
if (isset($styles['background_color'])) {
$rules[] = "background-color:{$styles['background_color']};";
}
if (isset($styles['border_radius'])) {
$rules[] = "border-radius:" . intval($styles['border_radius']) . "px;";
}
if (isset($styles['border_size'])) {
$rules[] = "border-width:" . intval($styles['border_size']) . "px;";
}
if (isset($styles['border_color'])) {
$rules[] = "border-color:{$styles['border_color']};";
}
return implode('', $rules);
}
}