Skip to content

Commit 52dfead

Browse files
author
ToryaToria
committed
refactor(extended-2.1): change classes using BEM methodology
1 parent 3a99c48 commit 52dfead

File tree

3 files changed

+34
-31
lines changed

3 files changed

+34
-31
lines changed

app.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ var createNewTaskElement=function(taskString){
3333
var deleteButtonImg=document.createElement("img");//delete button image
3434

3535
label.innerText=taskString;
36-
label.className='task';
36+
label.className='tasks__field';
3737

3838
//Each elements, needs appending
3939
checkBox.type="checkbox";
4040
editInput.type="text";
41-
editInput.className="task";
41+
editInput.className="tasks__field";
4242

4343
editButton.innerText="Edit"; //innerText encodes special characters, HTML does not.
4444
editButton.className="edit";

index.html

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,34 @@
1212
</head>
1313

1414
<body>
15-
<header class="header"><img src="./eisenhower-matrix.jpg" alt="eisenhower matrix">
16-
<a class="more-information" href="https://goal-life.com/page/method/matrix-eisenhower">
15+
<header class="header">
16+
<img class="header__img" src="./eisenhower-matrix.jpg" alt="eisenhower matrix">
17+
<a class="header__more-information" href="https://goal-life.com/page/method/matrix-eisenhower">
1718
Want more details?
1819
</a>
1920
</header>
2021

2122
<main>
22-
<section>
23-
<div class="centered-wrapper">
24-
<h1 class="title">Todo</h1>
25-
<div class="add-wrapper">
26-
<h3>
27-
<label for="new-task">Add Item</label>
28-
</h3>
29-
<div class="task-row-wrapper">
30-
<input id="new-task" class="task" type="text">
23+
<section class="tasks">
24+
<div class="tasks__centered-wrapper">
25+
<h1 class="tasks__main-title">Todo App</h1>
26+
27+
<div class="tasks__add-wrapper">
28+
<h2>
29+
<label class="tasks__title" for="new-task">Add Item</label>
30+
</h2>
31+
<div class="tasks__row-wrapper">
32+
<input id="new-task" class="tasks__field" type="text">
3133
<button>Add</button>
3234
</div>
3335
</div>
3436

35-
<h2>Todo</h2>
37+
<h2 class="tasks__title">Todo</h2>
3638
<ul id="incomplete-tasks">
3739
<li>
3840
<input type="checkbox">
39-
<label class="task">Pay Bills</label>
40-
<input type="text" class="task">
41+
<label class="tasks__field">Pay Bills</label>
42+
<input type="text" class="tasks__field">
4143
<button class="edit">Edit</button>
4244
<button class="delete">
4345
<img src="./remove.svg" alt="remove">
@@ -46,21 +48,22 @@ <h2>Todo</h2>
4648

4749
<li class="edit-mode">
4850
<input type="checkbox">
49-
<label class="task">Go Shopping</label>
50-
<input type="text" value="Go Shopping" class="task">
51+
<label class="tasks__field">Go Shopping</label>
52+
<input type="text" value="Go Shopping" class="tasks__field">
5153
<button class="edit">Save</button>
5254
<button class="delete">
5355
<img src="./remove.svg" alt="remove">
5456
</button>
5557
</li>
5658

5759
</ul>
58-
<h2>Completed</h2>
60+
<h2 class="tasks__title">Completed</h2>
5961
<ul id="completed-tasks">
6062
<li>
6163
<input type="checkbox" checked>
62-
<label class="task">See the Doctor</label>
63-
<input type="text" class="task"><button class="edit">Edit</button>
64+
<label class="tasks__field">See the Doctor</label>
65+
<input type="text" class="tasks__field">
66+
<button class="edit">Edit</button>
6467
<button class="delete">
6568
<img src="./remove.svg" alt="remove">
6669
</button>

style.css

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ body {
55
font-family: Lato, sans-serif;
66
}
77

8-
.title {
8+
.tasks__main-title {
9+
font-size: 0;
910
width: 0;
1011
line-height: 0;
1112
}
1213

13-
.add-wrapper {
14+
.tasks__add-wrapper {
1415
margin-top: 16px;
1516
margin-bottom: 16px;
1617
}
@@ -22,11 +23,11 @@ line-height: 0;
2223
text-align: right;
2324
}
2425

25-
.header img {
26+
.header__img {
2627
width: 100%;
2728
}
2829

29-
.header .more-information {
30+
.header__more-information {
3031
font-family: fantasy, cursive;
3132
}
3233

@@ -36,19 +37,19 @@ line-height: 0;
3637
}
3738
}
3839

39-
.centered-wrapper {
40+
.tasks__centered-wrapper {
4041
display: block;
4142
width: 500px;
4243
margin: 0 auto 0;
4344
}
4445

45-
.task {
46+
.tasks__field {
4647
width: 56%;
4748
display: inline-block;
4849
flex-grow: 1;
4950
}
5051

51-
.task-row-wrapper {
52+
.tasks__row-wrapper {
5253
display: flex;
5354
}
5455

@@ -58,7 +59,7 @@ ul {
5859
}
5960

6061
li,
61-
h2 {
62+
.tasks__title {
6263
list-style: none;
6364
}
6465

@@ -82,8 +83,7 @@ button:hover {
8283
}
8384

8485
/* Heading */
85-
h2,
86-
label[for="new-task"] {
86+
.tasks__title {
8787
color: #333;
8888
font-weight: 700;
8989
font-size: 15px;

0 commit comments

Comments
 (0)