1: <?php
2:
3: declare(strict_types=1);
4:
5: namespace Atk4\Ui;
6:
7: class Label extends View
8: {
9: public $ui = 'label';
10:
11: /**
12: * Add icon before label. If 'string' or seed is specified, it will
13: * be converted to object by init().
14: *
15: * @var View|array|string
16: */
17: public $icon;
18:
19: /**
20: * Icon to the right of the label.
21: *
22: * @var View|array|string
23: */
24: public $iconRight;
25:
26: /** @var string|false|null Add "Detail" to label. */
27: public $detail;
28:
29: /**
30: * Image to the left of the label. Cannot be used with label. If string
31: * is set, will be used as Image source. Can also contain seed or object.
32: *
33: * @var View|array|string
34: */
35: public $image;
36:
37: /**
38: * Image to the right of the label.
39: *
40: * @var View|array|string
41: */
42: public $imageRight;
43:
44: public $defaultTemplate = 'label.html';
45:
46: #[\Override]
47: protected function renderView(): void
48: {
49: if ($this->icon) {
50: $this->icon = Icon::addTo($this, [$this->icon], ['BeforeContent']);
51: }
52:
53: if ($this->image) {
54: $this->image = Image::addTo($this, [$this->image], ['BeforeContent']);
55: $this->addClass('image');
56: }
57:
58: if ($this->detail) {
59: $this->detail = View::addTo($this, [$this->detail], ['AfterContent'])->addClass('detail');
60: }
61:
62: if ($this->iconRight) {
63: $this->iconRight = Icon::addTo($this, [$this->iconRight], ['AfterContent']);
64: }
65:
66: if ($this->imageRight) {
67: $this->imageRight = Image::addTo($this, [$this->imageRight], ['AfterContent']);
68: $this->addClass('image');
69: }
70:
71: parent::renderView();
72: }
73: }
74: