| 12345678910111213141516171819202122232425262728293031323334353637 |
- <?php
- // UI::hAttributes($params);
- // UI::hChildrens($childrens);
- // - props[type] - string success|info|warning|danger|error
- // <div class="alert alert-success" role="alert">...</div>
- // <div class="alert alert-info" role="alert">...</div>
- // <div class="alert alert-warning" role="alert">...</div>
- // <div class="alert alert-danger" role="alert">...</div>
- class UI_Alert implements UITagInterface {
- /**
- * @param string $tagName = 'p5:Alert'
- * @param array $props
- * @param array $childrens
- *
- * @return string html code
- */
- static function h($tagName, $props = [], $childrens = []) {
- $type = self::convertType($props['type']);
- return UI::h('div', [ 'class' => "alert alert-{$type}" ], $childrens);
- }
- static function convertType($type) {
- switch (strtolower($type)) {
- case 'success': return 'success';
- case 'info': return 'info';
- case 'warning': return 'warning';
- case 'danger': return 'danger';
- case 'error': return 'danger';
- default: return 'info';
- }
- }
- }
|