Skip to content

Commit e244a9a

Browse files
committed
update design
1 parent ec7bf34 commit e244a9a

File tree

6 files changed

+102
-28
lines changed

6 files changed

+102
-28
lines changed

src/css/style.css

Lines changed: 48 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,34 @@ body {
22
min-width: 420px;
33
}
44

5+
a {
6+
color: #20786a;
7+
cursor: pointer;
8+
}
9+
510
a:hover {
611
text-decoration: none;
12+
color: #20786a;
13+
opacity: 0.8;
14+
}
15+
16+
svg {
17+
width: 32px;
18+
height: 32px;
19+
}
20+
21+
.table td {
22+
vertical-align: middle;
23+
}
24+
25+
.main__container {
26+
padding: 30px;
27+
border-radius: 20px;
28+
background-color: #f3ecd77d;
729
}
830

931
.header {
10-
background-color: #3E5E93;
32+
background-color: #81a7a1;
1133
color: #fff;
1234
margin-bottom: 40px;
1335
padding: 20px 0;
@@ -49,9 +71,31 @@ a:hover {
4971
margin-bottom: 30px;
5072
}
5173

74+
.btn-add {
75+
background-color: #b8d7d2;
76+
}
77+
78+
.btn-del,
79+
.btn-cancel {
80+
background-color: #ffbe70;
81+
}
82+
83+
.btn-edit {
84+
padding-left: 0;
85+
}
86+
87+
.btn-edit:focus,.btn-edit:active {
88+
outline: none !important;
89+
box-shadow: none;
90+
}
91+
92+
.select-line {
93+
background-color: rgba(255, 207, 98, 0.27) !important;
94+
}
95+
5296
.form {
5397
padding: 30px 50px;
54-
background-color: #fff;
98+
background-color: #fff8e3;
5599
border-bottom-left-radius: 4px;
56100
border-bottom-right-radius: 4px;
57101
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
@@ -118,7 +162,7 @@ a:hover {
118162
}
119163

120164
.th-cell:hover {
121-
color: #007bff;
165+
color: #81a7a1;
122166
}
123167

124168
.del-icon:hover,
@@ -132,7 +176,7 @@ a:hover {
132176
left: 0;
133177
right: 0;
134178
padding: 10px;
135-
background-color: #3E5E93;
179+
background-color: #81a7a1;
136180
color: #fff;
137181
text-align: center;
138182
}
@@ -141,10 +185,6 @@ a:hover {
141185
.cell-phone {
142186
gap: 15px;
143187
}
144-
145-
.button-edit {
146-
font-size: .8em;
147-
}
148188
}
149189

150190
@media (max-width: 720px) {

src/img/edit.svg

Lines changed: 1 addition & 0 deletions
Loading

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,5 @@ const {
4949
editContactControl(list);
5050
};
5151

52-
init('#app', 'Надежда');
52+
init('#app', '');
5353
}

src/script/control.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ const modalControl = (buttonAdd, formOverlay) => {
4545

4646
formOverlay.addEventListener('click', e => {
4747
const target = e.target;
48-
if (target === formOverlay || target.closest('.close')) {
48+
if (target === formOverlay ||
49+
target.closest('.close') ||
50+
target.closest('.btn-cancel')
51+
) {
4952
closeModal();
5053
}
5154
});
@@ -59,11 +62,12 @@ const modalControl = (buttonAdd, formOverlay) => {
5962

6063
const sortContacts = (cellSelector, list, isAscending) => {
6164
const allData = [];
62-
63-
[...list.querySelectorAll('.contact')].forEach(row => {
64-
const textContent = row.querySelector(cellSelector).textContent;
65-
allData.push({data: textContent, row});
66-
});
65+
if (cellSelector) {
66+
[...list.querySelectorAll('.contact')].forEach(row => {
67+
const textContent = row.querySelector(cellSelector).textContent;
68+
allData.push({data: textContent, row});
69+
});
70+
}
6771

6872
const newIsAscending = isAscending === undefined ? true : isAscending;
6973

@@ -176,7 +180,7 @@ const handleBlur = (contactRow) => {
176180
const isValidSurname = isValidText(newSurname);
177181
const isValidPhone = isValidPhoneNumber(newPhone);
178182

179-
contactRow.classList.remove('table-primary');
183+
contactRow.classList.remove('select-line');
180184
nameCell.contentEditable = false;
181185
surnameCell.contentEditable = false;
182186
phoneCell.contentEditable = false;
@@ -222,7 +226,7 @@ const handleEditButton = (e) => {
222226
const prevSurname = surnameCell.textContent;
223227
const prevPhone = phoneHref.textContent;
224228

225-
contactRow.classList.add('table-primary');
229+
contactRow.classList.add('select-line');
226230

227231
nameCell.contentEditable = true;
228232
surnameCell.contentEditable = true;
@@ -252,7 +256,7 @@ const handleEditButton = (e) => {
252256
const editContactControl = (list) => {
253257
list.addEventListener('click', e => {
254258
const target = e.target;
255-
const closestEditButton = target.closest('.button-edit');
259+
const closestEditButton = target.closest('.btn-edit');
256260

257261
if (closestEditButton) {
258262
handleEditButton(e);

src/script/createElements.js

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
const createContainer = () => {
1+
const createContainer = (className) => {
22
const container = document.createElement('div');
33
container.classList.add('container');
44

5+
if (className) {
6+
container.classList.add(className);
7+
}
8+
59
return container;
610
};
711

@@ -27,7 +31,7 @@ const createLogo = (title) => {
2731

2832
const createMain = () => {
2933
const main = document.createElement('main');
30-
const mainContainer = createContainer();
34+
const mainContainer = createContainer('main__container');
3135

3236
main.append(mainContainer);
3337
main.mainContainer = mainContainer;
@@ -39,11 +43,17 @@ const createButtonsGroup = (params) => {
3943
const btnWrapper = document.createElement('div');
4044
btnWrapper.classList.add('btn-wrapper');
4145

42-
const buttons = params.map(({className, type, text}) => {
46+
const buttons = params.map(({className, type, text, svg}) => {
4347
const button = document.createElement('button');
4448
button.className = className;
4549
button.type = type;
46-
button.textContent = text;
50+
if (svg) {
51+
const svgElement = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
52+
svgElement.innerHTML = svg;
53+
button.appendChild(svgElement);
54+
} else {
55+
button.textContent = text;
56+
}
4757

4858
return button;
4959
});
@@ -111,12 +121,12 @@ const createForm = () => {
111121

112122
const buttonsGroup = createButtonsGroup([
113123
{
114-
className: 'btn btn-primary mr-3',
124+
className: 'btn btn-add mr-3',
115125
type: 'submit',
116126
text: 'Добавить',
117127
},
118128
{
119-
className: 'btn btn-danger',
129+
className: 'btn btn-cancel',
120130
type: 'reset',
121131
text: 'Отмена',
122132
},
@@ -161,9 +171,28 @@ const createRow = ({name: firstName, surname, phone}) => {
161171

162172
const buttonsGroup = createButtonsGroup([
163173
{
164-
className: 'btn btn-primary button-edit',
174+
className: 'btn btn-edit',
165175
type: 'button',
166-
text: 'Редактировать',
176+
svg: `<svg viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg"
177+
xmlns:xlink="http://www.w3.org/1999/xlink"><linearGradient id="linear-gradient"
178+
gradientUnits="userSpaceOnUse"
179+
x1="2" x2="29.478" y1="16.276" y2="16.276">
180+
<stop offset="0" stop-color="#0fdcdd"></stop>
181+
<stop offset="1" stop-color="#46a1e8"></stop>
182+
</linearGradient>
183+
<g id="_23_Edit" data-name="23 Edit">
184+
<path d="m28.6 4.17-.77-.77a3.075 3.075 0 0 0 -4.24 0l-4.6 4.6
185+
h-13.99a3.009 3.009 0 0 0 -3 3v16a3.009 3.009 0 0 0 3 3
186+
h16a3.009 3.009 0 0 0 3-3v-13.99l4.6-4.6a3 3 0 0 0 0-4.24
187+
zm-2.18.64.77.77a1.008 1.008 0 0 1 0 1.42l-.353.353-2.19-2.19.353-.353
188+
a1.047 1.047 0 0 1 1.42 0zm-3.188 1.768 2.19 2.19-11.522 11.523
189+
-2.19-2.19zm-12.663 13.211 1.542 1.542-2.831 1.079zm11.431 7.211
190+
a1 1 0 0 1 -1 1h-16a1 1 0 0 1 -1-1v-16a1 1 0 0 1 1-1
191+
h11.99l-7.39 7.388-.01.012-.008.012-.012.012a.831.831 0 0 0
192+
-.19.26l-3.03 6.136a1 1 0 0 0 1.26 1.37l6.62-2.53a.929.929 0 0 0 .35
193+
-.23l.012-.012.012-.008.008-.012 7.388-7.388z"
194+
fill="url(#linear-gradient)" style="fill: rgb(87, 137, 122);">
195+
</path></g></svg>`,
167196
},
168197
]);
169198

src/script/render.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ export const renderPhoneBook = (app, title) => {
2020
const main = createMain();
2121
const buttonsGroup = createButtonsGroup([
2222
{
23-
className: 'btn btn-primary mr-3 btn-add',
23+
className: 'btn mr-3 btn-add',
2424
type: 'button',
2525
text: 'Добавить',
2626
},
2727
{
28-
className: 'btn btn-danger',
28+
className: 'btn btn-del',
2929
type: 'button',
3030
text: 'Удалить',
3131
},

0 commit comments

Comments
 (0)