From 1977ced1dcd34f586b20c3bd3993fc264c008149 Mon Sep 17 00:00:00 2001 From: Hao Sun Date: Wed, 15 Feb 2023 17:42:19 +0800 Subject: [PATCH] + zin: add new widget actionItem --- zin/func.php | 1 + zin/wg/actionitem/v1.php | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 zin/wg/actionitem/v1.php diff --git a/zin/func.php b/zin/func.php index aec24256d8..bc82e04a52 100644 --- a/zin/func.php +++ b/zin/func.php @@ -24,3 +24,4 @@ function row() {return createWg('row', func_get_args());} function column() {return createWg('column', func_get_args());} function center() {return createWg('center', func_get_args());} function cell() {return createWg('cell', func_get_args());} +function actionItem() {return createWg('actionitem', func_get_args());} diff --git a/zin/wg/actionitem/v1.php b/zin/wg/actionitem/v1.php new file mode 100644 index 0000000000..e68d5b76b0 --- /dev/null +++ b/zin/wg/actionitem/v1.php @@ -0,0 +1,36 @@ +prop('tagName', 'icon', 'text', 'trailingIcon'); + return h::create + ( + $tagName, + set($text), + set($this->props->skip(array_keys(actionItem::getDefinedProps()))), + $icon ? icon($icon) : NULL, + $this->children(), + $trailingIcon ? icon($trailingIcon) : NULL, + ); + } + + protected function build() + { + list($name, $type, $outerTag, $tagName, $url, $target, $active, $disabled, $outerProps) = $this->prop('name', 'type', 'outerTag', 'tagName', 'url', 'target', 'active', 'disabled', 'outerProps'); + + return h::create + ( + $outerTag, + set($tagName === 'a' ? array('href' => $url, 'target' => $target) : array('data-url' => $url, 'data-target' => $target)), + setClass("$name-$type"), + setClass(array('active' => $active, 'disabled' => $disabled)), + set($outerProps), + $this->buildItem() + ); + } +}