* zin: add icon::create() method to create icon conveniently.

This commit is contained in:
sunhao
2024-03-05 13:41:12 +08:00
parent 7c805ac725
commit ea97dad5e0
+14
View File
@@ -33,4 +33,18 @@ class icon extends wg
$this->children()
);
}
public static function create(string|array $nameOrProps, ?array $props = null, mixed ...$children): static
{
$props = $props ? $props : array();
if(is_string($nameOrProps))
{
$props['name'] = $nameOrProps;
}
else
{
$props = array_merge($nameOrProps, $props);
}
return new static(set($props), ...$children);
}
}