Skip to content

Commit

Permalink
Merge pull request #6 from KateSolodchuk/module7-task1
Browse files Browse the repository at this point in the history
  • Loading branch information
keksobot authored Nov 23, 2024
2 parents 22f26cb + 42bed0c commit ad5b007
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions js/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import './util.js';
import {CreatePhotoList} from './data.js';
import './thumbnails.js';

console.log(CreatePhotoList());

Check failure on line 5 in js/main.js

View workflow job for this annotation

GitHub Actions / Check

Unexpected console statement
22 changes: 22 additions & 0 deletions js/thumbnails.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import {CreatePhotoList} from './data.js';

const pictures = document.querySelector('.pictures');
const thumbnailsTemplate = document.querySelector('#picture')
.content
.querySelector('.picture');

const usersThumbnails = CreatePhotoList ();

const usersThumbnailsFragment = document.createDocumentFragment();

usersThumbnails.forEach((photo) => {
const usersElement = thumbnailsTemplate.cloneNode(true);
usersElement.querySelector('.picture__img').src = photo.url;
usersElement.querySelector('.picture__img').alt = photo.description;
usersElement.querySelector('.picture__likes').textContent = photo.likes;
usersElement.querySelector('.picture__comments').textContent = photo.comments.length;
usersThumbnailsFragment.appendChild(usersElement);
});

pictures.appendChild(usersThumbnailsFragment);

0 comments on commit ad5b007

Please sign in to comment.