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

completed challenge (WISE) #229

Open
wants to merge 1 commit into
base: master
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
38 changes: 38 additions & 0 deletions todo/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>To do</title>
<link rel="stylesheet" href="styles.css">
</head>

<body>

<!-- container -->
<div class="container">
<!-- sections -->

<section class="addItems">
<h1>Get it Done!</h1>
<input></input>
<button onclick="addItem()"> Add to List</button>
</section>
<section class="toDO">
<!-- populate ul with todo list -->
<ul>

</ul>
</section>

<section class="clear">
<span class="dept"></span>
<button onclick="clrCompleted()">Clear Completed</button>
<button onclick="clearList()">Clear List</button>
</section>

</div>
<script src="script.js"></script>

</body>
</html>
39 changes: 39 additions & 0 deletions todo/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
let input = document.getElementsByTagName('input')[0];
let list = document.getElementsByTagName('ul')[0]


// add items
function addItem(){
let inputValue = input.value

if (inputValue == ''){
list.innerHTML += ``
}else {
list.innerHTML += `<li onclick="completed(event)" >${inputValue}</li>`
}
}

// clears list
function clearList(){
list.innerHTML = '';
}


// complete task

function completed(event){

event.target.classList.toggle ('completed')
}


// clear completed
// mentor helped. fin is an array like object so I have to iterate through it removing each one with .remove()

function clrCompleted(){
let fin = document.getElementsByClassName('completed')

while (fin.length > 0) {
fin[0].remove();
}
}
61 changes: 61 additions & 0 deletions todo/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/* universal */
* {
box-sizing: border-box;
}

/* container */

.container {
background-color: rgba(120, 117, 99, 0.731);
width: 30vw;
padding: 20px;
}


/* completed task */

.completed {
text-decoration: line-through;
}


/* background */

body{
background-color: beige;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}

li {
width: 100%;
background-color: rgb(226, 243, 243);
list-style: none;
margin: 0;
font-size: 1.3rem;
padding: 5px;


}


/* font colors */

h1{
color: rgb(75, 68, 60);
}

/* buttons */

button {
border-radius: 5px;
border: none;
padding: 5px;
}

/* clear completed */
.clearCompleted {
display: none;
}