Skip to content

Commit 8610a11

Browse files
committed
moved edit and delete buttons to top right of TaskItem for better UI/UX
1 parent d8a3423 commit 8610a11

2 files changed

Lines changed: 19 additions & 20 deletions

File tree

client/src/components/task_item.tsx

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export function TaskItem({
127127
}
128128
return (
129129
<div className="task flex h-fit w-full max-w-[28rem] flex-col gap-3 rounded-lg bg-slate-400 p-5 text-slate-200 shadow-xl">
130-
<div className="task-title-container flex w-full flex-row items-center justify-start text-3xl font-bold text-slate-100 hover:text-slate-100">
130+
<div className="task-title-container flex w-full flex-row items-center justify-start gap-2 text-3xl font-bold text-slate-100 hover:text-slate-100">
131131
{/* Task Name and Completion */}
132132
<input
133133
className="task-completion mr-3 accent-slate-300"
@@ -142,11 +142,21 @@ export function TaskItem({
142142
onChange={(e) => setDraftName(e.target.value)}
143143
/>
144144
) : (
145-
<span
146-
className={"task-title" + (item.completed ? " line-through" : "")}
147-
>
148-
{item.name}
149-
</span>
145+
<>
146+
<span
147+
className={
148+
"task-title w-full" + (item.completed ? " line-through" : "")
149+
}
150+
>
151+
{item.name}
152+
</span>
153+
<button className="hover:brightness-110" onClick={startEdit}>
154+
<FaRegEdit className="h-5 w-5" />
155+
</button>
156+
<button onClick={() => onDelete(item.id)}>
157+
<FaRegTrashCan className="h-5 w-5 hover:text-red-600" />
158+
</button>
159+
</>
150160
)}
151161
</div>
152162

@@ -234,25 +244,14 @@ export function TaskItem({
234244
</button>
235245
</div>
236246
) : (
237-
<button className="hover:brightness-110" onClick={startEdit}>
238-
<FaRegEdit className="h-5 w-5" />
239-
</button>
240-
)}
241-
</div>
242-
243-
{/* Delete Button */}
244-
<div>
245-
{!isEditing && (
246-
<button onClick={() => onDelete(item.id)}>
247-
<FaRegTrashCan className="h-5 w-5 hover:text-red-600" />
248-
</button>
247+
<></>
249248
)}
250249
</div>
251250
</div>
252251
);
253252
}
254253

255-
function formatDay(day: number): string {
254+
export function formatDay(day: number): string {
256255
const days = [
257256
"Monday",
258257
"Tuesday",

client/src/pages/[id]/tasks.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ export default function TasksPage() {
145145
availableTopics={availableTopics}
146146
/>
147147
</div>
148-
<div className="add-task-container flex h-full flex-col items-center justify-start rounded-lg bg-slate-400 p-3 shadow-xl">
148+
<div className="add-task-container hidden h-full flex-col items-center justify-start rounded-lg bg-slate-400 p-3 shadow-xl">
149149
<h1 className="text-3xl font-bold text-slate-100">Add Task</h1>
150150
<div className="task-form-wrapper h-full overflow-auto">
151151
<TaskForm

0 commit comments

Comments
 (0)