Add basic style for buttons

Default background rendering has to be handled on the button renderer level
because of a specific markup for Outlook (bgcolor attribute). Default text color and paddings are
handled via CSS inlining. That's why they are tested in RendererTest

I used the same background color and font color as the one defined for the button
element in WP core theme.json, and I also used similar padding values
(In core they use "calc(0.667em + 2px) calc(1.333em + 2px)")
[MAILPOET-5814]
This commit is contained in:
Rostislav Wolny
2024-01-17 14:06:31 +01:00
committed by Jan Lysý
parent b9b57cc574
commit cd274c0738
5 changed files with 68 additions and 9 deletions

View File

@ -183,16 +183,25 @@ class SettingsController {
public function getStylesheetForRendering(): string {
$emailThemeSettings = $this->getTheme()->get_settings();
$css = '';
$cssPresets = '';
// Font family classes
foreach ($emailThemeSettings['typography']['fontFamilies']['default'] as $fontFamily) {
$css .= ".has-{$fontFamily['slug']}-font-family { font-family: {$fontFamily['fontFamily']}; } \n";
$cssPresets .= ".has-{$fontFamily['slug']}-font-family { font-family: {$fontFamily['fontFamily']}; } \n";
}
// Font size classes
foreach ($emailThemeSettings['typography']['fontSizes']['default'] as $fontSize) {
$css .= ".has-{$fontSize['slug']}-font-size { font-size: {$fontSize['size']}; } \n";
$cssPresets .= ".has-{$fontSize['slug']}-font-size { font-size: {$fontSize['size']}; } \n";
}
return $css;
// Block specific styles
$cssBlocks = '';
$blocks = $this->getTheme()->get_styles_block_nodes();
foreach ($blocks as $blockMetadata) {
$cssBlocks .= $this->getTheme()->get_styles_for_block($blockMetadata);
}
return $cssPresets . $cssBlocks;
}
public function translateSlugToFontSize(string $fontSize): string {