初始化仓库
This commit is contained in:
63
admin/components/UI/Widget/Badge.php
Normal file
63
admin/components/UI/Widget/Badge.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?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
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user