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

Pr exc1 #26

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Pr exc1 #26

wants to merge 3 commits into from

Conversation

amirbardugo
Copy link

No description provided.

/>
<div class="style">
<head>
<title>Exercise 1</title>
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should choose your own title so the tab name won't be just exercise 1

Comment on lines +25 to +26
<div id="listToDo" class="listToDo"></div>
<div id="footer" class="footer">
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't have to give id and class to all of your elements, usually id makes more sense when you are sure you'll have only one of this element and you want to access it easily from js, in that case the class is quite redundant here

@@ -0,0 +1,64 @@
const listToDo = document.querySelector(".listToDo");
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you didn't implement the alert when clicking on a task

Comment on lines +1 to +5
const listToDo = document.querySelector(".listToDo");
const count = document.querySelector(".count");
const buttonClearAll = document.querySelector(".buttonClearAll");
const newToInput = document.querySelector(".newToInput");
const buttonAdd = document.querySelector(".buttonAdd");
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you have id's on some of them might be better to use the id as the selector - i.e "#listToDo"

var removeSVG = '<i class="fa fa-trash"></i>';
count.textContent = 0;

clickButtonClearAll();
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you need to call it on initialization?

}
}

function add() {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try to give some more indicative name to the functions, when things will start to get complicated it will help you (and whoever will read your code) a lot

}

function add() {
if (document.querySelector("#newToDo input").value.length == 0) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are querying this element a lot, its better to do it once at the start and use some const like you did with other elements, this is better in terms of performance (the browser doesn't have to search for that element over and over again) and in terms of later changes and refactors, you'll have only one place the depends on the input id

Comment on lines +52 to +55
this.parentNode.style.opacity = "0";
count.textContent--;
clickButtonClearAll();
setTimeout(() => this.parentNode.remove()(), 200);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is that for the animation? cool idea but it introduce a bug, if I double click remove button the counter is getting out of sync and you can get to this situation
image

}
}

function clickButtonClearAll() {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if i had to guess by the function name I would say that this is what happens when you click the clear all,
I would go with something like setIsActiveClearButton

Comment on lines +251 to +266
@media screen and (max-width: 100px) {
.col-10,
.col-90,
input[type="submit"] {
width: 30%;
margin-top: 0;
}
}
@media (min-width: 100px) {
.style {
margin-right: 100px;
width: 100%;
height: 100vh;
background-image: linear-gradient(120deg, lightblue, rgb(45, 111, 133));
}
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you know what is it? do you need it?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall it seems like a lot of the CSS here is not relevant and copied, its great to get inspired but we usually want to be in max control and understanding of each line in our code,
we don't want to have redundant code that is not in use or we even don't know its purpose

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants