Skip to content

Commit

Permalink
удален файл function.js, добавлен новый модуль thumbnails.js, отвечаю…
Browse files Browse the repository at this point in the history
…щий за отрисовку миниатюр
  • Loading branch information
marijachernova committed Nov 6, 2024
1 parent 09ddb33 commit e19de9d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 66 deletions.
1 change: 0 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ <h2 class="success__title">Изображение успешно загруже
</div>
</section>
</template>
<script src="js/functions.js"></script>
<script src="js/main.js" type="module"></script>
</body>
</html>
64 changes: 0 additions & 64 deletions js/functions.js

This file was deleted.

3 changes: 2 additions & 1 deletion js/main.js
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());
25 changes: 25 additions & 0 deletions js/thumbnail.js
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;

Check failure on line 9 in js/thumbnail.js

View workflow job for this annotation

GitHub Actions / Check

Operator '=' must be spaced
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 };

0 comments on commit e19de9d

Please sign in to comment.