PluginProbe
Tableberg – Simple Gutenberg Table Block / 1.0.3
Tableberg – Simple Gutenberg Table Block v1.0.3
1.1.5 1.1.4 1.1.3 1.1.2 1.1.1 1.1.0 1.0.5 1.0.4 1.0.3 1.0.2 1.0.1 trunk 0.0.2 0.2.1 0.3.2 0.3.3 0.4.1 0.5.0 0.5.1 0.5.2 0.5.3 0.5.4 0.5.5 0.5.6 0.5.7 All 42 releases
tableberg / renderer / Text / TextRenderer.php

TextRenderer.php in Tableberg – Simple Gutenberg Table Block 1.0.3, at renderer/Text/TextRenderer.php

39 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Tableberg\Renderer\Text;
4
5 class TextRenderer {
6 /**
7 * @param array<string, mixed>|null $attributes
8 * @return string
9 */
10 public function render($attributes) {
11 $attrs = TextAttrs::from_array($attributes);
12
13 $styleValues = ['margin:0'];
14
15 if ($attrs->styles->textColor->isNotEmpty()) {
16 $styleValues[] = 'color:' . $attrs->styles->textColor->asAttr();
17 }
18
19 if ($attrs->styles->linkColor->isNotEmpty()) {
20 $styleValues[] = '--tableberg-text-link-color:' . $attrs->styles->linkColor->asAttr();
21 }
22
23 if ($attrs->styles->backgroundColor->isNotEmpty()) {
24 $styleValues[] = 'background-color:' . $attrs->styles->backgroundColor->asAttr();
25 }
26
27 if ($attrs->styles->fontSize->isNotEmpty()) {
28 $styleValues[] = 'font-size:' . $attrs->styles->fontSize->asAttr();
29 }
30
31 $styleAttr = implode(';', $styleValues);
32
33 return
34 "<p class='tableberg-text-element' style='{$styleAttr}'>
35 {$attrs->content->asHtml()}
36 </p>";
37 }
38 }
39