diff --git a/lib/zin/wg/entitylabel/v1.php b/lib/zin/wg/entitylabel/v1.php index 071563d759..0583a93e8f 100644 --- a/lib/zin/wg/entitylabel/v1.php +++ b/lib/zin/wg/entitylabel/v1.php @@ -9,7 +9,10 @@ class entityLabel extends wg protected static $defineProps = array( 'entityID?: string|int', // 实体编号 'level?: string|int', // 标题层级 - 'text: string' // 实体文本 + 'text: string', // 实体文本 + 'reverse?: bool=false', // 编号与文本是否交换顺序 + 'textClass?: string', // 文本样式类 + 'idClass?: string' // 编号样式类 ); protected static $defineBlocks = array( @@ -27,39 +30,41 @@ class entityLabel extends wg private function buildEntityID(): ?wg { - $entityID = $this->prop('entityID'); + $entityID = $this->prop('entityID'); + $className = $this->prop('idClass'); if(!isset($entityID)) return null; return new label ( - setClass('justify-center rounded-full mr-2 px-1.5 h-3.5'), + setClass('justify-center rounded-full px-1.5 h-3.5', $className), $entityID ); } private function buildEntityName(): wg { - $text = $this->prop('text'); - $level = $this->prop('level'); + $text = $this->prop('text'); + $level = $this->prop('level'); + $className = $this->prop('className'); return div ( - setClass("article-h$level"), + setClass("article-h$level", $className), $text ); } protected function build(): wg { + $reverse = $this->prop('reverse'); $suffix = $this->block('suffix'); $entityID = $this->buildEntityID(); $entityName = $this->buildEntityName(); return div ( - setClass('entity-label', 'flex', 'items-center'), + setClass('entity-label', 'flex', 'items-center', 'gap-x-1'), set($this->props->skip(array_keys(static::getDefinedProps()))), - $entityID, - $entityName, + $reverse ? array($entityName, $entityID) : array($entityID, $entityName), $suffix ); }