forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHomeTaskList.tsx
More file actions
97 lines (87 loc) · 2.85 KB
/
Copy pathHomeTaskList.tsx
File metadata and controls
97 lines (87 loc) · 2.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
'use client';
import Link from '@tschk/moonshine-next/link';
import { Check } from 'lucide-react';
import type { ActionItem } from '@/types/conversation';
import { cn } from '@/lib/utils';
/**
* The middle of the hub: what is actually waiting on you.
*
* This is the web read of desktop's `homeKnowsList` (DashboardPage) — the open
* action items, rendered as plain rows in a 520pt column. Desktop shows no
* count tiles here and neither does this: a number is a worse answer than the
* thing itself.
*/
/** Desktop caps the list so the hub stays a glance, not a backlog. */
const VISIBLE = 4;
interface HomeTaskListProps {
items: ActionItem[];
loading: boolean;
error: string | null;
onComplete: (id: string) => void;
}
export function HomeTaskList({ items, loading, error, onComplete }: HomeTaskListProps) {
if (loading) {
return (
<div className="w-full space-y-2">
{[0, 1, 2].map((key) => (
<div key={key} className="h-11 animate-pulse rounded-control bg-bg-raised/60" />
))}
</div>
);
}
if (error) {
return <p className="text-center text-sm text-error">Could not load tasks.</p>;
}
if (items.length === 0) {
return (
<p className="text-center text-sm text-text-quaternary">
Nothing's waiting on you.
</p>
);
}
const visible = items.slice(0, VISIBLE);
const overflow = items.length - visible.length;
return (
<div className="w-full">
<ul className="space-y-1">
{visible.map((item) => (
<li key={item.id}>
<div
className={cn(
'group flex items-center gap-3 rounded-control px-3 py-2.5',
'transition-colors hover:bg-bg-raised/70',
)}
>
<button
type="button"
onClick={() => onComplete(item.id)}
aria-label={`Complete: ${item.description}`}
className={cn(
'flex h-[18px] w-[18px] flex-shrink-0 items-center justify-center',
'rounded-full border border-stroke text-transparent',
'transition-colors hover:border-text-primary hover:text-text-primary',
)}
>
<Check className="h-3 w-3" strokeWidth={3} />
</button>
<Link
href="/tasks"
className="min-w-0 flex-1 truncate text-sm text-text-secondary transition-colors group-hover:text-text-primary"
>
{item.description}
</Link>
</div>
</li>
))}
</ul>
{overflow > 0 && (
<Link
href="/tasks"
className="mt-2 block px-3 text-xs text-text-quaternary transition-colors hover:text-text-secondary"
>
{overflow} more in Tasks
</Link>
)}
</div>
);
}