Skip to content

Commit

Permalink
PageTile accept Html
Browse files Browse the repository at this point in the history
  • Loading branch information
cevro committed Nov 1, 2023
1 parent 5d3f8e7 commit 8f3e43a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
13 changes: 9 additions & 4 deletions src/UI/PageTitle.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,23 @@

class PageTitle extends Title
{
public ?string $subTitle;
/** @var string|Html|null */
public $subTitle;

public function __construct(?string $id, string $title, ?string $icon = null, ?string $subTitle = null)
/**
* @param string|Html $title
* @param string|Html|null $subTitle
*/
public function __construct(?string $id, $title, ?string $icon = null, $subTitle = null)
{
parent::__construct($id, $title, $icon);
$this->subTitle = $subTitle;
}

public function toHtml(bool $includeSubHeadline = false): Html
public function toHtml(bool $includeSubTitle = false): Html
{
$container = parent::toHtml();
if ($includeSubHeadline && $this->subTitle) {
if ($includeSubTitle && $this->subTitle) {
$container->addHtml(
Html::el('small')
->addAttributes(['class' => 'ml-2 ms-2 text-secondary small'])
Expand Down
14 changes: 9 additions & 5 deletions src/UI/Title.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,19 @@

class Title
{
public string $title;
/** @var string|Html */
public $title;
public ?string $icon;
public ?string $id;
public string $id;

public function __construct(?string $id, string $title, ?string $icon = null)
/**
* @param string|Html $title
*/
public function __construct(?string $id, $title, ?string $icon = null)
{
$this->title = $title;
$this->icon = $icon;
$this->id = $id;
$this->id = $id ?? Random::generate(10, 'a-z');
}

public function toHtml(): Html
Expand All @@ -27,7 +31,7 @@ public function toHtml(): Html
$container->addHtml(
Html::el('i')->addAttributes(
[
'id' => $this->id ?? Random::generate(10, 'a-z'),
'id' => $this->id,
'class' => $this->icon . ' mr-2 me-2',
]
)
Expand Down

0 comments on commit 8f3e43a

Please sign in to comment.