From a3d21b1e26572a150939cfed2934273bf8bcd1b4 Mon Sep 17 00:00:00 2001 From: Evgeny Dudarev Date: Sun, 22 Dec 2019 21:09:34 +0300 Subject: [PATCH 01/29] Updated .gitignore. Started js --- .gitignore | 2 +- index.html | 12 ++++++------ js/index.js | 2 ++ js/product-card-popup.js | 8 ++++++++ 4 files changed, 17 insertions(+), 7 deletions(-) create mode 100644 js/product-card-popup.js diff --git a/.gitignore b/.gitignore index 6aaaf01..2691d9a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ /node_modules /dist - +notes.txt yarn-error.log .idea .cache diff --git a/index.html b/index.html index bb24f27..89b44be 100644 --- a/index.html +++ b/index.html @@ -136,7 +136,7 @@

Популярные товары

-
+
Зонт
@@ -147,7 +147,7 @@

Популярные товары

-
+
Сумка
@@ -158,7 +158,7 @@

Популярные товары

-
+
Шлепанцы
@@ -169,7 +169,7 @@

Популярные товары

-
+
Футболка
sale
@@ -182,7 +182,7 @@

Популярные товары

-
+
Толстовка
@@ -193,7 +193,7 @@

Популярные товары

-
+
Подушка
diff --git a/js/index.js b/js/index.js index f8b8ff8..1040c7f 100644 --- a/js/index.js +++ b/js/index.js @@ -1,2 +1,4 @@ import "./grid"; +import "./model"; import "./slider"; +import "./product-card-popup"; diff --git a/js/product-card-popup.js b/js/product-card-popup.js new file mode 100644 index 0000000..88d38a9 --- /dev/null +++ b/js/product-card-popup.js @@ -0,0 +1,8 @@ +//Повесить обработчик клика по карточке товара +let productCards = document + .querySelectorAll(".product-card") + .forEach(productCard => { + addEventListener("onclick", () => { + console.log(`${productCard.dataset.goods - id}`); + }); + }); From 1a83e887d390425bd08371e999c9e5ba45acb3c0 Mon Sep 17 00:00:00 2001 From: Evgeny Dudarev Date: Mon, 23 Dec 2019 09:17:09 +0300 Subject: [PATCH 02/29] Removed _popup modifier from product-card --- css/blocks/product-card/product-card.less | 14 ++++++-------- index.html | 18 +++++++++--------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/css/blocks/product-card/product-card.less b/css/blocks/product-card/product-card.less index 52acb32..0609049 100644 --- a/css/blocks/product-card/product-card.less +++ b/css/blocks/product-card/product-card.less @@ -9,15 +9,13 @@ font-size: 0; position: relative; - &_popup { - width: 212px; - height: 212px; - margin: 0 auto 10px auto; + width: 212px; + height: 212px; + margin: 0 auto 10px auto; - @media @screen-gt-m { - width: 290px; - height: 290px; - } + @media @screen-gt-m { + width: 290px; + height: 290px; } &_form { diff --git a/index.html b/index.html index 89b44be..5a1cffc 100644 --- a/index.html +++ b/index.html @@ -136,7 +136,7 @@

Популярные товары

-
+
Зонт
@@ -147,7 +147,7 @@

Популярные товары

-
+
Сумка
@@ -158,7 +158,7 @@

Популярные товары

-
+
Шлепанцы
@@ -169,7 +169,7 @@

Популярные товары

-
+
Футболка
sale
@@ -182,7 +182,7 @@

Популярные товары

-
+
Толстовка
@@ -193,7 +193,7 @@

Популярные товары

-
+
Подушка
@@ -468,7 +468,7 @@

Красная хлопоковая фут

