Update
This commit is contained in:
@@ -35,6 +35,8 @@ class BaseButton implements Contract\Renderable
|
||||
protected $link;
|
||||
/** @var integer|string */
|
||||
protected $counter;
|
||||
/** @var CounterStyle */
|
||||
protected $counterStyle;
|
||||
/** @var array */
|
||||
protected $events = [];
|
||||
/** @var ButtonAttributes */
|
||||
@@ -114,6 +116,11 @@ class BaseButton implements Contract\Renderable
|
||||
$this->setCounter($params['counter']);
|
||||
}
|
||||
|
||||
if (!empty($params['counterStyle']))
|
||||
{
|
||||
$this->setCounterStyle($params['counterStyle']);
|
||||
}
|
||||
|
||||
if (!empty($params['id']))
|
||||
{
|
||||
$this->setId($params['id']);
|
||||
@@ -258,9 +265,10 @@ class BaseButton implements Contract\Renderable
|
||||
|
||||
if ($counter !== null)
|
||||
{
|
||||
$counterStyle = $this->getCounterStyle() ?? CounterStyle::FILLED_ALERT;
|
||||
$counter = new Counter(
|
||||
useAirDesign: true,
|
||||
style: CounterStyle::FILLED_ALERT,
|
||||
style: $counterStyle,
|
||||
value: (int)$counter,
|
||||
);
|
||||
|
||||
@@ -642,4 +650,33 @@ class BaseButton implements Contract\Renderable
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setCounterStyle(CounterStyle | string $style): self
|
||||
{
|
||||
if ($style instanceof CounterStyle)
|
||||
{
|
||||
$this->counterStyle = $style;
|
||||
return $this;
|
||||
}
|
||||
|
||||
$styleFromEnum = CounterStyle::tryFrom($style);
|
||||
|
||||
if (!is_null($styleFromEnum))
|
||||
{
|
||||
$this->counterStyle = $styleFromEnum;
|
||||
return $this;
|
||||
}
|
||||
|
||||
$this->counterStyle = CounterStyle::FILLED_ALERT;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCounterStyle(): ?CounterStyle
|
||||
{
|
||||
return $this->counterStyle;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user