From cd225d7fffc33ce360317839e348738f62e9d1b3 Mon Sep 17 00:00:00 2001 From: ClaireFotina Date: Sun, 1 Dec 2024 21:19:31 +0400 Subject: [PATCH] =?UTF-8?q?=D0=BE=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6?= =?UTF-8?q?=D0=B0=D0=B5=D1=82=20=D1=84=D0=BE=D1=82=D0=BE=D0=B3=D1=80=D0=B0?= =?UTF-8?q?=D1=84=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/main.js | 4 +++- js/thumbnails.js | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 js/thumbnails.js diff --git a/js/main.js b/js/main.js index c20bccc..5c39269 100644 --- a/js/main.js +++ b/js/main.js @@ -1,5 +1,7 @@ import {getData} from './data.js' +import {renderThumbnails} from './thumbnails.js' const data = getData(); +renderThumbnails(data); -console.log(data) \ No newline at end of file +//console.log(data) \ No newline at end of file diff --git a/js/thumbnails.js b/js/thumbnails.js new file mode 100644 index 0000000..1f87b57 --- /dev/null +++ b/js/thumbnails.js @@ -0,0 +1,19 @@ +const template = document.querySelector('#picture').content.querySelector('.picture'); +const container = document.querySelector('.pictures'); + +export const renderThumbnails = (photos) => { + console.log('@@@', photos) + photos.forEach((photo) => { + const thumbnail = template.cloneNode(true); + const img = thumbnail.querySelector('.picture__img'); + img.src = photo.url; + img.alt = photo.description; + thumbnail.querySelector('.picture__comments').textContent = photo.comments.length; + thumbnail.querySelector('.picture__likes').textContent = photo.likes; + container.append(thumbnail); + }) +} + + + +