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

Revert "Milestone 2: Add, Edit and Remove functionalities" #4

Merged
merged 3 commits into from Jun 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Binary file removed dist/667a1805229ae33e7d3d.png
Binary file not shown.
265 changes: 0 additions & 265 deletions dist/add.bundle.js

This file was deleted.

229 changes: 0 additions & 229 deletions dist/addTaskUI.bundle.js

This file was deleted.

246 changes: 28 additions & 218 deletions dist/index.bundle.js

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions dist/index.html
Expand Up @@ -4,16 +4,16 @@
<meta charset="utf-8">
<title>To Do List</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script defer src="index.bundle.js"></script><script defer src="add.bundle.js"></script><script defer src="remove.bundle.js"></script><script defer src="addTaskUI.bundle.js"></script><script defer src="tasks.bundle.js"></script></head>
<script defer src="index.bundle.js"></script></head>
<body>
<main><div class="listContainer">
<div class="title"><h3>Today's To Do</h3><img class = 'imgRefresh' alt = 'refresh' src = '2a4441e2b7ef51d897cb.png'></div>
<div class="title"><h3>Today's To Do</h3><img class = 'imgRefresh' alt = 'refresh' src = '../src/refresh.png'></div>
<form class = "addTask">
<input type="text" placeholder="Add to your list..." class = 'add'>
<input type="submit" value = '' class = "submit"><img class = 'imgSubmit' alt = 'return' src = 'e776f112fe439b59d722.png'>
<input type="text" placeholder="Add to your list...">
<input type="submit" value = '' class = "submit"><img class = 'imgSubmit' src = '../src/return.png' alt = 'return'>
</form>
<ul class="to-do-list"></ul>
<div class="clear">Clear all completed</div>
</div></main>
</body>
</html>
</html>
66 changes: 0 additions & 66 deletions dist/remove.bundle.js

This file was deleted.

54 changes: 0 additions & 54 deletions dist/tasks.bundle.js

This file was deleted.

24 changes: 0 additions & 24 deletions src/add.js

This file was deleted.

66 changes: 0 additions & 66 deletions src/addTaskUI.js

This file was deleted.

6 changes: 3 additions & 3 deletions src/index.html
Expand Up @@ -9,11 +9,11 @@
<main><div class="listContainer">
<div class="title"><h3>Today's To Do</h3><img class = 'imgRefresh' alt = 'refresh' src = '../src/refresh.png'></div>
<form class = "addTask">
<input type="text" placeholder="Add to your list..." class = 'add'>
<input type="submit" value = '' class = "submit"><img class = 'imgSubmit' alt = 'return' src = '../src/return.png'>
<input type="text" placeholder="Add to your list...">
<input type="submit" value = '' class = "submit"><img class = 'imgSubmit' src = '../src/return.png' alt = 'return'>
</form>
<ul class="to-do-list"></ul>
<div class="clear">Clear all completed</div>
</div></main>
</body>
</html>
</html>
56 changes: 24 additions & 32 deletions src/index.js
@@ -1,43 +1,35 @@
import './style.css';
import moveSrc from './move.png';
import refreshSrc from './refresh.png';
import returnSrc from './return.png';
import {
addTask,
list,
} from './add.js';
import clearTask from './remove.js';
import appendTask from './addTaskUI.js';
import Task from './tasks.js';

const storage = JSON.parse(localStorage.getItem('tasks')) || [];
const addUI = document.querySelector('.add');
const deleteUI = document.querySelector('.clear');
const returnImg = document.querySelector('.imgSubmit');
returnImg.src = returnSrc;

const refreshImg = document.querySelector('.imgRefresh');
refreshImg.src = refreshSrc;

storage.forEach((item) => {
const task = new Task(item.description, item.completed, item.index);
list.push(task);
appendTask(task, list);
});
const toDoListUI = document.querySelector('.to-do-list');

returnImg.src = returnSrc;
refreshImg.src = refreshSrc;
class Task {
constructor(description, completed, index) {
this.description = description;
this.completed = completed;
this.index = index;
}
}

addUI.addEventListener('change', () => {
addTask(addUI.value, false, list.length + 1);
});
const list = [new Task('Finsh the project', false, 0), new Task('Wash the dishes', false, 1), new Task('Go on zoom meeting', false, 2)];

refreshImg.addEventListener('click', () => {
document.location.href = './index.html';
});
const appendTask = (item) => {
const taskUI = document.createElement('li');
taskUI.innerHTML = `<label><input type='checkbox' id = task-${item.index} class = 'check' value=${item.index}>${item.description}</label>`;
const moveImg = new Image();
moveImg.src = moveSrc;
taskUI.appendChild(moveImg);
toDoListUI.appendChild(taskUI);
};

deleteUI.addEventListener('click', () => {
const checks = document.querySelectorAll('.check');
for (let i = 0; i < checks.length; i += 1) {
if (checks[i].checked) {
clearTask(checks[i].value, list);
}
}
localStorage.setItem('tasks', JSON.stringify(list));
});
for (let i = 0; i < list.length; i += 1) {
appendTask(list[i]);
}
20 changes: 0 additions & 20 deletions src/remove.js

This file was deleted.

20 changes: 0 additions & 20 deletions src/style.css
Expand Up @@ -35,10 +35,6 @@ main {
border: none;
}

.addTask > input:focus {
outline: none !important;
}

.submit {
background-color: inherit;
}
Expand All @@ -60,20 +56,6 @@ main {
justify-content: space-between;
}

.to-do-list > * > div {
display: flex;
align-items: center;
}

.to-do-list > * > div > p {
white-space: nowrap;
}

.to-do-list > * > div > p:focus {
outline: none !important;
white-space: nowrap;
}

.check {
margin-right: 10px;
}
Expand All @@ -82,7 +64,6 @@ img {
width: 20px;
height: 20px;
background: inherit;
cursor: pointer;
}

.clear {
Expand All @@ -91,5 +72,4 @@ img {
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
}