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
Binary file added Shop/img/default.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions Shop/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Интернет-магазин</title>
<link rel="stylesheet" href="styles/main.css">
</head>
<body>
<header>
<button class="btn-cart" type="button">Корзина</button>
</header>
<main>
<div class="products"></div>
</main>
<script src="./js/main.js"></script>
</body>
</html>

25 changes: 25 additions & 0 deletions Shop/js/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const products = [
{id: 1, title: 'Notebook', price: 20000},
{id: 2, title: 'Mouse', price: 1500},
{id: 3, title: 'Keyboard', price: 5000},
{id: 4, title: 'Gamepad', price: 4500},
];

const renderProduct = ({title, price} , img = 'img/default.jpg') => {
return `<div class="product-item">
<img src="${img}" alt="${title}">
<h3>${title}</h3>
<p>${price}</p>
<button class="by-btn">Добавить в корзину</button>
</div>`;
};

const renderProducts = list => {
//const productList = list.map( product => renderProduct(product) );
const productList = list.map( product => {
return renderProduct(product);
});
document.querySelector('.products').innerHTML = productList.join(' ');
}

renderProducts(products);
61 changes: 61 additions & 0 deletions Shop/styles/main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
* {
margin: 0;
padding: 0;
}

header {
min-height: 60px;
background-color: aqua;
position: relative;
}

.btn-cart {
position: absolute;
display: block;
right: 12px;
top: 10px;
width: 90px;
height: 40px;

}

.products {
min-height: 100px;
border: 1px solid black;
}

.product-item {
margin: 15px 15px;
background-color: azure;
border: 1px solid black;
box-shadow: 0 0 10px rgba(0,0,0,0.5);
}

.product-item img {
display: block;
max-height: 100px;
margin: 10px 10px;
float: left;
border-radius: 10%;
}

.product-item h3 {
text-align: center;
margin-top: 10px;
font-style: oblique;
}

.product-item p {
text-align: center;
margin-top: 10px;
color: royalblue;
font-style: italic;
}

.product-item .by-btn {
display: block;
text-align: center;
height: 40px;
width: 150px;
margin: 10px auto;
}