Render form border

[MAILPOET-2809]
This commit is contained in:
Pavel Dohnal
2020-04-21 09:50:01 +02:00
committed by Veljko V
parent ee8291b2aa
commit c1691d2c5a
2 changed files with 42 additions and 0 deletions

View File

@@ -107,6 +107,14 @@ class Renderer {
$styles[] = 'color: ' . trim($formSettings['fontColor']);
}
if (isset($formSettings['borderSize']) && isset($formSettings['borderColor'])) {
$styles[] = 'border: ' . $formSettings['borderSize'] . 'px solid ' . $formSettings['borderColor'];
}
if (isset($formSettings['borderRadius'])) {
$styles[] = 'border-radius: ' . $formSettings['borderRadius'] . 'px';
}
return join(';', $styles);
}
}

View File

@@ -97,4 +97,38 @@ class RendererTest extends \MailPoetUnitTest {
$recaptcha = $this->htmlParser->findByXpath($html, "//div[@class='mailpoet_recaptcha']");
expect($recaptcha->length)->equals(0);
}
public function testItShouldNotRenderStylesForFormWithoutSettings() {
$form = Fixtures::get('simple_form_body');
$styles = $this->renderer->renderFormElementStyles($form);
expect($styles)->equals('');
}
public function testItShouldRenderBackgroundColour() {
$form = Fixtures::get('simple_form_body');
$form['settings'] = ['backgroundColor' => 'red'];
$styles = $this->renderer->renderFormElementStyles($form);
expect($styles)->equals('background-color: red');
}
public function testItShouldRenderFontColour() {
$form = Fixtures::get('simple_form_body');
$form['settings'] = ['fontColor' => 'red'];
$styles = $this->renderer->renderFormElementStyles($form);
expect($styles)->equals('color: red');
}
public function testItShouldRenderBorder() {
$form = Fixtures::get('simple_form_body');
$form['settings'] = ['borderSize' => '22', 'borderColor' => 'red'];
$styles = $this->renderer->renderFormElementStyles($form);
expect($styles)->equals('border: 22px solid red');
}
public function testItShouldRenderBorderWithRadius() {
$form = Fixtures::get('simple_form_body');
$form['settings'] = ['borderSize' => '22', 'borderColor' => 'red', 'borderRadius' => '11'];
$styles = $this->renderer->renderFormElementStyles($form);
expect($styles)->equals('border: 22px solid red;border-radius: 11px');
}
}