Alert component : allow to be closed by default

This commit is contained in:
Pierre Goiffon
2020-12-15 17:08:31 +01:00
parent ebe30a88a1
commit 3d27e59269
2 changed files with 21 additions and 3 deletions

View File

@@ -84,6 +84,8 @@ class Alert extends UIBlock
protected $sContent;
/** @var string $sColor */
protected $sColor;
/** @var bool */
protected $bIsOpenedByDefault;
/**
* Alert constructor.
@@ -92,12 +94,16 @@ class Alert extends UIBlock
* @param string $sContent
* @param string $sColor
* @param string|null $sId
* @param bool|null $bIsOpenedByDefault
*/
public function __construct(string $sTitle = '', string $sContent = '', string $sColor = self::DEFAULT_COLOR, ?string $sId = null)
public function __construct(string $sTitle = '', string $sContent = '', string $sColor = self::DEFAULT_COLOR, ?string $sId = null,
?bool $bIsOpenedByDefault = true
)
{
$this->sTitle = $sTitle;
$this->sContent = $sContent;
$this->sColor = $sColor;
$this->bIsOpenedByDefault = $bIsOpenedByDefault;
parent::__construct($sId);
}
@@ -148,7 +154,7 @@ class Alert extends UIBlock
/**
* @return string
*/
public function GetColor()
public function GetColor(): string
{
return $this->sColor;
}
@@ -163,4 +169,16 @@ class Alert extends UIBlock
return $this;
}
public function IsOpenedByDefault()
{
return $this->bIsOpenedByDefault;
}
public function SetOpenedByDefault(bool $bIsOpenedByDefault): Alert
{
$this->bIsOpenedByDefault = $bIsOpenedByDefault;
return $this;
}
}

View File

@@ -1,4 +1,4 @@
<div id="{{ oUIBlock.GetId() }}" class="ibo-alert ibo-is-{{ oUIBlock.GetColor() }} ibo-is-opened">
<div id="{{ oUIBlock.GetId() }}" class="ibo-alert ibo-is-{{ oUIBlock.GetColor() }}{% if oUIBlock.IsOpenedByDefault() %} ibo-is-opened"{% endif %}>
<div class="ibo-alert--action-button ibo-alert--maximize-button" data-role="ibo-alert--maximize-button"><i class="fas fa-caret-down"></i></div>
<div class="ibo-alert--action-button ibo-alert--minimize-button" data-role="ibo-alert--minimize-button"><i class="fas fa-caret-up"></i></div>
<div class="ibo-alert--action-button ibo-alert--close-button" data-role="ibo-alert--close-button"><i class="fas fa-times"></i></div>