diff options
| author | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-09-08 08:57:08 +0200 |
|---|---|---|
| committer | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-09-08 08:57:08 +0200 |
| commit | 4b2b964283075712de98743720ff3e31370ddc8e (patch) | |
| tree | 7200e83869dbd42d5f20318a07a6ca328e5ac59f /src/lib/components/StatusBadge.svelte | |
| parent | 992e40835af1600a0961ec2454fb78ff43aec3c6 (diff) | |
Deduplicate routine actions and badges across project routes
- Share edit/complete/archive form actions in routine-actions.ts; route
servers become thin wrappers (strictest guard semantics in one place)
- Move parseFrequencyDays into validation.ts
- Extract ScoreBadge/StatusBadge components; use on project pages and
the home page instead of duplicated scoreClass/statusClass helpers
- Fix archiveProject calling the routine archive with the project id
Diffstat (limited to 'src/lib/components/StatusBadge.svelte')
| -rw-r--r-- | src/lib/components/StatusBadge.svelte | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/lib/components/StatusBadge.svelte b/src/lib/components/StatusBadge.svelte new file mode 100644 index 0000000..babcbfa --- /dev/null +++ b/src/lib/components/StatusBadge.svelte @@ -0,0 +1,26 @@ +<script lang="ts"> + import { + STATUS_LABELS, + type RoutineStatus, + } from '$lib/shared/routine-metrics'; + + let { + status, + overdueDays = 0, + }: { status: RoutineStatus; overdueDays?: number } = $props(); + + const className = $derived( + status === 'ok' + ? 'status bg-success text-white' + : status === 'due' + ? 'status bg-accent-soft text-accent' + : status === 'late' + ? 'status bg-accent text-white' + : 'status bg-danger text-white', + ); +</script> + +<span class={className}> + {STATUS_LABELS[status]}{#if overdueDays > 0} + ({overdueDays} j){/if} +</span> |
