Skip to content

Commit 741f48e

Browse files
fix - otimizando codigo
1 parent cc2c260 commit 741f48e

File tree

2 files changed

+11
-104
lines changed

2 files changed

+11
-104
lines changed

Lista/css/style.css

Lines changed: 1 addition & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -9,35 +9,14 @@ body {
99
background-color: #f2f2f2;
1010
}
1111

12-
.title {
13-
text-transform: uppercase;
14-
text-shadow: 2px 2px 2px #0002;
15-
}
16-
17-
.title a {
18-
color: #d07335;
19-
}
20-
2112
.content-center {
2213
width: 100%;
2314
max-width: 300px;
2415
margin: auto;
2516
padding: 25px;
2617
background-color: #fff;
2718
border-radius: 15px;
28-
box-shadow: 6px 6px 6px #0004;
29-
}
30-
31-
.content-center .text-center {
32-
text-align: center;
33-
}
34-
35-
.content-center img {
36-
width: 70%;
37-
}
38-
39-
.content-center form {
40-
margin: 20px;
19+
box-shadow: 5px 5px 5px #0004;
4120
}
4221

4322
.content-center input,
@@ -57,12 +36,6 @@ body {
5736
border-bottom-color: #d07335;
5837
}
5938

60-
.content-center button {
61-
background-color: #d07335;
62-
color: #fff;
63-
border-radius: 5px;
64-
}
65-
6639
.content-center button:hover {
6740
background-color: #b55b28;
6841
cursor: pointer;
@@ -72,68 +45,6 @@ body {
7245
background-color: #c14e0e;
7346
}
7447

75-
header a {
76-
color: #666;
77-
text-decoration: none;
78-
}
79-
80-
header a:visited {
81-
color: #000;
82-
}
83-
84-
header a:hover {
85-
text-decoration: underline;
86-
}
87-
88-
header h1 {
89-
font-size: 2.5em;
90-
text-align: center;
91-
margin: 50px auto;
92-
}
93-
94-
footer {
95-
font-size: 0.8em;
96-
text-align: center;
97-
margin: 20px auto;
98-
}
99-
100-
101-
.content-tab {
102-
width: 100%;
103-
text-align: center;
104-
max-width: 500px;
105-
background-color: #fff;
106-
margin: auto;
107-
padding: 20px;
108-
border-radius: 15px;
109-
box-shadow: 5px 5px 5px #0004;
110-
}
111-
112-
.content-tab table {
113-
width: 100%;
114-
border-collapse: collapse;
115-
}
116-
117-
.content-tab td {
118-
padding: .75em;
119-
border-top: 1px solid #dee2e6;
120-
}
121-
122-
.content-tab tbody tr:nth-child(odd) {
123-
background-color: rgba(0, 0, 0, .05);
124-
}
125-
126-
.content-tab tbody tr:hover {
127-
background-color: rgba(0, 0, 0, .15);
128-
cursor: pointer;
129-
}
130-
131-
#valueA {
132-
width: 100%;
133-
padding: 10px;
134-
}
135-
136-
13748
.todo {
13849
list-style: none;
13950
padding: 0;
@@ -167,7 +78,3 @@ footer {
16778
width: 100%;
16879
padding: 10px;
16980
}
170-
171-
.up {
172-
text-transform: uppercase;
173-
}

Lista/js/script.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
let data = []
22

3-
function renderTodo() {
3+
function renderTodo()
4+
{
45
document.querySelector('.todo').innerHTML = ''
6+
57
data.forEach(task => {
68
let li = document.createElement('li')
79
li.innerHTML =
@@ -10,28 +12,25 @@ function renderTodo() {
1012
<label for="task-${task.id}">${task.title}</label>
1113
<button type="button">X</button>
1214
`
15+
1316
li.querySelector('input').addEventListener('change', e => {
14-
1517
if (e.target.checked) {
1618
li.classList.add('complete')
1719
} else {
1820
li.classList.remove('complete')
1921
}
20-
2122
})
23+
2224
li.querySelector('button').addEventListener('click', e => {
23-
let btn = e.target
24-
let li = btn.parentNode
25-
let input = li.querySelector('input')
26-
let id = input.id
27-
let idArray = id.split('-')
28-
let todoId = idArray[1]
25+
let btn = e.target.parentNode.querySelector('input').id.split('-')[1]
2926
let title = li.querySelector('label').innerText
27+
3028
if (confirm(`Deseja realmente excluir a tarefa ${title} ?`)) {
31-
data = data.filter(task => task.id !== parseInt(todoId))
29+
data = data.filter(task => task.id !== parseInt(btn))
3230
renderTodo()
3331
}
3432
})
33+
3534
document.querySelector('.todo').append(li)
3635
})
3736
}
@@ -42,6 +41,7 @@ document.querySelector('#new-task').addEventListener('keyup', e => {
4241
id: data.length + 1,
4342
title: e.target.value
4443
})
44+
4545
e.target.value = ''
4646
renderTodo()
4747
}

0 commit comments

Comments
 (0)