Commit awal: prototipe UI SIAKAD Untan
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
{{-- Batang kemajuan bernilai nyata (role="meter"). Isi memakai skala, bukan lebar. --}}
|
||||
@props(['value', 'max' => 100, 'label', 'valueText' => null, 'tone' => 'neutral', 'id' => null])
|
||||
|
||||
@php
|
||||
$id ??= 'meter-'.\Illuminate\Support\Str::random(6);
|
||||
$tone = in_array($tone, ['neutral', 'success', 'danger', 'accent'], true) ? $tone : 'neutral';
|
||||
$max = (float) $max > 0 ? (float) $max : 100.0;
|
||||
$now = max(0.0, min((float) $value, $max));
|
||||
$ratio = round($now / $max, 4);
|
||||
$fmt = fn (float $n): string => rtrim(rtrim(number_format($n, 2, ',', '.'), '0'), ',');
|
||||
$valueText ??= $fmt($now).' dari '.$fmt($max);
|
||||
@endphp
|
||||
|
||||
<div {{ $attributes->class(['meter', "meter--{$tone}" => $tone !== 'neutral']) }}>
|
||||
<div class="meter__head">
|
||||
<span class="meter__label" id="{{ $id }}-label">{{ $label }}</span>
|
||||
<span class="meter__text">{{ $valueText }}</span>
|
||||
</div>
|
||||
<div
|
||||
class="meter__track"
|
||||
role="meter"
|
||||
aria-labelledby="{{ $id }}-label"
|
||||
aria-valuemin="0"
|
||||
aria-valuemax="{{ $max }}"
|
||||
aria-valuenow="{{ $now }}"
|
||||
aria-valuetext="{{ $valueText }}"
|
||||
>
|
||||
<div class="meter__fill" style="--meter-ratio: {{ $ratio }}"></div>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user