v1.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace zin;
  3. require_once dirname(__DIR__) . DS . 'label' . DS . 'v1.php';
  4. class branchLabel extends label
  5. {
  6. /**
  7. * @var mixed[]
  8. */
  9. protected static $defineProps = array
  10. (
  11. 'text?:string',
  12. 'branch?: int'
  13. );
  14. public function build()
  15. {
  16. list($text, $branch) = $this->prop(array('text', 'branch'));
  17. return span
  18. (
  19. setClass(empty($branch) ? 'text-primary secondary-outline' : 'gray-300-outline'),
  20. setClass('label size-sm rounded-full flex-none text-clip mx-1'),
  21. setStyle('max-width', '60px'),
  22. set($this->getRestProps()),
  23. $text,
  24. $this->children()
  25. );
  26. }
  27. /**
  28. * @param mixed ...$children
  29. * @return $this
  30. * @param int $branch
  31. * @param string $text
  32. */
  33. public static function create($branch, $text, ...$children)
  34. {
  35. $props = array('branch' => $branch, 'text' => $text);
  36. return new static(set($props), ...$children);
  37. }
  38. }