Skip to content

Conversation

epent
Copy link

@epent epent commented May 17, 2022

No description provided.

.task-input-wrapper {
display: flex;
justify-content: space-between;
margin-bottom: 15px;

Choose a reason for hiding this comment

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

As the relative positioning goes from left to right and top to bottom, it's a better practice to control the element's position against the existing dom on the top & left, thus using margin-left/margin-top instead of positioning the next set of elements (right-bottom).

}

.task-button {
margin-right: 25px;

Choose a reason for hiding this comment

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

good job on reusing the button class!

position: absolute;
width: 35%;
left: 25px;
top: 540px;

Choose a reason for hiding this comment

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

The positioning here (absolute against the whole page) will be difficult to maintain, as almost any change to the layout will require adjusting the positions. look for other ways to position the footer part of the app

Can't wait when you add your first task!
</h2>
</ul>
<button id="sort-by-name-button" class="task-button hidden">

Choose a reason for hiding this comment

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

you might want to wrap the sort & clear all buttons with a footer container to easier positioning

const addTaskButton = document.querySelector(".task-button");
const addTaskInput = document.querySelector(".task-input");
const clearAllButton = document.querySelector("#clear-all-button");
const sortByNameButton = document.querySelector("#sort-by-name-button");

Choose a reason for hiding this comment

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

having all the elements outside here requires all the dom elements to exist when this file is loaded, which might not be the case in complex web apps that dynamically change the dom depending on the view

<body>
<div class="white-box">
<h1 class="main-header">Task Manager</h1>
<div class="task-input-wrapper">

Choose a reason for hiding this comment

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

nice dom modeling!

</button>
</div>
<ul class="task-list">
<div id="triangle" class="triangle"></div>
Copy link

@SergeiSafrigin SergeiSafrigin May 27, 2022

Choose a reason for hiding this comment

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

The "ul" should only have "li" direct children


function hideWelcomePart() {
addButton.classList.remove("hithere");
clearAllButton.classList.remove("hidden");
Copy link

@SergeiSafrigin SergeiSafrigin May 27, 2022

Choose a reason for hiding this comment

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

Moving the welcome page into its own container (maybe with a shared class for some of the styles) will make your life easier here - 1 line of code instead of 6. Also in the current state, every new element you'll add to the task-list container will require you to handle it here as well

function showWelcomePart() {
addButton.classList.add("hithere");
clearAllButton.classList.add("hidden");
sortByNameButton.classList.add("hidden");

Choose a reason for hiding this comment

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

same here :)

liElm.addEventListener("click", () => alert(`Task: ${text}`));

//clear input
document.querySelector(".task-input").value = "";

Choose a reason for hiding this comment

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

could be moved into it's own function

//add ids
const idText = text.split(" ").join("-");
divElm.setAttribute("id", `${idText}`);
deleteButton.setAttribute("id", `${idText}-button`);

Choose a reason for hiding this comment

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

can be dangerous as these ids are not unique.


//remove <div> with task
const divElementId = buttonId.join("-");
document.querySelector(`#${divElementId}`).remove();
Copy link

@SergeiSafrigin SergeiSafrigin May 27, 2022

Choose a reason for hiding this comment

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

consider eaither using unique ids for the tasks. You could use UUID or traverse the dom from the target up until you find the task (target.parentElement)

const elementIndex = listOfTasks.findIndex((task) => {
return task === taskText;
});
listOfTasks.splice(elementIndex, 1);

Choose a reason for hiding this comment

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

Bug: removing a task with a not unique name might not remove the one the user wanted. Consider making each task a complex object with id and text properties.

}

function sortByName() {
listOfTasks.forEach((task) => {

Choose a reason for hiding this comment

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

duplication, consider moving it into it's own function

listOfTasks.sort();
console.log(listOfTasks);

listOfTasks.forEach((task) => {

Choose a reason for hiding this comment

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

nice!

}

function capitalize(string) {
const updatedString = string.charAt(0).toUpperCase() + string.slice(1);

Choose a reason for hiding this comment

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

like!

}

function createTask(text) {
//create elements

Choose a reason for hiding this comment

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

good job on the separation of concerns between the functions!

Copy link

@SergeiSafrigin SergeiSafrigin left a comment

Choose a reason for hiding this comment

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

See comments for ex1


.task-list {
display: flex;
flex-direction: column;

Choose a reason for hiding this comment

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

Visual bug: There is no scroll, so if I add too many tasks it overflows

image

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