Skip to content
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
47 changes: 47 additions & 0 deletions HW#1/project/css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
*{
margin: 0 auto;
padding: auto;

}
body{
background-color: #dedaeedd;
}
header{
display: grid;
grid-template-rows: 1fr;
justify-content: flex-end;
background-color: #cccc;
}
.btn-cart{
padding: 10px 50px;
background-color: #fff;
}
main{
display: grid;
grid-template-columns: 1fr;
}
.products{
display: grid;
grid-template-columns: 1fr 1fr;
grid-template-rows: 1fr;
}
.product-item{
border: 1px solid black;
display: block;
width: 350px;
height: 200px;
margin: 5px;
}
.product-item h3{
color: red;
font-size: 30px;
margin: 5px;
}
.product-item p{
font-weight: 600;
font-size: 18px;
margin-left: 10px;
}
button{
margin: 5px;
}

Choose a reason for hiding this comment

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

Принимаю стили

17 changes: 17 additions & 0 deletions HW#1/project/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="css/style.css">
<title>Title</title>
</head>
<body>
<header>
<button class="btn-cart">Cart</button>
</header>
<main>
<div class="products"></div>
</main>
<script src="js/main.js"></script>
</body>
</html>
26 changes: 26 additions & 0 deletions HW#1/project/js/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const data = [
{ title: 'Notebook', id: 1, price: 2000 },
{ title: 'Keyboard', id: 2, price: 200 },
{ title: 'Mouse', id: 3, price: 100 },
{ title: 'Gamepad', id: 4, price: 87 },
{ title: 'Новый Товар', id: 5 }
];
const renderProduct = (title, id, price = 'Цена товара', img = "https://placehold.it//150x100") => {

Choose a reason for hiding this comment

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

У вас опечатка в урле изображения, лишний слэш после .it - https://placehold.it/150x100 должно быть так.
Не согласен с аргументом по умолчанию для цены - у вас строка в качестве дефолтного значения price сейчас. А какой тип у этого аргумента мы ждем? Мы ждем число, и вот тут очень неявная история получается, во-первых читая код непонятно, что в итоге то будет попадать в price, судя по тому, что есть сейчас строка, а если смотреть уже на данные товаров - число. Во-вторых это может привести к проблемам в коде - допустим использовались бы какие-то явно зависимые от числовых значений методы, а по дефолту мы бы вдруг строку обрабатывали. В общем куда правильнее задавать дефолтные значения того же типа, который мы ожидаем получать реально.

return `
<div class="product-item">
<img src = "${img}" alt = "${title}">
<div>
<h3>${title}</h3>
<p>${price}</p>
<button>Купить</button>
</div>
</div>
`
};

const render = (products) => {
document.querySelector('.products').innerHTML = products.map(item => renderProduct(item.title, item.id, item.price)).join('');

Choose a reason for hiding this comment

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

По 3-му заданию все выполнено верно

};

render(data);
console.log(data)