| 1: | <?php |
| 2: | |
| 3: | declare(strict_types=1); |
| 4: | |
| 5: | namespace Atk4\Ui; |
| 6: | |
| 7: | |
| 8: | |
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: | |
| 14: | |
| 15: | |
| 16: | |
| 17: | class Header extends View |
| 18: | { |
| 19: | |
| 20: | public $size; |
| 21: | |
| 22: | |
| 23: | public $icon; |
| 24: | |
| 25: | |
| 26: | public $image; |
| 27: | |
| 28: | |
| 29: | public $subHeader; |
| 30: | |
| 31: | |
| 32: | public $aligned; |
| 33: | |
| 34: | public $ui = 'header'; |
| 35: | |
| 36: | public $defaultTemplate = 'header.html'; |
| 37: | |
| 38: | #[\Override] |
| 39: | protected function renderView(): void |
| 40: | { |
| 41: | if ($this->size) { |
| 42: | if (is_int($this->size)) { |
| 43: | $this->setElement('h' . $this->size); |
| 44: | } else { |
| 45: | $this->addClass($this->size); |
| 46: | } |
| 47: | } |
| 48: | |
| 49: | if ($this->icon) { |
| 50: | $this->icon = Icon::addTo($this, [$this->icon], ['Icon']); |
| 51: | } |
| 52: | |
| 53: | if ($this->image) { |
| 54: | $this->image = Image::addTo($this, [$this->image], ['Icon']); |
| 55: | } |
| 56: | |
| 57: | if ($this->subHeader) { |
| 58: | $this->subHeader = View::addTo($this, [$this->subHeader], ['SubHeader'])->addClass('sub header'); |
| 59: | } |
| 60: | |
| 61: | if ($this->aligned) { |
| 62: | $this->addClass($this->aligned . ' aligned'); |
| 63: | } |
| 64: | |
| 65: | if ($this->aligned && ($this->icon || $this->image)) { |
| 66: | $this->addClass('icon'); |
| 67: | } |
| 68: | |
| 69: | if (!$this->icon && !$this->elements) { |
| 70: | $this->template->del('hasContent'); |
| 71: | $this->template->set('title', $this->content); |
| 72: | $this->content = null; |
| 73: | } |
| 74: | |
| 75: | parent::renderView(); |
| 76: | } |
| 77: | } |
| 78: | |