From 5de3edd601f08a5d0381cd9f0cead642ac7a1ce9 Mon Sep 17 00:00:00 2001 From: Aleksandr Anokhin Date: Fri, 15 Nov 2024 18:32:31 +0300 Subject: [PATCH 1/2] start homework 7 --- js/thumbnail.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/js/thumbnail.js b/js/thumbnail.js index 4d78187..89ef7b9 100644 --- a/js/thumbnail.js +++ b/js/thumbnail.js @@ -1,3 +1,15 @@ +const containerElement = document.querySelector('.pictures'); +const cardTemplate = document.querySelector('#picture').content.querySelector('.picture'); + + export const renderCards = (photos) => { console.log(photos); +const fragment = document.createDocumentFragment(); + photos.forEach((photo) => { + const thumbnail = cardTemplate.cloneNode(true); + thumbnail.querySelector('.picture_img').src = photo.url; + thumbnail.querySelector('.picture_comments').data.textContent('comments'.length); + thumbnail.querySelector('#likes'); + }); + containerElement.append(fragment); }; From 1c5c0a5d199806875b59f63ff04979d6622a355b Mon Sep 17 00:00:00 2001 From: Aleksandr Anokhin Date: Fri, 15 Nov 2024 19:50:10 +0300 Subject: [PATCH 2/2] =?UTF-8?q?=D0=B2=D0=BD=D0=B5=D1=81=20=D0=B8=D0=B7?= =?UTF-8?q?=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=D0=B8=D1=8F.=20=D1=81=D1=82?= =?UTF-8?q?=D1=80=D0=B0=D0=BD=D0=B8=D1=86=D0=B0=20=D1=81=20=D0=BA=D0=BE?= =?UTF-8?q?=D0=BD=D1=82=D0=B5=D0=BD=D1=82=D0=BE=D0=BC=20=D0=B7=D0=B0=D0=B3?= =?UTF-8?q?=D1=80=D1=83=D0=B6=D0=B0=D0=B5=D1=82=D1=81=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/thumbnail.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/js/thumbnail.js b/js/thumbnail.js index 89ef7b9..bf63684 100644 --- a/js/thumbnail.js +++ b/js/thumbnail.js @@ -7,9 +7,10 @@ export const renderCards = (photos) => { const fragment = document.createDocumentFragment(); photos.forEach((photo) => { const thumbnail = cardTemplate.cloneNode(true); - thumbnail.querySelector('.picture_img').src = photo.url; - thumbnail.querySelector('.picture_comments').data.textContent('comments'.length); - thumbnail.querySelector('#likes'); + thumbnail.querySelector('.picture__img').src = photo.url; + thumbnail.querySelector('.picture__comments').textContent = photo.comments.length; + thumbnail.querySelector('.picture__likes').textContent = photo.likes; + fragment.append(thumbnail) }); containerElement.append(fragment); };