* zin: add buildItem.

This commit is contained in:
dingyongliang
2023-02-06 13:09:22 +08:00
parent f045a7e70a
commit f520e1a358
3 changed files with 75 additions and 10 deletions
+6 -9
View File
@@ -16,7 +16,7 @@ foreach(\customModel::getMainMenu() as $menuItem)
page
(
set ('title', $title),
set('title', $title),
pageheader
(
pageheading
@@ -29,21 +29,18 @@ page
(
zuinav
(
set('js-render', true),
set('js-render', false),
set('items', $navItems),
item(array('text' => 'text')),
),
),
toolbar
(
setId('toolbar'),
set('js-render', true),
set('items', array
(
array('icon' => 'icon-plus'),
array('icon' => 'icon-group'),
array('text' => '研发综合界面'),
)
),
item(array('icon' => 'icon-plus')),
item(array('icon' => 'icon-group')),
item(array('text' => '研发综合界面')),
),
),
+35 -1
View File
@@ -3,14 +3,48 @@ namespace zin\wg;
require_once dirname(dirname(__DIR__)) . DS . 'core' . DS . 'wg.class.php';
use \zin\core\h5;
class toolbar extends \zin\core\wg
{
static $tag = 'div';
static $defaultProps = array('class' => 'toolbar', 'id' => 'toolbar');
static $defaultProps = array('id' => 'toolbar');
static $customProps = 'wrap,gap,items,btnProps,itemRender,beforeRender,afterRender,firstRender';
protected function itemsWrapper()
{
return h5::nav()->addClass('toolbar');
}
protected function buildItem($item)
{
if ($item['type'] === 'divider') return h5::div()->addClass('toolbar-divider');
$button = h5::button()->addClass('btn toolbar-item ghost');
$a = h5::a();
if ($item['active'])
{
$a->addClass('active');
}
$url = $item['url'];
if (!empty($url))
{
$a->prop('href', "$url");
}
$button->append($a);
$icon = $item['icon'];
if (!empty($icon))
{
$i = h5::i()->addClass("icon icon-$icon");
$a->append($i);
}
$span = h5::span($item['text'])->addClass('text');
$a->append($span);
return $button;
}
protected function build($isPrint = false, $parent = null)
{
$builder = parent::build($isPrint, $parent);
+34
View File
@@ -5,6 +5,8 @@ require_once dirname(dirname(__DIR__)) . DS . 'core' . DS . 'wg.class.php';
require_once dirname(dirname(__DIR__)) . DS . 'core' . DS . 'h5.class.php';
require_once dirname(__DIR__) . DS . 'icon' . DS . 'v1.php';
use \zin\core\h5;
class zuinav extends \zin\core\wg
{
static $tag = 'div';
@@ -15,6 +17,38 @@ class zuinav extends \zin\core\wg
public $cssList = array(':root{--nav-active-color: white;}');
protected function itemsWrapper()
{
return h5::menu()->addClass('nav');
}
protected function buildItem($item)
{
if ($item['type'] === 'divider') return h5::li()->addClass('nav-divider');
$li = h5::li()->addClass('nav-item');
$a = h5::a();
if ($item['active'])
{
$a->addClass('active');
}
$url = $item['url'];
if (!empty($url))
{
$a->prop('href', "$url");
}
$li->append($a);
$icon = $item['icon'];
if (!empty($icon))
{
$i = h5::i()->addClass("icon icon-$icon");
$a->append($i);
}
$span = h5::span($item['text'])->addClass('text');
$a->append($span);
return $li;
}
/**
* @return builder
*/