* zin: refactor.

This commit is contained in:
dingyongliang
2023-02-16 15:21:08 +08:00
parent 048a5d9140
commit 2bc5d28a0a
6 changed files with 18 additions and 67 deletions
+3 -10
View File
@@ -8,15 +8,6 @@ class cell extends wg
{
static $defineProps = 'order,grow,shrink,width,align,flex';
public function onAddChild($child)
{
if($child instanceof wg) {
$this->addToBlock('inner', $child);
return false;
}
return null;
}
protected function build()
{
$basis = empty($this->prop('width')) ? 'auto' : $this->prop('width');
@@ -32,9 +23,11 @@ class cell extends wg
if(!empty($this->prop('width'))) $style['flex-basis'] = $this->prop('width');
if(!empty($this->prop('align'))) $style['align-self'] = $this->prop('align');
if(!empty($this->prop('flex'))) $style['flex'] = $this->prop('flex');
return div(
setStyle($style),
$this->block('inner'),
set($this->props->skip(array_keys(static::getDefinedProps()))),
$this->children()
);
}
}
+2 -10
View File
@@ -4,20 +4,12 @@ namespace zin;
class center extends wg
{
public function onAddChild($child)
{
if($child instanceof wg) {
$this->addToBlock('inner', $child);
return false;
}
return null;
}
protected function build()
{
return div(
setClass("flex justify-center items-center"),
$this->block('inner'),
set($this->props->skip(array_keys(static::getDefinedProps()))),
$this->children()
);
}
}
+3 -10
View File
@@ -6,22 +6,15 @@ class column extends wg
{
static $defineProps = 'justify,align';
public function onAddChild($child)
{
if($child instanceof wg) {
$this->addToBlock('inner', $child);
return false;
}
return null;
}
protected function build()
{
$justify = empty($this->prop('justify')) ? 'start' : $this->prop('justify');
$align = empty($this->prop('align')) ? 'start' : $this->prop('align');
return div(
setClass("col justify-$justify items-$align"),
$this->block('inner'),
set($this->props->skip(array_keys(static::getDefinedProps()))),
$this->children()
);
}
}
+3 -15
View File
@@ -6,24 +6,12 @@ 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(),
)),
setClass('label'),
set($this->props->skip(array_keys(static::getDefinedProps()))),
$this->children()
);
}
}
+4 -12
View File
@@ -3,21 +3,13 @@ namespace zin;
class pagemain extends wg
{
public function onAddChild($child)
{
if($child instanceof wg) {
$this->addToBlock('inner', $child);
return false;
}
return null;
}
protected function build()
{
$pagemain = h::div(
h::div(
$pagemain = div(
div(
setClass('container'),
$this->block('inner'),
set($this->props->skip(array_keys(static::getDefinedProps()))),
$this->children()
)
);
$pagemain->setDefaultProps(array('id' => 'main'));
+3 -10
View File
@@ -6,22 +6,15 @@ class row extends wg
{
static $defineProps = 'justify,align';
public function onAddChild($child)
{
if($child instanceof wg) {
$this->addToBlock('inner', $child);
return false;
}
return null;
}
protected function build()
{
$justify = empty($this->prop('justify')) ? 'start' : $this->prop('justify');
$align = empty($this->prop('align')) ? 'start' : $this->prop('align');
return div(
setClass("row justify-$justify items-$align"),
$this->block('inner'),
set($this->props->skip(array_keys(static::getDefinedProps()))),
$this->children()
);
}
}