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

Solicitação de merge? pra nova-versao #2

Open
wants to merge 4 commits into
base: nova-versao
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
8 changes: 4 additions & 4 deletions Projeto_Lista_Tarefas/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<header>
<div class="header-section">
<div class="logo-img">
<img src="/Projeto_Lista_Tarefas/Img/rocket.svg">
<img src="Img/rocket.svg">
</div>
<div class="logo-text">
<h1><span class="logo-color">to</span>do</h1>
Expand All @@ -37,7 +37,7 @@ <h1><span class="logo-color">to</span>do</h1>

<input type="text" id="search" class="input-search" placeholder="Adicione uma nova tarefa" value="">
<label for="search" class="label-search">
<button class="btn-search">Criar <img src="/Projeto_Lista_Tarefas/Img/plus.svg">
<button class="btn-search">Criar <img src="Img/plus.svg">
</button>
</label>

Expand Down Expand Up @@ -65,7 +65,7 @@ <h2>

<div class="no-tasks">
<div class="no-tasks-img">
<img src="/Projeto_Lista_Tarefas/Img/clipboard.svg">
<img src="Img/clipboard.svg">
</div>

<div class="no-tasks-text">
Expand All @@ -88,7 +88,7 @@ <h3>Você ainda não tem tarefas cadastradas</h3>
<h1>Feito por <a href="https://github.com/CiceroRMG">@cicerormg</a></h1>
</footer>

<script src="/Projeto_Lista_Tarefas/scripts/script.js"></script>
<script src="scripts/script.js" type="module"></script>
</body>

</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
export function createCheckbox() {
const input = document.createElement("input");
input.setAttribute("type", "checkbox");
input.classList.add("hidden");

const label = document.createElement("label");
label.classList.add("btn-main");
label.appendChild(input);

const imgUnselected = document.createElement("img");
imgUnselected.setAttribute("src", "Img/btn-not.svg");
const imgSelected = document.createElement("img");
imgSelected.setAttribute("src", "Img/btn-select.svg");
imgSelected.classList.add("hidden");

label.appendChild(imgSelected);
label.appendChild(imgUnselected);

function selectCheckbox() {
imgSelected.classList.remove("hidden");
imgUnselected.classList.add("hidden");
}

function unselectCheckbox() {
imgSelected.classList.add("hidden");
imgUnselected.classList.remove("hidden");
}

return {
elemento: label,
selectCheckbox: selectCheckbox,
unselectCheckbox: unselectCheckbox,
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export function addCreateTaskCount() {
const count = document.querySelector(".task-new-conta");
const oldValue = Number(count.innerHTML);
count.innerHTML = `${oldValue + 1}`;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@


export function addContadorConcluidas() {
const contadorConcluidas = document.querySelector(".task-conclude-conta");
const oldValue = Number(contadorConcluidas.innerHTML);
contadorConcluidas.innerHTML = `${oldValue + 1}`;
}

export function subContadorConcluidas() {
const contadorConcluidas = document.querySelector(".task-conclude-conta");
const oldValue = Number(contadorConcluidas.innerHTML);
contadorConcluidas.innerHTML = `${oldValue - 1}`;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export function getCountTasksCrated() {
const count = document.querySelector(".task-new-conta");
return Number(count.innerHTML);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export function subCreateTaskCount() {
const count = document.querySelector(".task-new-conta");
const oldValue = Number(count.innerHTML);
count.innerHTML = `${oldValue - 1}`;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export function createButtonTrash() {
const button = document.createElement("button");
button.classList.add("btn-trash");
const imgTrash = document.createElement("img");
imgTrash.setAttribute("src", "Img/trash.svg");
button.appendChild(imgTrash);

return button;
}
4 changes: 4 additions & 0 deletions Projeto_Lista_Tarefas/scripts/create-task/add-task-on-list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export function addTaskOnList(task) {
const taskList = document.querySelector(".tasks-main-text");
taskList.appendChild(task);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { createButtonTrash } from "../Trash-Button/createButtonTrash.js"
import { createDescriptionTask } from "./createDescriptionTask.js"
import { createCheckbox } from "../Check-Box/create-checkbox.js";
import { createListItem } from "./createListItens.js"
import {addContadorConcluidas} from "../Counter-Functions/contador-Concluidas.js"
import {subContadorConcluidas} from "../Counter-Functions/contador-Concluidas.js"
import {subCreateTaskCount} from "../Counter-Functions/subCreateTaskCount.js"
import {addNoTaskDiv} from "../no-taks-div/add-no-tasks.js"
import {getCountTasksCrated} from "../Counter-Functions/getCountTasksCreated.js"

export function createTaskNode(descripionTask) {
const listItem = createListItem();

const checkbox = createCheckbox();
const descriptionTask = createDescriptionTask(descripionTask);
const buttonTrash = createButtonTrash();

listItem.appendChild(checkbox.elemento);
listItem.appendChild(descriptionTask.elemento);
listItem.appendChild(buttonTrash);

checkbox.elemento.addEventListener("click", (event) => {
const isChecked = event.target.checked;
if (isChecked === true) {
checkbox.selectCheckbox();
descriptionTask.selectedDescriptionTask();
addContadorConcluidas();
} else if (isChecked === false) {
checkbox.unselectCheckbox();
descriptionTask.unselectedDescriptionTask();
subContadorConcluidas();
}
});

buttonTrash.addEventListener("click", (event) => {
const isChecked = descriptionTask.elemento.classList.contains("through");
if (isChecked) {
subContadorConcluidas();
}
listItem.remove();
subCreateTaskCount();

const countCreatedTasks = getCountTasksCrated();

if (countCreatedTasks === 0) {
addNoTaskDiv();
}
});

return listItem;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

export function createDescriptionTask(descripionTask) {
const span = document.createElement("span");
span.classList.add("main-input-user");
span.innerText = descripionTask;

function selectedDescriptionTask() {
span.classList.add("through");
}

function unselectedDescriptionTask() {
span.classList.remove("through");
}

return {
elemento: span,
selectedDescriptionTask: selectedDescriptionTask,
unselectedDescriptionTask: unselectedDescriptionTask,
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export function createListItem() {
const createListItem = document.createElement("li");
createListItem.classList.add("tasks-main-form");
return createListItem;
}
23 changes: 23 additions & 0 deletions Projeto_Lista_Tarefas/scripts/create-task/create-task.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { createTaskNode } from "./create-task-node/create-taks-node.js"
import { selectSearchInput } from "./select-search-input.js"
import { addTaskOnList } from "./add-task-on-list.js"
import { addCreateTaskCount } from "./Counter-Functions/addCreateTaskCount.js"
import { hiddenNoTaskDiv } from "./no-taks-div/hidden-no-tasks.js"

export function createTask(event) {
event.preventDefault();
const input = selectSearchInput();
const inputValue = input.value;

if (!inputValue) {
return console.log("Escreva alguma coisa");
}

const task = createTaskNode(inputValue);

addTaskOnList(task);
hiddenNoTaskDiv();
addCreateTaskCount();

input.value = "";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export function addNoTaskDiv() {
const noTaskDiv = document.querySelector(".no-tasks-section");
noTaskDiv.classList.remove("hidden");
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export function hiddenNoTaskDiv() {
const noTaskDiv = document.querySelector(".no-tasks-section");
noTaskDiv.classList.add("hidden");
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export function selectSearchInput() {
const input = document.querySelector(".input-search");
return input;
}
Loading