* zin: add label.

This commit is contained in:
dingyongliang
2023-02-16 13:46:25 +08:00
parent 63eca80b13
commit bb13ce4e18
2 changed files with 30 additions and 0 deletions
+1
View File
@@ -26,3 +26,4 @@ function center() {return createWg('center', func_get_args());}
function cell() {return createWg('cell', func_get_args());}
function actionItem() {return createWg('actionitem', func_get_args());}
function nav() {return createWg('nav', func_get_args());}
function label() {return createWg('label', func_get_args());}
+29
View File
@@ -0,0 +1,29 @@
<?php
namespace zin;
class label extends wg
{
static $defineProps = 'text';
public function onAddChild($child)
{
if(is_string($child) && !$this->props->has('text'))
{
$this->props->set('text', $child);
return false;
}
return null;
}
public function build()
{
return span(
$this->prop('text'),
setClass(array(
'label',
$this->props->class->toStr(),
)),
);
}
}