123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- <?php
- // UI::hAttributes($params);
- // UI::hChildrens($childrens);
- // <details class="p5-details p5-details--{$props['theme']}">
- // <summary class="p5-details__summary">{$props['summary']}</summary>
- // <div class="p5-details__body">{$props['summary']}</div>
- // </details>
- // - props[summary] - mixed string|array passed to UI::hChildrens($params)
- // - props[type] - string success|info|warning|danger|error
- // - props[open] - boolean
- // - props[style] - string <details> style attribute value
- // - props[summary.style] - string <summary> style attribute value
- // - props[body.style] - string .p5-details__body style attribute value
- class UI_Details implements UITagInterface {
- /**
- * @param string $tagName = 'p5:Details'
- * @param array $props
- * @param array $childrens
- *
- * @return string html code
- */
- static function h($tagName, $props = [], $childrens = []) {
- if (empty($props['summary'])) throw new Exception("Missing details summary");
- $thisProps = [];
- $thisProps['style'] = (!empty($props['style'])) ? [ 'style' => $props['style'] ] : [];
- return UI::h('details', [
- 'class' => "p5-details" . (!empty($props['theme']) ? " p5-details--{$props['theme']}" : ""),
- 'style' => V::get('style', '', $props),
- 'open' => (true === $props['open']) ? true : false,
- 'test-attr-true' => true,
- 'test-attr-false' => false,
- ], [
- UI::h('summary', [
- 'class' => "p5-details__summary",
- 'style' => V::get('summary.style', '', $props),
- ], $props['summary']),
- UI::h('div', [
- 'class' => "p5-details__body",
- 'style' => V::get('body.style', '', $props),
- ], $childrens),
- ]);
- }
- }
|