refactor(ui): extract admin mini bar row blade component

This commit is contained in:
萝卜
2026-03-17 08:30:20 +08:00
parent 617400a9e1
commit ac929ec593
2 changed files with 68 additions and 14 deletions

View File

@@ -0,0 +1,46 @@
@php
/**
* Admin UI Component: Mini Bar Row (link)
*
* Required:
* - $href
* - $label
* - $pct
* - $value
*
* Optional:
* - $rowRole
* - $barRole
* - $title
* - $ariaLabel
* - $class
*/
$href = (string) ($href ?? '#');
$label = (string) ($label ?? '');
$pct = (float) ($pct ?? 0);
$value = (string) ($value ?? '');
$rowRole = (string) ($rowRole ?? '');
$barRole = (string) ($barRole ?? '');
$title = (string) ($title ?? '');
$ariaLabel = (string) ($ariaLabel ?? '');
$class = (string) ($class ?? '');
$pct = max(0, min(100, $pct));
@endphp
<a class="adm-mini-bar-row adm-mini-bar-row-link {{ $class }}"
@if($rowRole !== '') data-role="{{ $rowRole }}" @endif
href="{!! $href !!}"
@if($ariaLabel !== '') aria-label="{{ $ariaLabel }}" @endif
>
<div class="adm-mini-bar-label">{{ $label }}</div>
<div class="adm-mini-bar"
@if($barRole !== '') data-role="{{ $barRole }}" @endif
@if($title !== '') title="{{ $title }}" @endif
>
<span class="adm-mini-bar-fill" style="width: {{ $pct }}%"></span>
</div>
<div class="adm-mini-bar-value">{{ $value }}</div>
</a>