初始化仓库
This commit is contained in:
71
admin/components/UI/Widget/Progress.php
Normal file
71
admin/components/UI/Widget/Progress.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace admin\components\UI\Widget;
|
||||
|
||||
use admin\components\UI\Tools;
|
||||
use admin\components\UI\Widget\Append\Element;
|
||||
|
||||
/**
|
||||
* Class Progress
|
||||
* @package backend\components\UI\Widget
|
||||
*/
|
||||
class Progress extends Widget
|
||||
{
|
||||
use Element;
|
||||
|
||||
private $value;
|
||||
private string $color = 'default';
|
||||
private string $size = 'medium';
|
||||
|
||||
|
||||
/**
|
||||
* Progress constructor.
|
||||
* @param $value
|
||||
* @param callable|null $callback
|
||||
*/
|
||||
public function __construct($value, callable $callback = NULL)
|
||||
{
|
||||
$this->value = $value;
|
||||
$this->callback = $callback;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $color
|
||||
* @return $this
|
||||
*/
|
||||
public function color(string $color): self
|
||||
{
|
||||
$this->color = $color;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $size
|
||||
* @return $this
|
||||
*/
|
||||
public function size($size = 'medium'): self
|
||||
{
|
||||
$this->size = (bool)$size;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function render(): array
|
||||
{
|
||||
$node = [
|
||||
'nodeName' => 'a-progress',
|
||||
'size' => $this->size,
|
||||
'status' => $this->color,
|
||||
];
|
||||
if (is_numeric($this->value)) {
|
||||
$node['percent'] = $this->value;
|
||||
}else {
|
||||
$node['vBind:percent'] = $this->value;
|
||||
}
|
||||
return $node;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user