页面显示优化
This commit is contained in:
+165
-137
@@ -31,9 +31,39 @@ const ClockIcon = () => (
|
||||
);
|
||||
|
||||
const levelConfig = [
|
||||
{ accent: 'emerald', badge: 'bg-emerald-100 text-emerald-700 dark:bg-emerald-900/30 dark:text-emerald-300', border: 'border-l-emerald-400', hoverBg: 'hover:border-l-emerald-500', barColor: 'bg-emerald-500', barTrack: 'bg-emerald-100 dark:bg-emerald-900/30', iconBg: 'bg-emerald-50 text-emerald-600 dark:bg-emerald-900/30 dark:text-emerald-400', checkBg: 'bg-emerald-600 border-emerald-600' },
|
||||
{ accent: 'sky', badge: 'bg-sky-100 text-sky-700 dark:bg-sky-900/30 dark:text-sky-300', border: 'border-l-sky-400', hoverBg: 'hover:border-l-sky-500', barColor: 'bg-sky-500', barTrack: 'bg-sky-100 dark:bg-sky-900/30', iconBg: 'bg-sky-50 text-sky-600 dark:bg-sky-900/30 dark:text-sky-400', checkBg: 'bg-sky-600 border-sky-600' },
|
||||
{ accent: 'violet', badge: 'bg-violet-100 text-violet-700 dark:bg-violet-900/30 dark:text-violet-300', border: 'border-l-violet-400', hoverBg: 'hover:border-l-violet-500', barColor: 'bg-violet-500', barTrack: 'bg-violet-100 dark:bg-violet-900/30', iconBg: 'bg-violet-50 text-violet-600 dark:bg-violet-900/30 dark:text-violet-400', checkBg: 'bg-violet-600 border-violet-600' },
|
||||
{
|
||||
accent: 'emerald',
|
||||
badge: 'bg-emerald-100 text-emerald-700 dark:bg-emerald-900/40 dark:text-emerald-300',
|
||||
border: 'border-l-emerald-500',
|
||||
barColor: 'bg-emerald-500',
|
||||
barTrack: 'bg-emerald-100 dark:bg-emerald-900/40',
|
||||
iconBg: 'bg-emerald-50 text-emerald-600 dark:bg-emerald-900/40 dark:text-emerald-300',
|
||||
checkBg: 'bg-emerald-600 border-emerald-600',
|
||||
nest: 'bg-emerald-50/80 dark:bg-emerald-950/30 border-emerald-100 dark:border-emerald-900/50',
|
||||
rail: 'bg-emerald-300 dark:bg-emerald-700',
|
||||
},
|
||||
{
|
||||
accent: 'sky',
|
||||
badge: 'bg-sky-100 text-sky-700 dark:bg-sky-900/40 dark:text-sky-300',
|
||||
border: 'border-l-sky-500',
|
||||
barColor: 'bg-sky-500',
|
||||
barTrack: 'bg-sky-100 dark:bg-sky-900/40',
|
||||
iconBg: 'bg-sky-50 text-sky-600 dark:bg-sky-900/40 dark:text-sky-300',
|
||||
checkBg: 'bg-sky-600 border-sky-600',
|
||||
nest: 'bg-sky-50/80 dark:bg-sky-950/25 border-sky-100 dark:border-sky-900/40',
|
||||
rail: 'bg-sky-300 dark:bg-sky-700',
|
||||
},
|
||||
{
|
||||
accent: 'violet',
|
||||
badge: 'bg-violet-100 text-violet-700 dark:bg-violet-900/40 dark:text-violet-300',
|
||||
border: 'border-l-violet-500',
|
||||
barColor: 'bg-violet-500',
|
||||
barTrack: 'bg-violet-100 dark:bg-violet-900/40',
|
||||
iconBg: 'bg-violet-50 text-violet-600 dark:bg-violet-900/40 dark:text-violet-300',
|
||||
checkBg: 'bg-violet-600 border-violet-600',
|
||||
nest: 'bg-violet-50/80 dark:bg-violet-950/25 border-violet-100 dark:border-violet-900/40',
|
||||
rail: 'bg-violet-300 dark:bg-violet-700',
|
||||
},
|
||||
];
|
||||
|
||||
const priorityConfig: Record<TaskPriority, { color: string; dot: string }> = {
|
||||
@@ -124,56 +154,97 @@ const TaskItem: React.FC<TaskItemProps> = ({ task, taskNumber, onToggleTask, onE
|
||||
}
|
||||
}, [task.dueDate, task.status, t]);
|
||||
|
||||
const indentPx = level * 28;
|
||||
const cardPad = level === 0 ? 'px-3.5 py-3.5 sm:px-5 sm:py-5' : 'px-3.5 py-3 sm:px-4 sm:py-3.5';
|
||||
const titleSize = level === 0 ? 'text-base sm:text-[17px]' : level === 1 ? 'text-[15px]' : 'text-sm';
|
||||
|
||||
const actionButtons = (
|
||||
<>
|
||||
<button
|
||||
onClick={(e) => { e.stopPropagation(); onAddSiblingTask(task); }}
|
||||
className="p-1.5 sm:p-2 text-teal-500 hover:text-teal-700 dark:text-teal-400 dark:hover:text-teal-300 rounded-lg hover:bg-teal-50 dark:hover:bg-teal-900/20 transition-all duration-150"
|
||||
title={t('addSibling')}
|
||||
>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" className="w-4 h-4" viewBox="0 0 20 20" fill="currentColor">
|
||||
<path fillRule="evenodd" d="M10 2a.75.75 0 01.75.75v6.5h2.94l-1.47-1.47a.75.75 0 111.06-1.06l2.75 2.75a.75.75 0 010 1.06l-2.75 2.75a.75.75 0 11-1.06-1.06l1.47-1.47h-2.94v6.5a.75.75 0 01-1.5 0v-6.5H6.31l1.47 1.47a.75.75 0 11-1.06 1.06l-2.75-2.75a.75.75 0 010-1.06l2.75-2.75a.75.75 0 011.06 1.06L6.31 9.25h2.94v-6.5A.75.75 0 0110 2z" clipRule="evenodd" />
|
||||
</svg>
|
||||
</button>
|
||||
{level < 2 && (
|
||||
<button
|
||||
onClick={(e) => { e.stopPropagation(); onAddChildTask(task); }}
|
||||
className="p-1.5 sm:p-2 text-blue-500 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300 rounded-lg hover:bg-blue-50 dark:hover:bg-blue-900/20 transition-all duration-150"
|
||||
title={t('addChild')}
|
||||
>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" className="w-4 h-4" viewBox="0 0 20 20" fill="currentColor">
|
||||
<path fillRule="evenodd" d="M2 4.75A.75.75 0 012.75 4h3a.75.75 0 010 1.5H4.5v7.75a2.25 2.25 0 002.25 2.25h4.19l-1.47-1.47a.75.75 0 111.06-1.06l2.75 2.75a.75.75 0 010 1.06l-2.75 2.75a.75.75 0 11-1.06-1.06l1.47-1.47H6.75A3.75 3.75 0 013 12.25V5.5H2.75A.75.75 0 012 4.75z" clipRule="evenodd" />
|
||||
</svg>
|
||||
</button>
|
||||
)}
|
||||
<button
|
||||
onClick={(e) => { e.stopPropagation(); onEditTask(task); }}
|
||||
className="p-1.5 sm:p-2 text-emerald-500 hover:text-emerald-700 dark:text-emerald-400 dark:hover:text-emerald-300 rounded-lg hover:bg-emerald-50 dark:hover:bg-emerald-900/20 transition-all duration-150"
|
||||
title={t('editTask')}
|
||||
>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" className="w-4 h-4">
|
||||
<path d="M2.695 14.763l-1.262 3.154a.5.5 0 00.65.65l3.155-1.262a4 4 0 001.343-.885L17.5 5.5a2.121 2.121 0 00-3-3L3.58 13.42a4 4 0 00-.885 1.343z" />
|
||||
</svg>
|
||||
</button>
|
||||
<button
|
||||
onClick={(e) => { e.stopPropagation(); setShowDeleteConfirm(true); }}
|
||||
className="p-1.5 sm:p-2 text-red-400 hover:text-red-600 dark:text-red-400 dark:hover:text-red-300 rounded-lg hover:bg-red-50 dark:hover:bg-red-900/20 transition-all duration-150"
|
||||
title={t('deleteTask')}
|
||||
>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" className="w-4 h-4">
|
||||
<path fillRule="evenodd" d="M8.75 1A2.75 2.75 0 006 3.75v.443c-.795.077-1.584.176-2.365.298a.75.75 0 10.23 1.482l.149-.022 1.005 11.27A2.75 2.75 0 007.77 19h4.46a2.75 2.75 0 002.751-2.529l1.005-11.27.149.022a.75.75 0 10.23-1.482A41.03 41.03 0 0014 4.193V3.75A2.75 2.75 0 0011.25 1h-2.5zM10 4c.84 0 1.673.025 2.5.075V3.75c0-.69-.56-1.25-1.25-1.25h-2.5c-.69 0-1.25.56-1.25 1.25v.325C8.327 4.025 9.16 4 10 4zM8.58 7.72a.75.75 0 00-1.5.06l.3 7.5a.75.75 0 101.5-.06l-.3-7.5zm4.34.06a.75.75 0 10-1.5-.06l-.3 7.5a.75.75 0 101.5.06l.3-7.5z" clipRule="evenodd" />
|
||||
</svg>
|
||||
</button>
|
||||
</>
|
||||
);
|
||||
|
||||
return (
|
||||
<div
|
||||
className={`group/task ${dragOverTask?.id === task.id ? 'ring-2 ring-blue-400/50 rounded-lg' : ''}`}
|
||||
className={`group/task ${dragOverTask?.id === task.id ? 'ring-2 ring-blue-400/60 rounded-2xl' : ''}`}
|
||||
draggable
|
||||
onDragStart={(e) => { e.stopPropagation(); onDragStart?.(task); }}
|
||||
onDragOver={(e) => { e.stopPropagation(); onDragOver?.(e, task); }}
|
||||
onDrop={(e) => { e.stopPropagation(); onDrop?.(e, task); }}
|
||||
onDragEnd={() => { onDragEnd?.(); }}
|
||||
>
|
||||
{/* Main task row */}
|
||||
<div
|
||||
style={{ marginLeft: indentPx }}
|
||||
className={`
|
||||
relative bg-white dark:bg-slate-800 rounded-lg border border-l-[3px] ${config.border} ${config.hoverBg}
|
||||
border-slate-200/80 dark:border-slate-600/50
|
||||
px-3.5 py-3
|
||||
relative bg-white dark:bg-slate-800 border-l-4 ${config.border}
|
||||
border border-slate-200/90 dark:border-slate-700
|
||||
${level === 0 ? 'rounded-2xl shadow-sm' : 'rounded-xl'}
|
||||
${cardPad}
|
||||
transition-all duration-200 ease-out
|
||||
${isDone ? 'bg-slate-50/70 dark:bg-slate-800/70' : isInProgress ? 'bg-blue-50/30 dark:bg-blue-900/10' : isLocked ? 'bg-slate-50/50 dark:bg-slate-800/50' : 'hover:shadow-md hover:shadow-slate-100 dark:hover:shadow-slate-900/30'}
|
||||
${isDone ? 'border-slate-200/50 dark:border-slate-600/30' : ''}
|
||||
${isDone ? 'bg-slate-50/80 dark:bg-slate-800/70' : isInProgress ? 'bg-blue-50/40 dark:bg-blue-950/20' : isLocked ? 'bg-slate-50/70 dark:bg-slate-800/60' : 'hover:shadow-md hover:shadow-slate-200/70 dark:hover:shadow-black/20'}
|
||||
`}
|
||||
>
|
||||
<div className="flex items-start gap-2.5">
|
||||
{/* Collapse / dot indicator */}
|
||||
<div className="flex items-start gap-2 sm:gap-3">
|
||||
{hasChildren ? (
|
||||
<button
|
||||
onClick={() => setCollapsed(!collapsed)}
|
||||
className={`flex-shrink-0 mt-0.5 w-5 h-5 rounded-md flex items-center justify-center ${config.iconBg} hover:scale-110 active:scale-95 transition-all duration-150`}
|
||||
className={`flex-shrink-0 w-7 h-7 sm:w-8 sm:h-8 rounded-lg flex items-center justify-center ${config.iconBg} hover:scale-105 active:scale-95 transition-all duration-150`}
|
||||
title={collapsed ? t('expand') : t('collapse')}
|
||||
aria-expanded={!collapsed}
|
||||
>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
className={`h-3 w-3 transition-transform duration-200 ${collapsed ? '' : 'rotate-90'}`}
|
||||
className={`h-4 w-4 transition-transform duration-200 ${collapsed ? '' : 'rotate-90'}`}
|
||||
fill="none" viewBox="0 0 24 24" strokeWidth={2.5} stroke="currentColor"
|
||||
>
|
||||
<path strokeLinecap="round" strokeLinejoin="round" d="M8.25 4.5l7.5 7.5-7.5 7.5" />
|
||||
</svg>
|
||||
</button>
|
||||
) : (
|
||||
<div className="flex-shrink-0 mt-1 w-5 h-5 flex items-center justify-center">
|
||||
<div className={`w-1.5 h-1.5 rounded-full transition-colors duration-200 ${isDone ? 'bg-emerald-400' : isInProgress ? 'bg-blue-400 animate-pulse' : 'bg-slate-300 dark:bg-slate-500'}`} />
|
||||
<div className="flex-shrink-0 w-7 h-7 sm:w-8 sm:h-8 flex items-center justify-center">
|
||||
<div className={`w-2 h-2 rounded-full transition-colors duration-200 ${isDone ? 'bg-emerald-400' : isInProgress ? 'bg-blue-400 animate-pulse' : 'bg-slate-300 dark:bg-slate-500'}`} />
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Checkbox / Status toggle */}
|
||||
<div className="flex-shrink-0 mt-0.5 relative" ref={statusMenuRef}>
|
||||
<div className="flex-shrink-0 mt-1 relative" ref={statusMenuRef}>
|
||||
{hasChildren && isLocked && !isDone ? (
|
||||
<div title={t('depLocked')} className="w-[18px] h-[18px] flex items-center justify-center text-slate-400">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" className="w-[18px] h-[18px]">
|
||||
<div title={t('depLocked')} className="w-5 h-5 flex items-center justify-center text-slate-400">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" className="w-5 h-5">
|
||||
<path fillRule="evenodd" d="M10 1a4.5 4.5 0 00-4.5 4.5V9H5a2 2 0 00-2 2v6a2 2 0 002 2h10a2 2 0 002-2v-6a2 2 0 00-2-2h-.5V5.5A4.5 4.5 0 0010 1zm3 8V5.5a3 3 0 10-6 0V9h6z" clipRule="evenodd" />
|
||||
</svg>
|
||||
</div>
|
||||
@@ -185,17 +256,17 @@ const TaskItem: React.FC<TaskItemProps> = ({ task, taskNumber, onToggleTask, onE
|
||||
tabIndex={0}
|
||||
onKeyDown={(e) => { if (e.key === ' ' || e.key === 'Enter') handleToggle() }}
|
||||
title={isDone ? t('autoDone') : t('finishChildrenFirst')}
|
||||
className={`w-[18px] h-[18px] rounded-[5px] border-2 flex items-center justify-center transition-all duration-200 ${isDone ? `${config.checkBg}` : 'bg-slate-50 dark:bg-slate-700 border-slate-300 dark:border-slate-500'} cursor-pointer active:scale-90`}
|
||||
className={`w-5 h-5 rounded-md border-2 flex items-center justify-center transition-all duration-200 ${isDone ? `${config.checkBg}` : 'bg-slate-50 dark:bg-slate-700 border-slate-300 dark:border-slate-500'} cursor-pointer active:scale-90`}
|
||||
>
|
||||
{isDone && (
|
||||
<svg className="w-2.5 h-2.5 text-white" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={3.5}>
|
||||
<svg className="w-3 h-3 text-white" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={3.5}>
|
||||
<path strokeLinecap="round" strokeLinejoin="round" d="M5 13l4 4L19 7" />
|
||||
</svg>
|
||||
)}
|
||||
</div>
|
||||
) : effectivelyLocked && !isDone ? (
|
||||
<div title={t('needDeps')} className="w-[18px] h-[18px] flex items-center justify-center text-slate-400">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" className="w-[18px] h-[18px]">
|
||||
<div title={t('needDeps')} className="w-5 h-5 flex items-center justify-center text-slate-400">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" className="w-5 h-5">
|
||||
<path fillRule="evenodd" d="M10 1a4.5 4.5 0 00-4.5 4.5V9H5a2 2 0 00-2 2v6a2 2 0 002 2h10a2 2 0 002-2v-6a2 2 0 00-2-2h-.5V5.5A4.5 4.5 0 0010 1zm3 8V5.5a3 3 0 10-6 0V9h6z" clipRule="evenodd" />
|
||||
</svg>
|
||||
</div>
|
||||
@@ -213,13 +284,13 @@ const TaskItem: React.FC<TaskItemProps> = ({ task, taskNumber, onToggleTask, onE
|
||||
}
|
||||
}}
|
||||
className={`
|
||||
w-[18px] h-[18px] rounded-[5px] border-2 flex items-center justify-center
|
||||
w-5 h-5 rounded-md border-2 flex items-center justify-center
|
||||
transition-all duration-200 cursor-pointer active:scale-90
|
||||
${isDone ? `${config.checkBg}` : isInProgress ? 'bg-blue-500 border-blue-500' : 'bg-white dark:bg-slate-700 border-slate-300 dark:border-slate-500 hover:border-emerald-400'}
|
||||
`}
|
||||
>
|
||||
{isDone && (
|
||||
<svg className="w-2.5 h-2.5 text-white" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={3.5}>
|
||||
<svg className="w-3 h-3 text-white" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={3.5}>
|
||||
<path strokeLinecap="round" strokeLinejoin="round" d="M5 13l4 4L19 7" />
|
||||
</svg>
|
||||
)}
|
||||
@@ -231,7 +302,7 @@ const TaskItem: React.FC<TaskItemProps> = ({ task, taskNumber, onToggleTask, onE
|
||||
|
||||
{/* Status dropdown menu */}
|
||||
{showStatusMenu && (
|
||||
<div className="absolute top-6 left-0 z-50 bg-white dark:bg-slate-700 rounded-lg shadow-lg border border-slate-200 dark:border-slate-600 py-1 min-w-[120px]">
|
||||
<div className="absolute top-7 left-0 z-50 bg-white dark:bg-slate-700 rounded-xl shadow-xl border border-slate-200 dark:border-slate-600 py-1.5 min-w-[140px]">
|
||||
{[
|
||||
{ value: 'todo', label: t('statusTodo'), icon: '⬜' },
|
||||
{ value: 'in_progress', label: t('statusDoing'), icon: '🔵' },
|
||||
@@ -240,7 +311,7 @@ const TaskItem: React.FC<TaskItemProps> = ({ task, taskNumber, onToggleTask, onE
|
||||
<button
|
||||
key={s.value}
|
||||
onClick={() => handleStatusSelect(s.value)}
|
||||
className={`w-full text-left px-3 py-1.5 text-sm hover:bg-slate-50 dark:hover:bg-slate-600 flex items-center gap-2 ${task.status === s.value ? 'font-semibold text-green-600 dark:text-green-400' : 'text-slate-700 dark:text-slate-200'}`}
|
||||
className={`w-full text-left px-3 py-2 text-sm hover:bg-slate-50 dark:hover:bg-slate-600 flex items-center gap-2 ${task.status === s.value ? 'font-semibold text-green-600 dark:text-green-400' : 'text-slate-700 dark:text-slate-200'}`}
|
||||
>
|
||||
<span>{s.icon}</span>
|
||||
<span>{s.label}</span>
|
||||
@@ -250,24 +321,21 @@ const TaskItem: React.FC<TaskItemProps> = ({ task, taskNumber, onToggleTask, onE
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Content */}
|
||||
<div className="flex-grow min-w-0">
|
||||
{/* Title row */}
|
||||
<div className="flex items-center gap-1.5 flex-wrap">
|
||||
<span className={`text-[10px] font-bold px-1.5 py-0.5 rounded ${config.badge} leading-none`}>
|
||||
<div className="flex-1 min-w-0 pt-0.5">
|
||||
<div className="flex items-center gap-1.5 sm:gap-2 flex-wrap">
|
||||
<span className={`text-[11px] font-bold px-2 py-0.5 rounded-md ${config.badge} leading-none tracking-wide`}>
|
||||
{taskNumber}
|
||||
</span>
|
||||
{/* Priority badge */}
|
||||
{task.priority && task.priority !== 'medium' && (
|
||||
<span className={`text-[9px] font-semibold px-1.5 py-0.5 rounded ${priorityConfig[task.priority].color} leading-none`}>
|
||||
<span className={`text-[11px] font-semibold px-2 py-0.5 rounded-md ${priorityConfig[task.priority].color} leading-none`}>
|
||||
{t(task.priority === 'high' ? 'priorityHigh' : task.priority === 'low' ? 'priorityLow' : 'priorityMedium')}
|
||||
</span>
|
||||
)}
|
||||
<span
|
||||
onClick={handleToggle}
|
||||
className={`
|
||||
font-medium leading-snug
|
||||
${level === 0 ? 'text-[15px]' : 'text-sm'}
|
||||
min-w-0 font-semibold leading-snug
|
||||
${titleSize}
|
||||
${isDone ? 'text-slate-400 dark:text-slate-500 line-through decoration-slate-300' : isInProgress ? 'text-blue-700 dark:text-blue-300' : isLocked ? 'text-slate-400 dark:text-slate-500' : 'text-slate-800 dark:text-slate-100'}
|
||||
${!isLocked && !hasChildren ? 'cursor-pointer' : ''}
|
||||
transition-colors duration-150
|
||||
@@ -275,126 +343,87 @@ const TaskItem: React.FC<TaskItemProps> = ({ task, taskNumber, onToggleTask, onE
|
||||
>
|
||||
{task.title}
|
||||
</span>
|
||||
{/* In progress indicator */}
|
||||
{isInProgress && (
|
||||
<span className="text-[9px] font-semibold px-1.5 py-0.5 rounded bg-blue-100 text-blue-600 dark:bg-blue-900/30 dark:text-blue-400 leading-none">
|
||||
<span className="text-[11px] font-semibold px-2 py-0.5 rounded-md bg-blue-100 text-blue-600 dark:bg-blue-900/40 dark:text-blue-300 leading-none">
|
||||
{t('inProgress')}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Description */}
|
||||
<div className="hidden sm:flex flex-shrink-0 items-center gap-0.5 opacity-0 group-hover/task:opacity-100 focus-within:opacity-100 transition-opacity duration-150">
|
||||
{actionButtons}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="mt-2">
|
||||
{task.description && (
|
||||
<p className={`mt-1 text-[13px] leading-relaxed ${isDone ? 'text-slate-400 dark:text-slate-500' : isLocked ? 'text-slate-400 dark:text-slate-500' : 'text-slate-500 dark:text-slate-400'}`}>
|
||||
<p className={`text-sm leading-relaxed ${isDone ? 'text-slate-400 dark:text-slate-500' : isLocked ? 'text-slate-400 dark:text-slate-500' : 'text-slate-500 dark:text-slate-400'}`}>
|
||||
{task.description}
|
||||
</p>
|
||||
)}
|
||||
|
||||
{/* Meta info */}
|
||||
<div className="mt-1.5 flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px]">
|
||||
{task.dependencies.length > 0 && (
|
||||
<div className={isDone ? 'text-slate-400 dark:text-slate-500' : 'text-slate-500 dark:text-slate-400'}>
|
||||
<span className="font-medium">{t('dependsOn')}</span> {task.dependencies.join(', ')}
|
||||
</div>
|
||||
)}
|
||||
{task.durationInHours > 0 && (
|
||||
<div className={`flex items-center gap-1 ${isDone ? 'text-slate-400 dark:text-slate-500' : 'text-slate-500 dark:text-slate-400'}`}>
|
||||
<ClockIcon />
|
||||
<span>{task.durationInHours}h</span>
|
||||
</div>
|
||||
)}
|
||||
{dueDateDisplay && (
|
||||
<div className={`flex items-center gap-1 ${dueDateDisplay.overdue ? 'text-red-500 font-semibold' : isDone ? 'text-slate-400 dark:text-slate-500' : 'text-slate-500 dark:text-slate-400'}`}>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" className="h-3 w-3" viewBox="0 0 20 20" fill="currentColor">
|
||||
<path fillRule="evenodd" d="M5.75 2a.75.75 0 01.75.75V4h7V2.75a.75.75 0 011.5 0V4h.25A2.75 2.75 0 0118 6.75v8.5A2.75 2.75 0 0115.25 18H4.75A2.75 2.75 0 012 15.25v-8.5A2.75 2.75 0 014.75 4H5V2.75A.75.75 0 015.75 2zm-1.5 5.5c-.69 0-1.25.56-1.25 1.25v6.5c0 .69.56 1.25 1.25 1.25h10.5c.69 0 1.25-.56 1.25-1.25v-6.5c0-.69-.56-1.25-1.25-1.25H4.25z" clipRule="evenodd" />
|
||||
</svg>
|
||||
<span>{dueDateDisplay.text}</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Progress bar for parent tasks */}
|
||||
{hasChildren && (
|
||||
<div className="mt-2.5">
|
||||
<div className="flex justify-between items-center mb-1">
|
||||
<span className="text-[11px] text-slate-400 dark:text-slate-500">
|
||||
{t('childSummary', { done: completedChildren, total: totalChildren })}
|
||||
{(task.dependencies.length > 0 || task.durationInHours > 0 || dueDateDisplay) && (
|
||||
<div className={`${task.description ? 'mt-2.5' : ''} flex flex-wrap items-center gap-2 text-xs`}>
|
||||
{task.dependencies.length > 0 && (
|
||||
<span className={`inline-flex items-center rounded-full px-2.5 py-1 ${isDone ? 'bg-slate-100 text-slate-400 dark:bg-slate-700/50 dark:text-slate-500' : 'bg-slate-100 text-slate-500 dark:bg-slate-700/60 dark:text-slate-300'}`}>
|
||||
<span className="font-medium mr-1">{t('dependsOn')}</span> {task.dependencies.join(', ')}
|
||||
</span>
|
||||
<span className={`text-[11px] font-bold ${childProgress === 100 ? 'text-emerald-600 dark:text-emerald-400' : 'text-slate-500 dark:text-slate-400'}`}>
|
||||
)}
|
||||
{task.durationInHours > 0 && (
|
||||
<span className={`inline-flex items-center gap-1 rounded-full px-2.5 py-1 ${isDone ? 'bg-slate-100 text-slate-400 dark:bg-slate-700/50 dark:text-slate-500' : 'bg-slate-100 text-slate-500 dark:bg-slate-700/60 dark:text-slate-300'}`}>
|
||||
<ClockIcon />
|
||||
<span>{task.durationInHours}h</span>
|
||||
</span>
|
||||
)}
|
||||
{dueDateDisplay && (
|
||||
<span className={`inline-flex items-center gap-1 rounded-full px-2.5 py-1 ${dueDateDisplay.overdue ? 'bg-red-50 text-red-500 font-semibold dark:bg-red-900/20' : isDone ? 'bg-slate-100 text-slate-400 dark:bg-slate-700/50 dark:text-slate-500' : 'bg-slate-100 text-slate-500 dark:bg-slate-700/60 dark:text-slate-300'}`}>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" className="h-3.5 w-3.5" viewBox="0 0 20 20" fill="currentColor">
|
||||
<path fillRule="evenodd" d="M5.75 2a.75.75 0 01.75.75V4h7V2.75a.75.75 0 011.5 0V4h.25A2.75 2.75 0 0118 6.75v8.5A2.75 2.75 0 0115.25 18H4.75A2.75 2.75 0 012 15.25v-8.5A2.75 2.75 0 014.75 4H5V2.75A.75.75 0 015.75 2zm-1.5 5.5c-.69 0-1.25.56-1.25 1.25v6.5c0 .69.56 1.25 1.25 1.25h10.5c.69 0 1.25-.56 1.25-1.25v-6.5c0-.69-.56-1.25-1.25-1.25H4.25z" clipRule="evenodd" />
|
||||
</svg>
|
||||
<span>{dueDateDisplay.text}</span>
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{hasChildren && (
|
||||
<div className="mt-3.5">
|
||||
<div className="flex justify-between items-center gap-3 mb-1.5">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setCollapsed(!collapsed)}
|
||||
className="min-w-0 text-left text-xs leading-snug text-slate-500 dark:text-slate-400 hover:text-slate-700 dark:hover:text-slate-200 transition-colors"
|
||||
>
|
||||
{t('childSummary', { done: completedChildren, total: totalChildren })}
|
||||
</button>
|
||||
<span className={`shrink-0 text-xs font-bold tabular-nums ${childProgress === 100 ? 'text-emerald-600 dark:text-emerald-400' : 'text-slate-500 dark:text-slate-400'}`}>
|
||||
{childProgress}%
|
||||
</span>
|
||||
</div>
|
||||
<div className={`w-full ${config.barTrack} rounded-full h-1`}>
|
||||
<div className={`w-full ${config.barTrack} rounded-full h-1.5`}>
|
||||
<div
|
||||
className={`h-1 rounded-full transition-all duration-500 ease-out ${childProgress === 100 ? 'bg-emerald-500' : config.barColor}`}
|
||||
className={`h-1.5 rounded-full transition-all duration-500 ease-out ${childProgress === 100 ? 'bg-emerald-500' : config.barColor}`}
|
||||
style={{ width: `${childProgress}%` }}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Action buttons - always visible, compact icon row */}
|
||||
<div className="flex-shrink-0 self-center flex items-center gap-0.5 opacity-0 group-hover/task:opacity-100 transition-opacity duration-150">
|
||||
{/* Add sibling */}
|
||||
<button
|
||||
onClick={(e) => { e.stopPropagation(); onAddSiblingTask(task); }}
|
||||
className="p-1.5 text-teal-500 hover:text-teal-700 dark:text-teal-400 dark:hover:text-teal-300 rounded-md hover:bg-teal-50 dark:hover:bg-teal-900/20 transition-all duration-150"
|
||||
title={t('addSibling')}
|
||||
>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" className="w-3.5 h-3.5" viewBox="0 0 20 20" fill="currentColor">
|
||||
<path fillRule="evenodd" d="M10 2a.75.75 0 01.75.75v6.5h2.94l-1.47-1.47a.75.75 0 111.06-1.06l2.75 2.75a.75.75 0 010 1.06l-2.75 2.75a.75.75 0 11-1.06-1.06l1.47-1.47h-2.94v6.5a.75.75 0 01-1.5 0v-6.5H6.31l1.47 1.47a.75.75 0 11-1.06 1.06l-2.75-2.75a.75.75 0 010-1.06l2.75-2.75a.75.75 0 011.06 1.06L6.31 9.25h2.94v-6.5A.75.75 0 0110 2z" clipRule="evenodd" />
|
||||
</svg>
|
||||
</button>
|
||||
{/* Add subtask */}
|
||||
{level < 2 && (
|
||||
<button
|
||||
onClick={(e) => { e.stopPropagation(); onAddChildTask(task); }}
|
||||
className="p-1.5 text-blue-500 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300 rounded-md hover:bg-blue-50 dark:hover:bg-blue-900/20 transition-all duration-150"
|
||||
title={t('addChild')}
|
||||
>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" className="w-3.5 h-3.5" viewBox="0 0 20 20" fill="currentColor">
|
||||
<path fillRule="evenodd" d="M2 4.75A.75.75 0 012.75 4h3a.75.75 0 010 1.5H4.5v7.75a2.25 2.25 0 002.25 2.25h4.19l-1.47-1.47a.75.75 0 111.06-1.06l2.75 2.75a.75.75 0 010 1.06l-2.75 2.75a.75.75 0 11-1.06-1.06l1.47-1.47H6.75A3.75 3.75 0 013 12.25V5.5H2.75A.75.75 0 012 4.75z" clipRule="evenodd" />
|
||||
</svg>
|
||||
</button>
|
||||
)}
|
||||
{/* Edit */}
|
||||
<button
|
||||
onClick={(e) => { e.stopPropagation(); onEditTask(task); }}
|
||||
className="p-1.5 text-emerald-500 hover:text-emerald-700 dark:text-emerald-400 dark:hover:text-emerald-300 rounded-md hover:bg-emerald-50 dark:hover:bg-emerald-900/20 transition-all duration-150"
|
||||
title={t('editTask')}
|
||||
>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" className="w-3.5 h-3.5">
|
||||
<path d="M2.695 14.763l-1.262 3.154a.5.5 0 00.65.65l3.155-1.262a4 4 0 001.343-.885L17.5 5.5a2.121 2.121 0 00-3-3L3.58 13.42a4 4 0 00-.885 1.343z" />
|
||||
</svg>
|
||||
</button>
|
||||
{/* Delete */}
|
||||
<button
|
||||
onClick={(e) => { e.stopPropagation(); setShowDeleteConfirm(true); }}
|
||||
className="p-1.5 text-red-400 hover:text-red-600 dark:text-red-400 dark:hover:text-red-300 rounded-md hover:bg-red-50 dark:hover:bg-red-900/20 transition-all duration-150"
|
||||
title={t('deleteTask')}
|
||||
>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" className="w-3.5 h-3.5">
|
||||
<path fillRule="evenodd" d="M8.75 1A2.75 2.75 0 006 3.75v.443c-.795.077-1.584.176-2.365.298a.75.75 0 10.23 1.482l.149-.022 1.005 11.27A2.75 2.75 0 007.77 19h4.46a2.75 2.75 0 002.751-2.529l1.005-11.27.149.022a.75.75 0 10.23-1.482A41.03 41.03 0 0014 4.193V3.75A2.75 2.75 0 0011.25 1h-2.5zM10 4c.84 0 1.673.025 2.5.075V3.75c0-.69-.56-1.25-1.25-1.25h-2.5c-.69 0-1.25.56-1.25 1.25v.325C8.327 4.025 9.16 4 10 4zM8.58 7.72a.75.75 0 00-1.5.06l.3 7.5a.75.75 0 101.5-.06l-.3-7.5zm4.34.06a.75.75 0 10-1.5-.06l-.3 7.5a.75.75 0 101.5.06l.3-7.5z" clipRule="evenodd" />
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
<div className="mt-1.5 flex sm:hidden items-center justify-end gap-0.5 -mr-1">
|
||||
{actionButtons}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Children with tree lines */}
|
||||
{hasChildren && !collapsed && (
|
||||
<div className="relative" style={{ marginLeft: indentPx }}>
|
||||
<div className="absolute top-0 bottom-0 w-px bg-slate-200 dark:bg-slate-600" style={{ left: 14 }} />
|
||||
<div className="pt-1 space-y-0.5">
|
||||
{task.children.map((child, index) => {
|
||||
const isLast = index === task.children!.length - 1;
|
||||
return (
|
||||
<div key={child.id} className="relative">
|
||||
<div className="absolute top-5 h-px bg-slate-200 dark:bg-slate-600" style={{ left: 14, width: 14 }} />
|
||||
{!isLast && <div className="absolute top-0 bottom-0 w-px bg-slate-200 dark:bg-slate-600" style={{ left: 14 }} />}
|
||||
{isLast && <div className="absolute top-0 h-5 w-px bg-slate-200 dark:bg-slate-600" style={{ left: 14 }} />}
|
||||
<TaskItem
|
||||
<div className={`mt-2.5 sm:ml-8 rounded-2xl border p-2 sm:p-4 space-y-2.5 sm:space-y-3 ${config.nest}`}>
|
||||
{task.children.map((child, index) => {
|
||||
const isLast = index === task.children!.length - 1;
|
||||
return (
|
||||
<div key={child.id} className="relative sm:pl-4">
|
||||
<span className={`hidden sm:block absolute left-0 top-5 bottom-5 w-0.5 rounded-full ${config.rail}`} aria-hidden="true" />
|
||||
<TaskItem
|
||||
task={child}
|
||||
taskNumber={`${taskNumber}.${index + 1}`}
|
||||
onToggleTask={onToggleTask}
|
||||
@@ -414,10 +443,9 @@ const TaskItem: React.FC<TaskItemProps> = ({ task, taskNumber, onToggleTask, onE
|
||||
onChildTaskCompleted={onChildTaskCompleted}
|
||||
onParentTaskCompleted={onParentTaskCompleted}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user