* zin: refactor btngroup.
This commit is contained in:
+15
-6
@@ -5,13 +5,22 @@ require_once dirname(__DIR__) . DS . 'btn' . DS . 'v1.php';
|
||||
|
||||
class btngroup extends wg
|
||||
{
|
||||
static $defineProps = 'items?:array';
|
||||
|
||||
public function onBuildItem($item)
|
||||
{
|
||||
if(!($item instanceof item)) $item = item(set($item));
|
||||
return btn(inherit($item));
|
||||
}
|
||||
|
||||
protected function build()
|
||||
{
|
||||
$btnGroup = h::div(setClass('btn-group'));
|
||||
foreach($this->prop('btns') as $props)
|
||||
{
|
||||
$btnGroup->addChild(btn()->prop($props));
|
||||
}
|
||||
return $btnGroup;
|
||||
$items = $this->prop('items');
|
||||
return div(
|
||||
setClass('btn-group'),
|
||||
set($this->props->skip(array_keys(static::getDefinedProps()))),
|
||||
is_array($items) ? array_map(array($this, 'onBuildItem'), $items) : NULL,
|
||||
$this->children()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user