From 9b31cc50834d0874173a379f3a10dca77af2a53b Mon Sep 17 00:00:00 2001 From: paul-nothaft <40865108-paul-nothaft@users.noreply.replit.com> Date: Thu, 11 Sep 2025 10:02:12 +0000 Subject: [PATCH] Improve task calendar usability and task creation functionality Add `onKeyDown` handler to the task title input in `TaskCreationModal.tsx` to allow task creation with the Enter key. Enhance `TasksWithCalendar.tsx` to include `hoveredDate` state and `handleDragEnter`/`handleDragLeave` handlers for visual feedback during drag-and-drop operations on the calendar. Adjust the calendar's positioning to be fixed at the bottom with full width and modify styling for task cards during drag operations. Fix the display of the "today" border on the calendar. Replit-Commit-Author: Agent Replit-Commit-Session-Id: ceced2fc-aa46-458d-ba87-ddd4b7bb1518 Replit-Commit-Checkpoint-Type: intermediate_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/659922a9-0087-461c-90dd-6d9a58b81d4d/ceced2fc-aa46-458d-ba87-ddd4b7bb1518/sqJIbnU --- .replit | 4 + client/src/components/TaskCreationModal.tsx | 8 ++ client/src/components/TasksWithCalendar.tsx | 118 +++++++++++--------- replit.md | 87 +++++++++++++++ 4 files changed, 165 insertions(+), 52 deletions(-) create mode 100644 replit.md diff --git a/.replit b/.replit index 74ed208..930416a 100644 --- a/.replit +++ b/.replit @@ -14,6 +14,10 @@ run = ["npm", "run", "start"] localPort = 5000 externalPort = 80 +[[ports]] +localPort = 41353 +externalPort = 3000 + [env] PORT = "5000" diff --git a/client/src/components/TaskCreationModal.tsx b/client/src/components/TaskCreationModal.tsx index c45bb2a..c98005b 100644 --- a/client/src/components/TaskCreationModal.tsx +++ b/client/src/components/TaskCreationModal.tsx @@ -46,6 +46,13 @@ export default function TaskCreationModal({ isOpen, onClose, onSave }: TaskCreat onClose(); }; + const handleKeyDown = (e: React.KeyboardEvent) => { + if (e.key === 'Enter' && !e.shiftKey) { + e.preventDefault(); + handleSave(); + } + }; + const handleClose = () => { setTitle(''); setDescription(''); @@ -70,6 +77,7 @@ export default function TaskCreationModal({ isOpen, onClose, onSave }: TaskCreat placeholder="What needs to be done?" value={title} onChange={(e) => setTitle(e.target.value)} + onKeyDown={handleKeyDown} className="text-base" data-testid="input-task-title" autoFocus diff --git a/client/src/components/TasksWithCalendar.tsx b/client/src/components/TasksWithCalendar.tsx index 4351bec..c83677e 100644 --- a/client/src/components/TasksWithCalendar.tsx +++ b/client/src/components/TasksWithCalendar.tsx @@ -25,6 +25,7 @@ export default function TasksWithCalendar({ tasks, onTaskUpdate, onTaskEdit }: T const [filterBy, setFilterBy] = useState('all'); const [calendarStartDate, setCalendarStartDate] = useState(startOfToday()); const [draggedTask, setDraggedTask] = useState(null); + const [hoveredDate, setHoveredDate] = useState(null); const [completionModal, setCompletionModal] = useState<{ isOpen: boolean; task: Task | null }>({ isOpen: false, task: null @@ -124,6 +125,16 @@ export default function TasksWithCalendar({ tasks, onTaskUpdate, onTaskEdit }: T e.dataTransfer.dropEffect = 'move'; }; + const handleDragEnter = (date: Date) => { + if (draggedTask) { + setHoveredDate(date); + } + }; + + const handleDragLeave = () => { + setHoveredDate(null); + }; + const navigateCalendar = (direction: 'prev' | 'next') => { const newDate = addDays(calendarStartDate, direction === 'next' ? 7 : -7); setCalendarStartDate(newDate); @@ -235,8 +246,8 @@ export default function TasksWithCalendar({ tasks, onTaskUpdate, onTaskEdit }: T draggable onDragStart={(e) => handleDragStart(task.id, e)} onDragEnd={handleDragEnd} - className={`cursor-move transition-transform ${ - draggedTask === task.id ? 'opacity-50 scale-95' : 'hover:scale-[1.02]' + className={`cursor-move transition-transform hover-elevate ${ + draggedTask === task.id ? 'opacity-50 scale-95' : '' }`} > - {/* Calendar Section */} -
- {/* Calendar Header */} -
-
- -

- Next 7 Days -

-
- -
- + {/* Calendar Section - Fixed at bottom with full width */} +
+
+ {/* Calendar Header */} +
+
+ +

+ Next 7 Days +

+
- +
+ + + +
-
- {/* Horizontal Scrollable Calendar */} -
-
+ {/* Full Width Calendar Grid - Responsive */} +
{dates.map((date, index) => { const dayTasks = getTasksForDate(date); const isToday = isSameDay(date, new Date()); const isWeekend = date.getDay() === 0 || date.getDay() === 6; + const isHovered = hoveredDate && isSameDay(date, hoveredDate); return ( handleDragEnter(date)} + onDragLeave={handleDragLeave} onDrop={(e) => handleDrop(date, e)} onClick={() => { console.log('Date selected:', date.toLocaleDateString()); @@ -332,7 +346,7 @@ export default function TasksWithCalendar({ tasks, onTaskUpdate, onTaskEdit }: T
{format(date, 'EEE')}
-
{format(date, 'MMM d')} @@ -353,7 +367,7 @@ export default function TasksWithCalendar({ tasks, onTaskUpdate, onTaskEdit }: T variant="outline" className="w-full justify-start text-xs p-1 h-auto text-left" > -
+
{task.title}
@@ -361,18 +375,20 @@ export default function TasksWithCalendar({ tasks, onTaskUpdate, onTaskEdit }: T ))} {dayTasks.length > 2 && ( - + +{dayTasks.length - 2} )} {dayTasks.length === 0 && ( -
- {draggedTask ? 'Drop here' : 'No tasks'} + {isHovered && draggedTask ? '✓ Drop here' : draggedTask ? 'Drop' : ''}
)}
@@ -381,13 +397,11 @@ export default function TasksWithCalendar({ tasks, onTaskUpdate, onTaskEdit }: T })}
- - {/* Calendar Instructions */} -
- Drag tasks from above to schedule them • Use arrow buttons to see more days -
+ {/* Add bottom padding to prevent content overlap */} +
+ {/* Time Completion Modal */}