Skip to content

Commit

Permalink
✨ feat: reversed task list
Browse files Browse the repository at this point in the history
  • Loading branch information
bytevictor committed Mar 28, 2024
1 parent e756a99 commit cefc195
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 21 deletions.
24 changes: 9 additions & 15 deletions app/Components/TasksApp/AddTask.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,14 @@ import { useState } from "react";
export default function AddTask({ onAddTask }: { onAddTask: any }) {
const [text, setText] = useState("");
return (
<>
<input
placeholder="Add task"
value={text}
onChange={(e) => setText(e.target.value)}
/>
<button
onClick={() => {
setText("");
onAddTask(text);
}}
>
Add
</button>
</>
<button
className="btn btn-primary btn-lg"
onClick={() => {
setText("");
onAddTask(text);
}}
>
Add Task
</button>
);
}
1 change: 0 additions & 1 deletion app/Components/TasksApp/TaskApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export default function TaskApp() {

return (
<>
<h1>Day off in Kyoto</h1>
<AddTask
onAddTask={handleAddTask}
/>
Expand Down
6 changes: 3 additions & 3 deletions app/Components/TasksApp/TaskList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export default function TaskList({
onDeleteTask: any;
}) {
return (
<ul className="w-1/2 flex justify-center flex-col">
{tasks.map((task: any) => (
<ul className="w-1/2 mt-24 flex justify-center flex-col">
{[...tasks].reverse().map((task: any) => (
<li className="flex flex-row w-full my-2" key={task.id}>
<Task task={task} onChange={onChangeTask} onDelete={onDeleteTask} />
</li>
Expand Down Expand Up @@ -44,7 +44,7 @@ function Task({
audio.play();
};

console.log("Task", task)
console.log("Task", task);

const [isEditing, setIsEditing] = useState(task.isNew);
let taskContent;
Expand Down
3 changes: 1 addition & 2 deletions app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import TaskApp from "./Components/TasksApp/TaskApp";

export default function Home() {
return (
<main className="flex min-h-screen flex-col items-center p-24">
<SoundButton />
<main className="flex min-h-screen flex-col items-center p-24 pt-0">
<TaskApp />
</main>
);
Expand Down

0 comments on commit cefc195

Please sign in to comment.