-
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.
Merge pull request #10 from aLesya66/module7-task1
- Loading branch information
Showing
5 changed files
with
59 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { finalMas } from './mas.js'; | ||
|
||
const template = document.querySelector('#picture').content.querySelector('.picture'); | ||
const container = document.querySelector('.pictures'); | ||
|
||
const similarFinalMas = finalMas(); | ||
|
||
const fragment = document.createDocumentFragment(); | ||
|
||
similarFinalMas.forEach(({url, description, comments, likes}) => { | ||
const copy = template.cloneNode(true); | ||
|
||
copy.querySelector('.picture__img').src = url; | ||
copy.querySelector('.picture__img').alt = description; | ||
copy.querySelector('.picture__comments').textContent = comments.length;// | ||
copy.querySelector('.picture__likes').textContent = likes;// | ||
|
||
container.append(copy); | ||
}); | ||
|
||
container.appendChild(fragment); | ||
export{similarFinalMas}; | ||
|
||
/* <template id="picture"> | ||
<a href="#" class="picture"> | ||
<img class="picture__img" src="" width="182" height="182" alt="Случайная фотография"> | ||
<p class="picture__info"> | ||
<span class="picture__comments"></span> | ||
<span class="picture__likes"></span> | ||
</p> | ||
</a> | ||
</template> */ | ||
/* <section class="pictures container"> | ||
<h2 class="pictures__title visually-hidden">Фотографии других пользователей</h2> */ |
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 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,2 @@ | ||
import { finalMas } from './data'; | ||
// eslint-disable-next-line no-console | ||
console.log(finalMas); | ||
import {similarFinalMas} from './createMiniature.js'; | ||
similarFinalMas(); |
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,20 @@ | ||
import {getRandomArrayElement, getRandomInteger} from './rand.js'; | ||
import {description, messageCommentator, nameCommentator, count} from './data.js'; | ||
|
||
const createComment = (indexx) => ({ | ||
id: indexx + 1, | ||
avatar: `img/avatar-${ getRandomInteger(1, 6) } .svg`, | ||
message: `${getRandomArrayElement(messageCommentator)}`, | ||
name: `${getRandomArrayElement(nameCommentator)}`, | ||
}); | ||
|
||
const createUsers = (index) => ({ | ||
id: index + 1, | ||
url: `photos/${ index + 1 }.jpg` , | ||
description: `${getRandomArrayElement(description)}`, | ||
likes: getRandomInteger(1, 200), | ||
comments: Array.from({ length: getRandomInteger(1, 30) }, (__, indexx) => createComment(indexx)), | ||
}); | ||
const finalMas = () => Array.from({length:count}, (__, index) => createUsers(index)); | ||
|
||
export {finalMas}; |
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