-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
удален файл function.js, добавлен новый модуль thumbnails.js, отвечаю…
…щий за отрисовку миниатюр
- Loading branch information
1 parent
09ddb33
commit e19de9d
Showing
4 changed files
with
27 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import { getImages } from './data.js'; | ||
import { showThumbnails } from './thumbnail.js'; | ||
|
||
getImages(); | ||
showThumbnails(getImages()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const container = document.querySelector('.pictures'); | ||
const templateFragment = document.querySelector('#picture').content; | ||
const template = templateFragment.querySelector('.picture'); | ||
|
||
const createThumbnail = ({url, description, comments, likes}) => { | ||
const thumbnail = template.cloneNode(true); | ||
|
||
thumbnail.querySelector('.picture__img').src = url; | ||
thumbnail.querySelector('.picture__img').alt= description; | ||
thumbnail.querySelector('.picture__comments').textContent = comments.length; | ||
thumbnail.querySelector('.picture__likes').textContent = likes; | ||
|
||
return thumbnail; | ||
}; | ||
|
||
const showThumbnails = (pictures) => { | ||
const fragment = document.createDocumentFragment(); | ||
pictures.forEach((picture) => { | ||
const thumbnail = createThumbnail(picture); | ||
fragment.append(thumbnail); | ||
}); | ||
container.append(fragment); | ||
}; | ||
|
||
export { showThumbnails }; |