feat: add progress bar to TripChecklist for item completion tracking
This commit is contained in:
parent
26c0b5b136
commit
a9288c29f7
1 changed files with 47 additions and 0 deletions
|
|
@ -231,6 +231,11 @@ export default function TripChecklist({ trips }: { trips: any[] }) {
|
||||||
return withSpaces.charAt(0).toUpperCase() + withSpaces.slice(1);
|
return withSpaces.charAt(0).toUpperCase() + withSpaces.slice(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Progress calculation
|
||||||
|
const totalItems = items.length;
|
||||||
|
const checkedItems = items.filter((item) => item.checked).length;
|
||||||
|
const progress = totalItems > 0 ? Math.round((checkedItems / totalItems) * 100) : 0;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="py-4 max-w-5xl mx-auto">
|
<div className="py-4 max-w-5xl mx-auto">
|
||||||
{/* Trip-Titel und Zeitraum */}
|
{/* Trip-Titel und Zeitraum */}
|
||||||
|
|
@ -315,6 +320,48 @@ export default function TripChecklist({ trips }: { trips: any[] }) {
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{/* Progressbar integriert am unteren Rand */}
|
||||||
|
<div className="mt-6">
|
||||||
|
<div className="flex justify-between items-center mb-1">
|
||||||
|
<span className="font-semibold text-gray-700">Fortschritt</span>
|
||||||
|
<span className="text-sm text-gray-500">{checkedItems} / {totalItems} erledigt</span>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
className="w-full h-5 rounded-full overflow-hidden shadow"
|
||||||
|
style={{
|
||||||
|
background: "linear-gradient(90deg, #f59e42 0%, #facc15 50%, #22c55e 100%)",
|
||||||
|
position: "relative",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className="h-full"
|
||||||
|
style={{
|
||||||
|
width: `${progress}%`,
|
||||||
|
background: "none", // inherit the gradient from parent
|
||||||
|
position: "absolute",
|
||||||
|
left: 0,
|
||||||
|
top: 0,
|
||||||
|
transition: "width 0.3s",
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
{/* Optional: gray overlay for unfilled part */}
|
||||||
|
<div
|
||||||
|
className="h-full w-full"
|
||||||
|
style={{
|
||||||
|
background: "rgba(243,244,246,0.9)", // tailwind gray-200 with opacity
|
||||||
|
position: "absolute",
|
||||||
|
left: 0,
|
||||||
|
top: 0,
|
||||||
|
pointerEvents: "none",
|
||||||
|
zIndex: 1,
|
||||||
|
width: `${100 - progress}%`,
|
||||||
|
marginLeft: `${progress}%`,
|
||||||
|
transition: "width 0.3s, margin-left 0.3s",
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="text-right text-xs text-gray-500 mt-1">{progress}%</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/* ...Rest der Checklist... */}
|
{/* ...Rest der Checklist... */}
|
||||||
<ul
|
<ul
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue