Skip to content

Commit c4752be

Browse files
committed
Refactor individual badge components into one
1 parent c40f5aa commit c4752be

12 files changed

+39
-108
lines changed

resources/views/components/component-badge.blade.php

Lines changed: 0 additions & 1 deletion
This file was deleted.

resources/views/components/component.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
</div>
2222

2323
@if ($component->incidents_count > 0)
24-
<a href="{{ route('cachet.status-page.incident', [$component->incidents->first()]) }}"><x-cachet::component-badge :type="$component->status" /></a>
24+
<a href="{{ route('cachet.status-page.incident', [$component->incidents->first()]) }}"><x-cachet::badge :status="$component->status" /></a>
2525
@else
26-
<x-cachet::component-badge :type="$status" />
26+
<x-cachet::badge :status="$status" />
2727
@endif
2828
</div>
2929
</li>

resources/views/components/incident-badge.blade.php

Lines changed: 0 additions & 1 deletion
This file was deleted.

resources/views/components/incident.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
</span>
3636
</div>
3737
<div class="flex justify-start sm:justify-end">
38-
<x-cachet::incident-badge :type="$incident->status" />
38+
<x-cachet::badge :status="$incident->status" />
3939
</div>
4040
</div>
4141
</div>

resources/views/components/schedule-badge.blade.php

Lines changed: 0 additions & 1 deletion
This file was deleted.

resources/views/components/schedule.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
</span>
1414
</div>
1515
<div class="flex justify-start sm:justify-end">
16-
<x-cachet::schedule-badge :schedule="$schedule" />
16+
<x-cachet::badge :status="$schedule->status" />
1717
</div>
1818
</div>
1919
<div class="prose-sm md:prose prose-zinc dark:prose-invert prose-a:text-primary-500 prose-a:underline prose-p:leading-normal">{!! $schedule->formattedMessage() !!}</div>

src/Enums/ScheduleStatusEnum.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Cachet\Enums;
44

5+
use Filament\Support\Colors\Color;
56
use Filament\Support\Contracts\HasColor;
67
use Filament\Support\Contracts\HasIcon;
78
use Filament\Support\Contracts\HasLabel;
@@ -46,9 +47,9 @@ public function getLabel(): string
4647
public function getColor(): string|array|null
4748
{
4849
return match ($this) {
49-
self::upcoming => 'info',
50-
self::in_progress => 'warning',
51-
self::complete => 'success',
50+
self::upcoming => Color::Blue,
51+
self::in_progress => Color::Amber,
52+
self::complete => Color::Green,
5253
};
5354
}
5455

src/Enums/SystemStatusEnum.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Cachet\Enums;
44

5+
use Filament\Support\Colors\Color;
56
use Filament\Support\Contracts\HasColor;
67
use Filament\Support\Contracts\HasIcon;
78
use Filament\Support\Contracts\HasLabel;
@@ -25,9 +26,9 @@ public function getLabel(): ?string
2526
public function getColor(): string|array|null
2627
{
2728
return match ($this) {
28-
self::operational => 'success',
29-
self::partial_outage => 'warning',
30-
self::major_outage => 'danger',
29+
self::operational => Color::Green,
30+
self::partial_outage => Color::Amber,
31+
self::major_outage => Color::Red,
3132
};
3233
}
3334

src/View/Components/Badge.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
namespace Cachet\View\Components;
4+
5+
use Closure;
6+
use Filament\Support\Contracts\HasColor;
7+
use Filament\Support\Contracts\HasIcon;
8+
use Filament\Support\Contracts\HasLabel;
9+
use Illuminate\Contracts\View\View;
10+
use Illuminate\View\Component;
11+
12+
class Badge extends Component
13+
{
14+
public function __construct(public readonly HasLabel&HasColor&HasIcon $status)
15+
{
16+
//
17+
}
18+
19+
public function render(): View|Closure|string
20+
{
21+
return view('cachet::components.badge', [
22+
'color' => $this->status->getColor(),
23+
'label' => $this->status->getLabel(),
24+
'icon' => $this->status->getIcon(),
25+
]);
26+
}
27+
}

src/View/Components/ComponentBadge.php

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)