+ zin: add statusLabel widget.

This commit is contained in:
sunhao
2024-03-05 16:00:01 +08:00
parent cfe78adfaf
commit 6e5e7ed4be
2 changed files with 33 additions and 0 deletions
+1
View File
@@ -69,6 +69,7 @@ function divider(): divider {return createWg('divider', func_get_args());}
function actionItem(): actionItem {return createWg('actionItem', func_get_args());}
function nav(): nav {return createWg('nav', func_get_args());}
function label(): label {return createWg('label', func_get_args());}
function statusLabel(): statusLabel {return createWg('statusLabel', func_get_args());}
function dtable(): dtable {return createWg('dtable', func_get_args());}
function menu(): menu {return createWg('menu', func_get_args());}
function dropdown(): dropdown {return createWg('dropdown', func_get_args());}
+32
View File
@@ -0,0 +1,32 @@
<?php
declare(strict_types=1);
namespace zin;
require_once dirname(__DIR__) . DS . 'label' . DS . 'v1.php';
class statusLabel extends label
{
protected static array $defineProps = array
(
'text?:string',
'status?: string'
);
public function build()
{
list($text, $status) = $this->prop(array('text', 'status'));
return span
(
setClass('label', $status ? "status-$status" : ''),
set($this->getRestProps()),
$text,
$this->children()
);
}
public static function create(string $status, string $text, mixed ...$children): static
{
$props = array('status' => $status, 'text' => $text);
return new static(set($props), ...$children);
}
}