SidePanelButton.php 887 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. // UI::hAttributes($params);
  3. // UI::hChildrens($childrens);
  4. class UI_SidePanelButton implements UITagInterface {
  5. /**
  6. * @param string $tagName = 'p5:SidePanelButton'
  7. * @param array $props
  8. * @param array $childrens
  9. *
  10. * @return string html code
  11. */
  12. static function h($tagName, $props = [], $childrens = []) {
  13. $jsFuncName = "p5_openSideBar"; // TODO: generate name based on $props['name']
  14. if (empty($props['label'])) throw new Exception("Missing 'label'");
  15. return UI::h('span', [], [
  16. UI::h('button', [
  17. 'onClick' => "return {$jsFuncName}(event, this);",
  18. 'data-name' => $props['name'],
  19. // 'data-url' => $props['url'], // TODO: if dynamic content
  20. ], $props['label']),
  21. UI::h('div', [ 'style' => "display:none" ], [
  22. ]),
  23. UI::hScript($jsFile = __FILE__ . '.script.js', $jsonVars = [
  24. // 'FUNCTION_NAME' => $jsFuncName,
  25. ]),
  26. ]);
  27. }
  28. }