35 lines
864 B
PHP
35 lines
864 B
PHP
<?php
|
|
|
|
namespace App\View\Components;
|
|
|
|
use App\Enums\Status;
|
|
use Illuminate\View\Component;
|
|
use Illuminate\View\View;
|
|
|
|
class Badge extends Component
|
|
{
|
|
/**
|
|
* @var array|string[]
|
|
*/
|
|
public array $colorClasses;
|
|
public Status $status;
|
|
|
|
public function __construct($status = null)
|
|
{
|
|
$this->status = Status::tryFrom($status) ?? Status::Success;
|
|
$this->colorClasses = match($this->status) {
|
|
Status::Success => ['bg' => 'bg-green-100', 'text' => 'text-green-700'],
|
|
Status::Failed => ['bg' => 'bg-red-100', 'text' => 'text-red-700'],
|
|
Status::Pending => ['bg' => 'bg-gray-100', 'text' => 'text-gray-600'],
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Get the view / contents that represents the component.
|
|
*/
|
|
public function render(): View
|
|
{
|
|
return view('components.badge');
|
|
}
|
|
}
|