-
+
Красная хлопоковая фут
- - + + From e7f4f6abc19d054d4db16dc4f47fdc8b1bed3687 Mon Sep 17 00:00:00 2001 From: Evgeny Dudarev Date: Mon, 23 Dec 2019 19:13:40 +0300 Subject: [PATCH 03/29] Started with popup for product-card --- css/blocks/product-card/product-card.less | 1 - js/index.js | 1 - js/model.js | 69 ++++++++++++++ js/product-card-popup.js | 26 +++++- js/render-product-card.js | 107 ++++++++++++++++++++++ 5 files changed, 199 insertions(+), 5 deletions(-) create mode 100644 js/model.js create mode 100644 js/render-product-card.js diff --git a/css/blocks/product-card/product-card.less b/css/blocks/product-card/product-card.less index 0609049..3b0c44b 100644 --- a/css/blocks/product-card/product-card.less +++ b/css/blocks/product-card/product-card.less @@ -5,7 +5,6 @@ cursor: pointer; &__image-container { - margin-bottom: 10px; font-size: 0; position: relative; diff --git a/js/index.js b/js/index.js index 1040c7f..2fd920f 100644 --- a/js/index.js +++ b/js/index.js @@ -1,4 +1,3 @@ import "./grid"; -import "./model"; import "./slider"; import "./product-card-popup"; diff --git a/js/model.js b/js/model.js new file mode 100644 index 0000000..7e27a79 --- /dev/null +++ b/js/model.js @@ -0,0 +1,69 @@ +export let productsData = [ + { + id: "1", + name: "Зонт", + description: "Красный зонт с логотипом HH", + image: "product-1.jpg", + price: "1 990" + }, + { + id: "2", + name: "Сумка", + description: "Красная сумка с логотипом HH", + image: "product-2.jpg", + price: "290" + }, + { + id: "3", + name: "Шлепанцы", + description: "Красные шлепанцы с логотипом HH", + image: "product-3.jpg", + price: "790", + sizes: { + xs: true, + x: true, + m: true, + l: true, + xl: true, + xxl: true + } + }, + { + id: "4", + name: "Футболка", + description: "Красная футболка с логотипом HH", + image: "product-4.jpg", + price: "690", + salePrice: "390", + sizes: { + xs: true, + x: true, + m: true, + l: true, + xl: true, + xxl: true + } + }, + { + id: "5", + name: "Толстовка", + description: "Красная толстовка с логотипом HH", + image: "product-5.jpg", + price: "3 990", + sizes: { + xs: true, + x: true, + m: true, + l: true, + xl: true, + xxl: true + } + }, + { + id: "6", + name: "Подушка", + description: "Красная подушка с логотипом HH", + image: "product-6.jpg", + price: "990" + } +]; diff --git a/js/product-card-popup.js b/js/product-card-popup.js index 88d38a9..c112d7f 100644 --- a/js/product-card-popup.js +++ b/js/product-card-popup.js @@ -1,8 +1,28 @@ +import { productsData } from "./model"; +import { renderProductCard } from "./render-product-card"; + +let showDataId = e => { + let target = e.target; + + while (!target.classList.contains("product-card")) { + target = target.parentNode; + + if (target.classList.contains("content-section")) { + return; + } + } + + const productData = productsData.find( + product => product.id === target.dataset.productId + ); + + console.log(productData); + const productCardTemplate = renderProductCard(productData); +}; + //Повесить обработчик клика по карточке товара let productCards = document .querySelectorAll(".product-card") .forEach(productCard => { - addEventListener("onclick", () => { - console.log(`${productCard.dataset.goods - id}`); - }); + productCard.addEventListener("click", showDataId); }); diff --git a/js/render-product-card.js b/js/render-product-card.js new file mode 100644 index 0000000..936dc56 --- /dev/null +++ b/js/render-product-card.js @@ -0,0 +1,107 @@ +export let renderProductCard = productData => { + return ` + */ From 0d629f5fc390695e482eaec272c833af18cbbb43 Mon Sep 17 00:00:00 2001 From: Evgeny Dudarev Date: Thu, 26 Dec 2019 12:29:12 +0300 Subject: [PATCH 04/29] Added disabled style for labels and style fot popup --- css/blocks/popup/popup.less | 6 +++++- css/common/label/label.less | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/css/blocks/popup/popup.less b/css/blocks/popup/popup.less index db87c20..084798a 100644 --- a/css/blocks/popup/popup.less +++ b/css/blocks/popup/popup.less @@ -1,7 +1,11 @@ .popup { width: 280px; border: 1px solid; - margin: 40px auto; + position: absolute; + top: 300px; + left: 300px; + transition: all 1s linear; + z-index: 100; @media @screen-gt-s { width: 242px; diff --git a/css/common/label/label.less b/css/common/label/label.less index 29eb911..a8067e7 100644 --- a/css/common/label/label.less +++ b/css/common/label/label.less @@ -6,4 +6,8 @@ .label { .label-default(); + + &_disabled { + opacity: 0.7; + } } From adb1a35b1ae530dfbdc8eef469ed17c5cab96443 Mon Sep 17 00:00:00 2001 From: Evgeny Dudarev Date: Thu, 26 Dec 2019 12:30:28 +0300 Subject: [PATCH 05/29] Designed js-model scheme for products --- js/model.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/model.js b/js/model.js index 7e27a79..aa7facf 100644 --- a/js/model.js +++ b/js/model.js @@ -22,7 +22,7 @@ export let productsData = [ sizes: { xs: true, x: true, - m: true, + m: false, l: true, xl: true, xxl: true From 507716f313a6184c3b9c609796d99962d13f5401 Mon Sep 17 00:00:00 2001 From: Evgeny Dudarev Date: Thu, 26 Dec 2019 12:31:22 +0300 Subject: [PATCH 06/29] Designed js-function for rendering product-card-tempalte --- js/render-product-card.js | 133 +++++++++++++------------------------- 1 file changed, 45 insertions(+), 88 deletions(-) diff --git a/js/render-product-card.js b/js/render-product-card.js index 936dc56..91f1652 100644 --- a/js/render-product-card.js +++ b/js/render-product-card.js @@ -1,5 +1,7 @@ +//Простой шаблон карточки продукта, основанный на интерполяции строк + export let renderProductCard = productData => { - return ` - */ + return ( + productCardMainTemplate + + productCardSizesTemplate + + "
\n" + + "
\n" + + submitButtonTemplate + ); + } +}; From 84d5a120070996a3e6e13e1cb5566353fc101a3e Mon Sep 17 00:00:00 2001 From: Evgeny Dudarev Date: Fri, 27 Dec 2019 18:00:32 +0300 Subject: [PATCH 07/29] Added styles for popup and button --- css/blocks/popup/popup.less | 14 +++++++++++--- css/common/button/button.less | 4 ++++ index.html | 11 +++++------ 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/css/blocks/popup/popup.less b/css/blocks/popup/popup.less index 084798a..e321cfa 100644 --- a/css/blocks/popup/popup.less +++ b/css/blocks/popup/popup.less @@ -2,11 +2,15 @@ width: 280px; border: 1px solid; position: absolute; - top: 300px; - left: 300px; - transition: all 1s linear; + opacity: 0; + transition: all 300ms linear; + background-color: @color-light; z-index: 100; + &_active { + opacity: 1; + } + @media @screen-gt-s { width: 242px; } @@ -34,5 +38,9 @@ z-index: 100; right: -10px; top: -10px; + + @media @screen-gt-m { + display: none; + } } } diff --git a/css/common/button/button.less b/css/common/button/button.less index e8f5762..a49c1e7 100644 --- a/css/common/button/button.less +++ b/css/common/button/button.less @@ -36,6 +36,10 @@ .button(); width: 100%; + &_disabled { + opacity: 0.5; + } + @media @screen-gt-s { width: 138px; } diff --git a/index.html b/index.html index 5a1cffc..4f702fe 100644 --- a/index.html +++ b/index.html @@ -6,7 +6,7 @@ HTML и CSS - +