Repository navigation
Expand file tree
/
Copy pathExtensionPill.php
More file actions
49 lines (43 loc) · 1.49 KB
/
Copy pathExtensionPill.php
File metadata and controls
49 lines (43 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
declare(strict_types=1);
namespace PHPForge\Debug\Helper;
use PHPForge\Debug\Theme\Css;
use UIAwesome\Html\Phrasing\Span;
/**
* Renders the shared `yii-debug-ext-pill` chip: a status LED, the extension name, and its state.
*/
final class ExtensionPill
{
/**
* Renders one extension pill.
*
* @param string $label Extension or module name shown in the pill.
* @param string $state Short state text shown after the label (`on`, `off`, or a version).
* @param bool $enabled Whether the extension is active, selecting the `is-on` / `is-off` modifier.
* @param string $summary Screen-reader-only detail appended after the state, or `''` to omit it.
*
* @return Span Extension pill element.
*/
public static function render(string $label, string $state, bool $enabled, string $summary = ''): Span
{
$children = [
Span::tag()
->addAriaAttribute('hidden', 'true')
->class(Css::EXT_PILL_DOT),
Span::tag()
->class(Css::EXT_PILL_LABEL)
->content($label),
Span::tag()
->class(Css::EXT_PILL_STATE)
->content($state),
];
if ($summary !== '') {
$children[] = Span::tag()
->class(Css::SR_ONLY)
->content($summary);
}
return Span::tag()
->class(Css::EXT_PILL . ' ' . ($enabled ? 'is-on' : 'is-off'))
->html(...$children);
}
}