Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1st commit #9

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,996 changes: 1,225 additions & 771 deletions package-lock.json

Large diffs are not rendered by default.

2,863 changes: 0 additions & 2,863 deletions pnpm-lock.yaml

This file was deleted.

Binary file added public/webLogo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
195 changes: 155 additions & 40 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,83 +1,198 @@
import { useState } from "react";
import { useEffect, useState } from "react";
import "./index.css";
import "./animation.css";
import "./navbar.css";

type Todo = {
content: string;
complete: boolean;
schedule: string;
priority: boolean;
};

function App() {
const [todos, setTodos] = useState<Todo[]>([]);
const [prio, setprio] = useState<Todo[]>([]);
const [todo, setTodo] = useState<string>("");
const [time, setTime] = useState<string>("");

function addTodo() {
if (!todo) {
alert("No todo!");
return;
}

const newTodos: Todo[] = [{ content: todo, complete: false }, ...todos];
const newTodos: Todo[] = [
{ content: todo, complete: false, schedule: time, priority: false},
...todos,
];
setTodos(newTodos);
}
function editTodo(index: number){
const newContent = prompt("Enter the new plan");
const newTime = prompt("Enter the new schedule");
const newTodos = todos.map((todo, i) => {
if (i === index) {
return {
content: ""+newContent,
complete: todo.complete,
schedule: ""+newTime,
priority: todo.priority,
}
}
return todo;
});
setTodos(newTodos);
}
// function shuffleTodo(index: number){
// const newIndex = prompt("Enter the new index")
// const newTodos = todos.map((todo, i) => {
// if (i === index) {
// todos.map.get(i)
// }
// return todo;
// });
// }
const [color, setColor] = useState("");
// const prioritizeTodo = (a) => {
// setColor(color);
// }
function prioritizeTodo(index: number){
const newTodos = todos.map((todo, i) => {
if (i === index) {
return {
content: todo.content,
complete: todo.complete,
schedule: todo.schedule,
priority: !todo.priority,
};
}
return todo;
});

setTodos(newTodos);
}
function removeTodo(index: number) {
// todos.splice(index, 1);
const newTodos = [ ...todos ];
const newTodos = [...todos];
newTodos.splice(index, 1);
setTodos(newTodos);
}

function toggleTodo(index: number) {
const newTodos = todos.map((todo, i) => {
if (i === index) {
return { content: todo.content, complete: !todo.complete };
return {
content: todo.content,
complete: !todo.complete,
schedule: todo.schedule,
priority: todo.priority,
};
}
return todo;
});


setTodos(newTodos);
}

return (
<div className="App bg-zinc-900 min-w-screen min-h-screen flex flex-col justify-center items-center gap-4">
<div className="flex gap-4 w-2/3">
<input
type="text"
placeholder="Enter todo"
onChange={(e) => setTodo(e.target.value)}
className="focus:outline-none bg-zinc-200 text-zinc-900 rounded-lg p-2 w-full"
/>
<button
onClick={() => addTodo()}
className="bg-zinc-200 text-zinc-900 rounded-lg p-2 px-4"
>
Add
</button>
<>
<div className="navBar">
<img src="webLogo.png" alt="" className="imgLogo"/>
<div className="webname">Todoist</div>
<div className="navBox">
<a href="">Home</a>
</div>
<div className="navBox">
<a href="">About</a>
</div>
<div className="navBox">
<a href="">Help</a>
</div>
</div>
<div className="todo-container flex flex-col justify-center gap-2 w-2/3">
{todos.map((todo, i) => (
<div key={i} className="flex justify-between items-center w-full">
<div className="flex gap-2 justify-center items-center">
<input
type="checkbox"
checked={todo.complete}
onChange={() => toggleTodo(i)}
/>
<p
className={`text-zinc-100 text-lg
${todo.complete && "line-through"}
`}
{/* <div className="circle1"></div>
<div className="circle2"></div>
<div className="circle3"></div>
<div className="circle4"></div> */}
<div className="App bg-zinc-900 min-w-screen min-h-screen flex flex-col justify-center items-center gap-4">
<div className="flex gap-4 w-2/3">
<input
type="text"
placeholder="Enter todo"
onChange={(e) => setTodo(e.target.value)}
className="focus:outline-none bg-zinc-200 text-zinc-900 rounded-lg p-2 w-full"
/>
<input
type="time"
placeholder="Enter Time"
onChange={(e) => setTime(e.target.value)}
className="focus:outline-none bg-zinc-200 text-zinc-900 rounded-lg p-2 w-full timeBox"
/>
<button
onClick={() => addTodo()}
className="bg-zinc-200 text-zinc-900 rounded-lg p-2 px-4"
>
Add
</button>
</div>
<div className="todo-container flex flex-col justify-center gap-2 w-2/3">
{todos.map((todo, i) => (
<div key={i} className="flex justify-between items-center w-full">
<div className={`flex gap-2 justify-center items-center parentDiv ${todo.priority && "bg-red-700 text-white"}`} >

<input
className="check"
type="checkbox"
checked={todo.complete}
onChange={() => toggleTodo(i)}
/>

<div className="todoBox">
<p
className={`text-zinc-100 text-lg
${todo.complete && "line-through"}
`}
>
{todo.content}
</p>
<p
className={`text-zinc-100 text-lg
${todo.complete && "line-through"}
`}
>
Scheduled Time: {todo.schedule}
</p>
</div>
</div>

<button
className="bg-red-500 px-4 py-2 rounded-lg"
onClick={() => removeTodo(i)}
>
Delete
</button>
<button
className="bg-red-500 px-4 py-2 rounded-lg"
onClick={() => editTodo(i)}
>
Edit
</button>
{/* <button
className="bg-red-500 px-4 py-2 rounded-lg"
onClick={() => shuffleTodo(i)}
>
{todo.content}
</p>
Shuffle
</button> */}
<button
className="bg-red-500 px-4 py-2 rounded-lg"
onClick={() => prioritizeTodo(i)}
>
Prioritize
</button>
</div>

<button className="bg-red-500 px-4 py-2 rounded-lg" onClick={() => removeTodo(i)}>Delete</button>
</div>
))}
))}
</div>
</div>
</div>
</>
);
}

