| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- <?php
- namespace zin;
- require_once dirname(__DIR__) . DS . 'actionitem' . DS . 'v1.php';
- class nav extends wg
- {
- /**
- * @var mixed[]
- */
- protected static $defineProps = array(
- 'stacked?: bool', // 是否为垂直模式。
- 'justified?: bool', // 是否为自适应模式。
- 'compact?: bool', // 是否为紧凑模式。
- 'type?: string', // 导航类型,包括 primary, tabs, secondary,pills
- 'items?:array', // 使用数组指定导航中的每一项。
- 'responsive?:array|bool' // 响应式导航配置。
- );
- public function onBuildItem($item)
- {
- return new actionItem
- (
- set('name', 'nav'),
- set('outerClass', 'item'),
- $item instanceof item ? inherit($item) : set($item)
- );
- }
- protected function build()
- {
- list($items, $type, $stacked, $justified, $compact, $responsive) = $this->prop(array('items', 'type', 'stacked', 'justified', 'compact', 'responsive'));
- $responsiveOptions = is_array($responsive) ? $responsive : null;
- return h::menu
- (
- setClass('nav', $type ? "nav-$type" : null, $stacked ? 'nav-stacked' : '', $justified ? 'nav-justified' : '', $compact ? 'nav-compact' : ''),
- set($this->getRestProps()),
- is_array($items) ? array_map(array($this, 'onBuildItem'), $items) : null,
- ($responsive || is_array($responsive)) ? zui::create('ResponsiveNavHelper', $responsiveOptions) : null,
- $this->children()
- );
- }
- }
|