Use an inline-colored full-width progress bar so the fill renders without relying on purged Tailwind classes.
44 lines
922 B
PHP
44 lines
922 B
PHP
<?php
|
|
|
|
namespace App\View\Components;
|
|
|
|
use App\Services\DiskSpaceService;
|
|
use Closure;
|
|
use Illuminate\Contracts\View\View;
|
|
use Illuminate\View\Component;
|
|
|
|
class DiskSpaceBar extends Component
|
|
{
|
|
/**
|
|
* @var array{
|
|
* total_bytes: int,
|
|
* free_bytes: int,
|
|
* used_bytes: int,
|
|
* used_percent: float,
|
|
* free_percent: float,
|
|
* total_human: string,
|
|
* free_human: string,
|
|
* used_human: string
|
|
* }|null
|
|
*/
|
|
public readonly ?array $disk;
|
|
|
|
public function __construct(DiskSpaceService $diskSpace)
|
|
{
|
|
$this->disk = $diskSpace->snapshot();
|
|
}
|
|
|
|
public function shouldRender(): bool
|
|
{
|
|
return $this->disk !== null;
|
|
}
|
|
|
|
/**
|
|
* Get the view / contents that represent the component.
|
|
*/
|
|
public function render(): View|Closure|string
|
|
{
|
|
return view('components.disk-space-bar');
|
|
}
|
|
}
|