* zin: refactor labels.
This commit is contained in:
@@ -5,7 +5,7 @@ namespace zin;
|
||||
class priLabel extends wg
|
||||
{
|
||||
protected static $defineProps = array(
|
||||
'pri:int|string'
|
||||
'pri: int|string'
|
||||
);
|
||||
|
||||
protected function onAddChild(mixed $child): mixed
|
||||
@@ -19,7 +19,7 @@ class priLabel extends wg
|
||||
|
||||
protected function build(): wg
|
||||
{
|
||||
$pri = (int)$this->prop('pri');
|
||||
$pri = $this->prop('pri');
|
||||
|
||||
return span
|
||||
(
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
.risk-label {font-size: 14px; font-weight: 400;}
|
||||
@@ -5,8 +5,8 @@ namespace zin;
|
||||
class riskLabel extends wg
|
||||
{
|
||||
protected static $defineProps = array(
|
||||
'text?:string', // 标签文本
|
||||
'level?:string' // 风险等级:高('high' 或 'h')、中('middle' 或 'm')、低('low' 或 'l')
|
||||
'text?: string', // 标签文本
|
||||
'level?: string' // 风险等级:高('high' 或 'h')、中('middle' 或 'm')、低('low' 或 'l')
|
||||
);
|
||||
|
||||
public static function getPageCSS(): string|false
|
||||
@@ -37,7 +37,7 @@ class riskLabel extends wg
|
||||
return span
|
||||
(
|
||||
set($this->props->skip(array_keys(static::getDefinedProps()))),
|
||||
setClass('risk-label', $this->getThemeClass()),
|
||||
setClass($this->getThemeClass()),
|
||||
$text
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
.severity-level {font-size: 14px; font-weight: 400;}
|
||||
@@ -5,8 +5,9 @@ namespace zin;
|
||||
class severityLabel extends wg
|
||||
{
|
||||
protected static $defineProps = array(
|
||||
'text?:string', // 标签文本
|
||||
'level?:string|int' // 严重程度等级 1|2|3|4
|
||||
'text?: string', // 标签文本
|
||||
'level?: string|int', // 严重程度等级
|
||||
'isIcon?: bool=false' // 是否显示为图标
|
||||
);
|
||||
|
||||
protected function onAddChild(mixed $child): mixed
|
||||
@@ -18,23 +19,17 @@ class severityLabel extends wg
|
||||
}
|
||||
}
|
||||
|
||||
private function setThemeStyle(): \zin\directive
|
||||
{
|
||||
$level = (int)$this->prop('level');
|
||||
if($level === 1) return setClass('text-danger');
|
||||
if($level === 2) return setClass('text-warning');
|
||||
if($level === 3) return setClass('text-secondary');
|
||||
return setStyle('color', 'var(--color-slate-800)');
|
||||
}
|
||||
|
||||
protected function build()
|
||||
{
|
||||
$text = $this->prop('text');
|
||||
$text = $this->prop('text');
|
||||
$level = $this->prop('level');
|
||||
$isIcon = $this->prop('isIcon');
|
||||
|
||||
return span
|
||||
(
|
||||
set($this->props->skip(array_keys(static::getDefinedProps()))),
|
||||
setClass('severity-label'),
|
||||
$this->setThemeStyle(),
|
||||
setClass($isIcon ? 'severity' : 'severity severity-label'),
|
||||
set('data-severity', $level),
|
||||
$text
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user