Files
xk-api-yii/admin/components/UI/Widget/Badge.php
2024-09-19 11:32:39 +08:00

64 lines
1.1 KiB
PHP

<?php
namespace admin\components\UI\Widget;
/**
* Class Badges
* @package backend\components\UI\Widget
*/
class Badge extends Widget
{
private string $content;
private string $size = 'medium';
private string $type;
/**
* Badges constructor.
* @param $content
* @param callable|null $callback
*/
public function __construct($content, callable $callback = NULL)
{
$this->content = $content;
$this->callback = $callback;
}
/**
* 颜色
* @param $value
* @return $this
*/
public function color($value): self
{
$this->type = $value;
return $this;
}
/**
* 大小
* @param string $size
* @return $this
*/
public function size(string $size = ''): self
{
$this->size = $size;
return $this;
}
/**
* @return array
*/
public function render(): array
{
return [
'nodeName' => 'a-tag',
'color' => $this->type,
'size' => $this->size,
'child' => $this->content
];
}
}