forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWeekStrip.tsx
More file actions
120 lines (109 loc) · 3.6 KB
/
Copy pathWeekStrip.tsx
File metadata and controls
120 lines (109 loc) · 3.6 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
'use client';
import { motion } from 'framer-motion';
import { Check } from 'lucide-react';
import { cn } from '@/lib/utils';
interface DayData {
date: Date;
dayName: string;
dayNumber: number;
isToday: boolean;
pending: number;
completed: number;
}
interface WeekStripProps {
days: DayData[];
selectedDate?: Date | null;
onSelectDate?: (date: Date) => void;
onDropTask?: (date: Date, taskId: string) => void;
}
export function WeekStrip({
days,
selectedDate,
onSelectDate,
onDropTask,
}: WeekStripProps) {
const handleDragOver = (e: React.DragEvent) => {
e.preventDefault();
e.currentTarget.classList.add('ring-2', 'ring-white');
};
const handleDragLeave = (e: React.DragEvent) => {
e.currentTarget.classList.remove('ring-2', 'ring-white');
};
const handleDrop = (e: React.DragEvent, date: Date) => {
e.preventDefault();
e.currentTarget.classList.remove('ring-2', 'ring-white');
const taskId = e.dataTransfer.getData('taskId');
if (taskId && onDropTask) {
onDropTask(date, taskId);
}
};
return (
<div className="flex gap-2 overflow-x-auto pb-2 scrollbar-hide">
{days.map((day, index) => {
const isSelected = selectedDate?.toDateString() === day.date.toDateString();
const hasNoTasks = day.pending === 0 && day.completed === 0;
const allCompleted = day.pending === 0 && day.completed > 0;
return (
<motion.button
key={day.date.toISOString()}
initial={{ opacity: 0, y: 10 }}
animate={{ opacity: 1, y: 0 }}
transition={{ delay: index * 0.05 }}
onClick={() => onSelectDate?.(day.date)}
onDragOver={handleDragOver}
onDragLeave={handleDragLeave}
onDrop={(e) => handleDrop(e, day.date)}
className={cn(
'flex flex-col items-center min-w-[72px] px-3 py-2 rounded-lg',
'border transition-all duration-150',
day.isToday
? 'bg-white/10 border-white/50'
: 'bg-bg-tertiary border-transparent hover:bg-bg-quaternary hover:border-white/30',
isSelected && 'ring-2 ring-white',
)}
>
{/* Day name */}
<span
className={cn(
'text-[10px] font-medium uppercase tracking-wide',
day.isToday ? 'text-white' : 'text-text-quaternary',
)}
>
{day.dayName}
</span>
{/* Day number */}
<span
className={cn(
'text-lg font-semibold my-0.5',
day.isToday ? 'text-text-primary' : 'text-text-secondary',
)}
>
{day.dayNumber}
</span>
{/* Badge */}
{!hasNoTasks && (
<div className="h-5 flex items-center justify-center">
{allCompleted ? (
<div className="w-5 h-5 rounded-full bg-success flex items-center justify-center">
<Check className="w-3 h-3 text-white" strokeWidth={3} />
</div>
) : (
<span
className={cn(
'px-1.5 py-0.5 rounded-full text-xs font-medium',
'bg-white text-black',
)}
>
{day.pending}
</span>
)}
</div>
)}
{/* Empty spacer to maintain height */}
{hasNoTasks && <div className="h-5" />}
</motion.button>
);
})}
</div>
);
}