Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HW1_fin #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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 image/defGoods.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions index.htm
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<link rel="stylesheet" href="style/style.css">

<title>Document</title>
</head>
<body>
<header>
<div class="container">
<button class="cartButton header__cartButton" type="button">Корзина</button>
</div>
</header>

<main>
<div class="container">
<div class="goodsList"></div>
</div>
</main>


<script src="script/main.js"></script>
</body>
</html>
36 changes: 36 additions & 0 deletions script/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"use strict";

const goods = [
{ title: 'Shirt', price: 150 },
{ title: 'Socks', price: 50 },
{ title: 'Jacket', price: 350 },
{ title: 'Shoes', price: 250 },
{ },
{ },
{ },
{ },
{ },
{ },
{ },
{ },
{ }
];

const renderGoodsItem = (title = 'Товар закончился', price = '0') =>
`<div class='goodsItem'>
<img src='image/defGoods.png' alt='good'>
<h3>${title}</h3>
<p>${price}$</p>
<button class="cartButtonAdd" type="button">Добавить</button>
</div>`;

const renderGoodsList = list => {
let goodsList = list.map(item => renderGoodsItem(item.title, item.price));
document.querySelector('.goodsList').innerHTML = goodsList.join('');
};

renderGoodsList(goods);




5 changes: 5 additions & 0 deletions style/scss/_elements.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.cartButton,
.cartButtonAdd {
padding: 4px 8px;
border-radius: 8px;
}
13 changes: 13 additions & 0 deletions style/scss/_header.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* Стили header */
header {
.container {
border: 1px solid black;
padding: 8px 32px;
display: flex;
justify-content:flex-end;
}

&__cartButton {
margin-left: auto;
}
}
29 changes: 29 additions & 0 deletions style/scss/_main.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/* Стили main */
main {
.container {
padding: 32px;
}

.goodsList {
display: grid;
grid-template-columns: repeat(6, 1fr);
gap: 16px;
}

.goodsItem {
border: 1px solid black;
border-radius: 8px;
padding: 16px;
text-align: right;

img {
max-width: 100%;
}

img,
h3,
p{
padding-bottom: 4px;
}
}
}
12 changes: 12 additions & 0 deletions style/scss/_normalize.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* Указываем box sizing */
*,
*::before,
*::after {
box-sizing: border-box;
}

/* Убираем отступы */
* {
padding: 0;
margin: 0;
}
67 changes: 67 additions & 0 deletions style/style.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions style/style.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions style/style.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@import "scss/_normalize";

@import "scss/elements";

@import "scss/_header";
@import "scss/_main";