Skip to content

Commit 724cdad

Browse files
committed
Use filament badge component and fix colors
1 parent 159c4b4 commit 724cdad

File tree

11 files changed

+59
-48
lines changed

11 files changed

+59
-48
lines changed

resources/lang/en.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"Metric Type": "Metric Type",
2828
"Month": "Month",
2929
"New Incident": "New Incident",
30-
"Newer Incidents": "Newer Incidents",
30+
"Next": "Next",
3131
"No incidents reported.": "No incidents reported.",
3232
"No incidents reported between :from and :to": "No incidents reported between :from and :to",
3333
"Notified Subscribers": "Notified Subscribers",
@@ -36,7 +36,7 @@
3636
"Partial Outage": "Partial Outage",
3737
"Past Incidents": "Past Incidents",
3838
"Performance Issues": "Performance Issues",
39-
"Previous Incidents": "Previous Incidents",
39+
"Previous": "Previous",
4040
"Record Update": "Record Update",
4141
"Resources": "Resources",
4242
"Settings": "Settings",

resources/svg/clock.svg

Lines changed: 1 addition & 1 deletion
Loading
Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,3 @@
1-
@props([
2-
'color',
3-
'icon',
4-
'label',
5-
])
6-
<div {{ $attributes->style([
7-
Illuminate\Support\Arr::toCssStyles([
8-
\Filament\Support\get_color_css_variables(
9-
$color,
10-
shades: [400, 900],
11-
),
12-
]),
13-
]) }}>
14-
<div {{ $attributes->class([
15-
'flex items-center gap-1 rounded-full px-2 py-1 text-xs font-semibold leading-tight shadow bg-custom-400 text-custom-900',
16-
]) }}>
17-
@svg($icon, 'h-5 w-5')
18-
19-
<span>{{ $label }}</span>
20-
</div>
21-
</div>
1+
<x-filament::badge :color="$color" :icon="$icon" class="bg-custom-400 text-custom-900 dark:bg-custom-400/40 dark:text-custom-400">
2+
{{ $label }}
3+
</x-filament::badge>

resources/views/components/component.blade.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
@props(['component'])
2-
31
<li class="px-4 py-3">
42
<div class="flex items-center justify-between">
53
<div class="flex flex-col">
@@ -25,7 +23,7 @@
2523
@if ($component->incidents_count > 0)
2624
<a href="{{ route('cachet.status-page.incident', [$component->incidents->first()]) }}"><x-cachet::component-badge :type="$component->status" /></a>
2725
@else
28-
<x-cachet::component-badge :type="$component->status" />
26+
<x-cachet::component-badge :type="$status" />
2927
@endif
3028
</div>
3129
</li>

resources/views/components/incident-update-status.blade.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,11 @@
22
Illuminate\Support\Arr::toCssStyles([
33
\Filament\Support\get_color_css_variables(
44
$color,
5-
shades: [200, 900],
5+
shades: [200, 400, 700, 900],
66
),
77
]),
88
])->merge(['title' => $title]) }}>
9-
<div class="absolute -left-[calc(28px+10px+13px)] top-4 flex h-7 w-7 items-center justify-center rounded-full bg-custom-200 dark:text-zinc-900">
10-
@if ($icon)
9+
<div class="absolute -left-[calc(28px+10px+13px)] top-4 flex h-7 w-7 items-center justify-center rounded-full bg-custom-200 dark:bg-custom-200/80 text-custom-700 isolate">
1110
@svg($icon, 'size-5')
12-
@else
13-
<x-heroicon-m-flag class="size-4" />
14-
@endif
1511
</div>
1612
</div>

resources/views/components/incident.blade.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
@use('Cachet\Enums\IncidentStatusEnum')
12
@props([
23
'date',
34
'incidents',
@@ -57,7 +58,7 @@
5758
</div>
5859
@endforeach
5960
<div class="relative py-4" x-data="{ timestamp: new Date(@js($incident->created_at)) }">
60-
<x-cachet::incident-update-status />
61+
<x-cachet::incident-update-status :status="IncidentStatusEnum::unknown" />
6162

6263
<span class="text-xs text-zinc-500 dark:text-zinc-400">
6364
{{ $incident->created_at->diffForHumans() }} — <time datetime="{{ $incident->created_at->toW3cString() }}" x-text="timestamp.toLocaleString()"></time>

src/Enums/ComponentStatusEnum.php

Lines changed: 7 additions & 6 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;
@@ -37,7 +38,7 @@ public function getLabel(): string
3738
public function getIcon(): ?string
3839
{
3940
return match ($this) {
40-
self::operational => 'cachet-component-operational',
41+
self::operational => 'cachet-circle-check',
4142
self::performance_issues => 'cachet-component-performance-issues',
4243
self::partial_outage => 'cachet-component-partial-outage',
4344
self::major_outage => 'cachet-component-major-outage',
@@ -48,11 +49,11 @@ public function getIcon(): ?string
4849
public function getColor(): string|array|null
4950
{
5051
return match ($this) {
51-
self::operational => 'success',
52-
self::performance_issues => 'info',
53-
self::partial_outage => 'warning',
54-
self::major_outage => 'danger',
55-
default => 'purple',
52+
self::operational => Color::Green,
53+
self::performance_issues => Color::Purple,
54+
self::partial_outage => Color::Amber,
55+
self::major_outage => Color::Red,
56+
default => Color::Blue,
5657
};
5758
}
5859
}

src/Enums/IncidentStatusEnum.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
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;
89

910
enum IncidentStatusEnum: int implements HasColor, HasIcon, HasLabel
1011
{
12+
case unknown = 0;
1113
case investigating = 1;
1214
case identified = 2;
1315
case watching = 3;
@@ -29,6 +31,7 @@ public static function fromString(string $value): self
2931
'identified' => self::identified,
3032
'watching' => self::watching,
3133
'fixed' => self::fixed,
34+
default => self::unknown,
3235
};
3336
}
3437

@@ -49,17 +52,19 @@ public function getIcon(): ?string
4952
self::investigating => 'cachet-incident-investigating',
5053
self::identified => 'cachet-incident-identified',
5154
self::watching => 'cachet-incident-watching',
52-
self::fixed => 'cachet-incident-fixed',
55+
self::fixed => 'cachet-circle-check',
56+
default => 'cachet-incident',
5357
};
5458
}
5559

5660
public function getColor(): string|array|null
5761
{
5862
return match ($this) {
59-
self::investigating => 'warning',
60-
self::watching => 'info',
61-
self::fixed => 'success',
62-
default => 'gray',
63+
self::investigating => Color::Blue,
64+
self::watching => Color::Amber,
65+
self::fixed => Color::Green,
66+
self::identified => Color::Purple,
67+
default => Color::Red,
6368
};
6469
}
6570
}

src/Enums/ScheduleStatusEnum.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,8 @@ public function getColor(): string|array|null
5555
public function getIcon(): ?string
5656
{
5757
return match ($this) {
58-
self::upcoming => 'heroicon-m-calendar-days',
59-
self::in_progress => 'heroicon-m-ellipsis-horizontal-circle',
60-
self::complete => 'heroicon-m-check-circle',
58+
self::complete => 'cachet-circle-check',
59+
default => 'cachet-clock',
6160
};
6261
}
6362

0 commit comments

Comments
 (0)