v1.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace zin;
  3. class sectionCard extends wg
  4. {
  5. /**
  6. * @var mixed[]
  7. */
  8. protected static $defineBlocks = array(
  9. 'title' => array('map' => 'entityLabel')
  10. );
  11. /**
  12. * @param string $text
  13. */
  14. private function title($text)
  15. {
  16. return div
  17. (
  18. setClass('h4', 'mb-1'),
  19. "[$text]"
  20. );
  21. }
  22. /**
  23. * @param \zin\item $item
  24. */
  25. public function onBuildItem($item)
  26. {
  27. return div
  28. (
  29. setClass('py-2', 'pl-3'),
  30. $this->title($item->prop('title')),
  31. $item->children()
  32. );
  33. }
  34. protected function build()
  35. {
  36. $title = $this->block('title');
  37. return div
  38. (
  39. setClass('section-card', 'border', 'rounded-sm'),
  40. div
  41. (
  42. setClass('h-9', 'flex', 'items-center', 'pl-3'),
  43. setStyle('background', 'var(--color-gray-100)'),
  44. $title
  45. ),
  46. div
  47. (
  48. setClass('py-1'),
  49. $this->children()
  50. )
  51. );
  52. }
  53. }