+ zin: add statusLabel widget.
This commit is contained in:
@@ -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());}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user