Skip to content

Commit

Permalink
отображает фотографии
Browse files Browse the repository at this point in the history
  • Loading branch information
ClaireFotina committed Dec 1, 2024
1 parent 5887252 commit cd225d7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
4 changes: 3 additions & 1 deletion js/main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import {getData} from './data.js'
import {renderThumbnails} from './thumbnails.js'

const data = getData();
renderThumbnails(data);

console.log(data)
//console.log(data)
19 changes: 19 additions & 0 deletions js/thumbnails.js
Original file line number Diff line number Diff line change
@@ -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);
})
}




0 comments on commit cd225d7

Please sign in to comment.