Expand Down
44 changes: 44 additions & 0 deletions src/animation.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
.circle1{
background-color: yellow;
border-radius: 300px;
width: 30vw;
height: 30vw;
position: absolute;
z-index: 0;
opacity: 20%;
top: 15vh;
left: 10vw;
}
.circle2{
background-color: red;
border-radius: 300px;
width: 20vw;
height: 20vw;
position: absolute;
z-index: 0;
opacity: 20%;
top: 20vh;
left: 60vw;
}
.circle3{
background-color: white;
border-radius: 300px;
width: 17vw;
height: 17vw;
position: absolute;
z-index: 0;
opacity: 20%;
top: 13vh;
left: 7vw;
}
.circle4{
background-color: white;
border-radius: 300px;
width: 10vw;
height: 10vw;
position: absolute;
z-index: 0;
opacity: 20%;
top: 15vh;
left: 60vw;
}
40 changes: 40 additions & 0 deletions src/index.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,43 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
input{
z-index: 1;
}
button{
z-index: 1;
}
.timeBox{
width: 10vw;
}
.todoBox{
width: 30vw;
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
}
#editPopup{
display: none;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 50px;
}
/* .parentDiv{
background-color: col or;
} */
.check{
width: 25px;
height: 25px;
}
.imgLogo{
width: 50px;
height: 50px;
}
.webname{
font-size: 20px;
font-weight: 700;
color: rgb(80, 220, 255);
margin: 0 10px 0 5px;
}
22 changes: 22 additions & 0 deletions src/navbar.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.navBar{
background-color: rgb(48, 48, 48);
display: flex;
flex-direction: row;
flex-wrap: wrap;
/* justify-content: center; */
align-items: center;
/* width: 100vw; */
padding: 5px;

}
.navBox{
/* background-color: rgb(184, 184, 184); */
color: white;
padding: 10px;
/* margin: 0 0 0 2px; */
border-radius: 3px;
}
.navBox > a{
text-decoration: none;
color: white;
}
Loading