Skip to content

Commit

Permalink
дополняет прошлое домашнее задание
Browse files Browse the repository at this point in the history
  • Loading branch information
KateSolodchuk committed Dec 6, 2024
1 parent ad5b007 commit 32dd26f
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 27 deletions.
4 changes: 2 additions & 2 deletions js/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,6 @@ const createPhoto = () => {
};
};

const CreatePhotoList = () => Array.from({length: PHOTO_LIST_LENGTH}, createPhoto());
const createPhotoList = () => Array.from({length: PHOTO_LIST_LENGTH}, createPhoto());

export {CreatePhotoList};
export {createPhotoList};
7 changes: 4 additions & 3 deletions js/main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import './util.js';
import {CreatePhotoList} from './data.js';
import './thumbnails.js';
import {createPhotoList} from './data.js';
import {renderThumbnails} from './render-thumbnails.js';

console.log(CreatePhotoList());
console.log(createPhotoList());
console.log(renderThumbnails());
26 changes: 26 additions & 0 deletions js/render-thumbnails.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import {createPhotoList} from './data.js';

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

const usersThumbnails = createPhotoList ();

const renderThumbnails = () => {
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);

};

export {renderThumbnails};
22 changes: 0 additions & 22 deletions js/thumbnails.js

This file was deleted.

0 comments on commit 32dd26f

Please sign in to comment.