-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Отрисуй меня полностью #6
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
import {createArrayOfPhotos} from './data.js'; | ||
|
||
createArrayOfPhotos(); | ||
import './photos.js'; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Лучше всего стараться всегда писать весь код внутри функций. Даже если в файле больше нет функций. Так проще масштабировать код, экспортировать, изолировать переменные. Поэтому здесь тоже лучше создать как минимум одну функцию для создания мениатюр. Может быть ты захочешь создать и больше, чем одну, почему нет) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍🏻 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import {createArrayOfPhotos} from "./data.js"; | ||
const picturesContainer = document.querySelector(".pictures"); | ||
const pictureTemplate = document.querySelector("#picture").content.querySelector(".picture"); | ||
const pictureFragment = document.createDocumentFragment(); | ||
|
||
const photos = createArrayOfPhotos(); | ||
|
||
photos.forEach((photo) => { | ||
const picture = pictureTemplate.cloneNode(true); | ||
|
||
picture.querySelector(".picture__img").src = photo.url; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. У фото еще alt нужно заполнить по заданию There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. как-то пропустил, исправил) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍🏻 |
||
picture.querySelector(".picture__comments").textContent = photo.comments.length; | ||
picture.querySelector(".picture__likes").textContent = photo.likes; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Можно в начале развернуть массив, чтобы проще было обращаться ко всем свойствам. Пример There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Добавил There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Заметил мою ошибку с массивом) Конечно же у нас объект, сделал все правильно |
||
|
||
pictureFragment.append(picture); | ||
}); | ||
|
||
picturesContainer.append(pictureFragment); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Когда создашь функцию в модуле, стоит импортировать ее и вызвать в главном модуле)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Исправил)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏻