Render submit button gradient on front end

[MAILPOET-3005]
This commit is contained in:
Rostislav Wolny
2020-07-02 16:25:25 +02:00
committed by Veljko V
parent 74ad8c4952
commit 12dff2c34d
2 changed files with 16 additions and 1 deletions

View File

@ -8,7 +8,7 @@ class BlockStylesRenderer {
if (isset($styles['full_width']) && intval($styles['full_width'])) {
$rules[] = 'width:100%;';
}
if (isset($styles['background_color'])) {
if (isset($styles['background_color']) && empty($styles['gradient'])) {
$rules[] = "background-color:{$styles['background_color']};";
}
if (isset($styles['border_size']) || isset($styles['border_radius']) || isset($styles['border_color'])) {
@ -56,6 +56,9 @@ class BlockStylesRenderer {
if (!isset($styles['border_color'])) {
$rules[] = "border-color:transparent;";
}
if (!empty($styles['gradient'])) {
$rules[] = "background: {$styles['gradient']};";
}
if (isset($styles['bold']) && $styles['bold'] === '1') {
$rules[] = "font-weight:bold;";
}

View File

@ -83,6 +83,18 @@ class BlockStylesRendererTest extends \MailPoetUnitTest {
expect($result)->contains('padding:40px;');
}
public function testItShouldRenderButtonGradient() {
$styles = [
'gradient' => 'linear-gradient(#eee, #ddd)',
];
$settings = [
'input_padding' => '40',
'fontSize' => 13,
];
$result = $this->renderer->renderForButton($styles, $settings);
expect($result)->contains('background: linear-gradient(#eee, #ddd);');
}
public function testItShouldRenderSegmentInputStyles() {
expect($this->renderer->renderForSelect([], ['input_padding' => 10]))->equals('padding:10px;');
expect($this->renderer->renderForSelect([], ['alignment' => 'right']))->equals('margin: 0 0 0 auto;');